framer-motion 9.1.6 → 10.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/cjs/index.js +76 -138
  2. package/dist/es/animation/waapi/create-accelerated-animation.mjs +4 -1
  3. package/dist/es/components/AnimatePresence/index.mjs +2 -8
  4. package/dist/es/components/AnimateSharedLayout.mjs +2 -2
  5. package/dist/es/components/LayoutGroup/index.mjs +2 -7
  6. package/dist/es/gestures/drag/VisualElementDragControls.mjs +2 -2
  7. package/dist/es/gestures/focus.mjs +2 -2
  8. package/dist/es/gestures/hover.mjs +1 -1
  9. package/dist/es/gestures/press.mjs +2 -2
  10. package/dist/es/index.mjs +1 -3
  11. package/dist/es/motion/features/animation/exit.mjs +1 -1
  12. package/dist/es/motion/features/viewport/index.mjs +2 -25
  13. package/dist/es/render/dom/viewport/index.mjs +0 -9
  14. package/dist/es/render/utils/animation-state.mjs +9 -17
  15. package/dist/es/render/utils/motion-values.mjs +1 -1
  16. package/dist/es/render/utils/variant-props.mjs +7 -7
  17. package/dist/es/value/index.mjs +5 -1
  18. package/dist/framer-motion.dev.js +76 -138
  19. package/dist/framer-motion.js +1 -1
  20. package/dist/index.d.ts +5 -35
  21. package/dist/projection.dev.js +26 -20
  22. package/dist/size-rollup-dom-animation-assets.js +1 -1
  23. package/dist/size-rollup-dom-animation.js +1 -1
  24. package/dist/size-rollup-dom-max-assets.js +1 -1
  25. package/dist/size-rollup-dom-max.js +1 -1
  26. package/dist/size-rollup-motion.js +1 -1
  27. package/dist/size-webpack-dom-animation.js +1 -1
  28. package/dist/size-webpack-dom-max.js +1 -1
  29. package/dist/size-webpack-m.js +1 -1
  30. package/dist/three-entry.d.ts +1 -13
  31. package/package.json +8 -8
  32. package/dist/es/context/DeprecatedLayoutGroupContext.mjs +0 -8
  33. package/dist/es/render/utils/types.mjs +0 -12
package/dist/cjs/index.js CHANGED
@@ -150,16 +150,16 @@ function isAnimationControls(v) {
150
150
  return typeof v === "object" && typeof v.start === "function";
151
151
  }
152
152
 
153
- const variantPriorityOrder$1 = [
154
- "animate" /* AnimationType.Animate */,
155
- "whileInView" /* AnimationType.InView */,
156
- "whileFocus" /* AnimationType.Focus */,
157
- "whileHover" /* AnimationType.Hover */,
158
- "whileTap" /* AnimationType.Tap */,
159
- "whileDrag" /* AnimationType.Drag */,
160
- "exit" /* AnimationType.Exit */,
153
+ const variantPriorityOrder = [
154
+ "animate",
155
+ "whileInView",
156
+ "whileFocus",
157
+ "whileHover",
158
+ "whileTap",
159
+ "whileDrag",
160
+ "exit",
161
161
  ];
162
- const variantProps = ["initial", ...variantPriorityOrder$1];
162
+ const variantProps = ["initial", ...variantPriorityOrder];
163
163
 
164
164
  function isControllingVariants(props) {
165
165
  return (isAnimationControls(props.animate) ||
@@ -1405,7 +1405,7 @@ function addHoverEvent(node, isActive) {
1405
1405
  return;
1406
1406
  const props = node.getProps();
1407
1407
  if (node.animationState && props.whileHover) {
1408
- node.animationState.setActive("whileHover" /* AnimationType.Hover */, isActive);
1408
+ node.animationState.setActive("whileHover", isActive);
1409
1409
  }
1410
1410
  if (props[callbackName]) {
1411
1411
  props[callbackName](event, info);
@@ -1443,13 +1443,13 @@ class FocusGesture extends Feature {
1443
1443
  }
1444
1444
  if (!isFocusVisible || !this.node.animationState)
1445
1445
  return;
1446
- this.node.animationState.setActive("whileFocus" /* AnimationType.Focus */, true);
1446
+ this.node.animationState.setActive("whileFocus", true);
1447
1447
  this.isActive = true;
1448
1448
  }
1449
1449
  onBlur() {
1450
1450
  if (!this.isActive || !this.node.animationState)
1451
1451
  return;
1452
- this.node.animationState.setActive("whileFocus" /* AnimationType.Focus */, false);
1452
+ this.node.animationState.setActive("whileFocus", false);
1453
1453
  this.isActive = false;
1454
1454
  }
1455
1455
  mount() {
@@ -1545,7 +1545,7 @@ class PressGesture extends Feature {
1545
1545
  * Ensure we trigger animations before firing event callback
1546
1546
  */
1547
1547
  if (whileTap && this.node.animationState) {
1548
- this.node.animationState.setActive("whileTap" /* AnimationType.Tap */, true);
1548
+ this.node.animationState.setActive("whileTap", true);
1549
1549
  }
1550
1550
  onTapStart && onTapStart(event, info);
1551
1551
  }
@@ -1554,7 +1554,7 @@ class PressGesture extends Feature {
1554
1554
  this.isPressing = false;
1555
1555
  const props = this.node.getProps();
1556
1556
  if (props.whileTap && this.node.animationState) {
1557
- this.node.animationState.setActive("whileTap" /* AnimationType.Tap */, false);
1557
+ this.node.animationState.setActive("whileTap", false);
1558
1558
  }
1559
1559
  return !isDragActive();
1560
1560
  }
@@ -1635,33 +1635,10 @@ class InViewFeature extends Feature {
1635
1635
  this.hasEnteredView = false;
1636
1636
  this.isInView = false;
1637
1637
  }
1638
- /**
1639
- * TODO: Remove this in 10.0
1640
- */
1641
- viewportFallback() {
1642
- /**
1643
- * Fire this in an rAF because, at this point, the animation state
1644
- * won't have flushed for the first time and there's certain logic in
1645
- * there that behaves differently on the initial animation.
1646
- */
1647
- requestAnimationFrame(() => {
1648
- this.hasEnteredView = true;
1649
- const { onViewportEnter } = this.node.getProps();
1650
- onViewportEnter && onViewportEnter(null);
1651
- if (this.node.animationState) {
1652
- this.node.animationState.setActive("whileInView" /* AnimationType.InView */, true);
1653
- }
1654
- });
1655
- }
1656
1638
  startObserver() {
1657
1639
  this.unmount();
1658
1640
  const { viewport = {} } = this.node.getProps();
1659
- const { root, margin: rootMargin, amount = "some", once, fallback = true, } = viewport;
1660
- if (typeof IntersectionObserver === "undefined") {
1661
- if (fallback)
1662
- this.viewportFallback();
1663
- return;
1664
- }
1641
+ const { root, margin: rootMargin, amount = "some", once } = viewport;
1665
1642
  const options = {
1666
1643
  root: root ? root.current : undefined,
1667
1644
  rootMargin,
@@ -1686,7 +1663,7 @@ class InViewFeature extends Feature {
1686
1663
  this.hasEnteredView = true;
1687
1664
  }
1688
1665
  if (this.node.animationState) {
1689
- this.node.animationState.setActive("whileInView" /* AnimationType.InView */, isIntersecting);
1666
+ this.node.animationState.setActive("whileInView", isIntersecting);
1690
1667
  }
1691
1668
  /**
1692
1669
  * Use the latest committed props rather than the ones in scope
@@ -1978,6 +1955,16 @@ function velocityPerSecond(velocity, frameDuration) {
1978
1955
  return frameDuration ? velocity * (1000 / frameDuration) : 0;
1979
1956
  }
1980
1957
 
1958
+ const warned = new Set();
1959
+ function warnOnce(condition, message, element) {
1960
+ if (condition || warned.has(message))
1961
+ return;
1962
+ console.warn(message);
1963
+ if (element)
1964
+ console.warn(element);
1965
+ warned.add(message);
1966
+ }
1967
+
1981
1968
  const isFloat = (value) => {
1982
1969
  return !isNaN(parseFloat(value));
1983
1970
  };
@@ -2000,7 +1987,7 @@ class MotionValue {
2000
1987
  * This will be replaced by the build step with the latest version number.
2001
1988
  * When MotionValues are provided to motion components, warn if versions are mixed.
2002
1989
  */
2003
- this.version = "9.1.6";
1990
+ this.version = "10.0.0-alpha.0";
2004
1991
  /**
2005
1992
  * Duration, in milliseconds, since last updating frame.
2006
1993
  *
@@ -2120,6 +2107,9 @@ class MotionValue {
2120
2107
  * @deprecated
2121
2108
  */
2122
2109
  onChange(subscription) {
2110
+ if (process.env.NODE_ENV !== "production") {
2111
+ warnOnce(false, `value.onChange(callback) is deprecated. Switch to value.on("change", callback).`);
2112
+ }
2123
2113
  return this.on("change", subscription);
2124
2114
  }
2125
2115
  on(eventName, callback) {
@@ -3614,6 +3604,7 @@ const acceleratedValues = new Set([
3614
3604
  "clipPath",
3615
3605
  "filter",
3616
3606
  "transform",
3607
+ "backgroundColor",
3617
3608
  ]);
3618
3609
  /**
3619
3610
  * 10ms is chosen here as it strikes a balance between smooth
@@ -3633,7 +3624,9 @@ function createAcceleratedAnimation(value, valueName, { onUpdate, onComplete, ..
3633
3624
  /**
3634
3625
  * If this animation needs pre-generated keyframes then generate.
3635
3626
  */
3636
- if (options.type === "spring" || !isWaapiSupportedEasing(options.ease)) {
3627
+ if (options.type === "spring" ||
3628
+ valueName === "backgroundColor" ||
3629
+ !isWaapiSupportedEasing(options.ease)) {
3637
3630
  /**
3638
3631
  * If we need to pre-generate keyframes and repeat is infinite then
3639
3632
  * early return as this will lock the thread.
@@ -4179,15 +4172,6 @@ function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
4179
4172
  return shouldBlock;
4180
4173
  }
4181
4174
 
4182
- const variantPriorityOrder = [
4183
- "animate" /* AnimationType.Animate */,
4184
- "whileInView" /* AnimationType.InView */,
4185
- "whileFocus" /* AnimationType.Focus */,
4186
- "whileHover" /* AnimationType.Hover */,
4187
- "whileTap" /* AnimationType.Tap */,
4188
- "whileDrag" /* AnimationType.Drag */,
4189
- "exit" /* AnimationType.Exit */,
4190
- ];
4191
4175
  const reversePriorityOrder = [...variantPriorityOrder].reverse();
4192
4176
  const numAnimationTypes = variantPriorityOrder.length;
4193
4177
  function animateList(visualElement) {
@@ -4488,13 +4472,13 @@ function createTypeState(isActive = false) {
4488
4472
  }
4489
4473
  function createState() {
4490
4474
  return {
4491
- ["animate" /* AnimationType.Animate */]: createTypeState(true),
4492
- ["whileInView" /* AnimationType.InView */]: createTypeState(),
4493
- ["whileHover" /* AnimationType.Hover */]: createTypeState(),
4494
- ["whileTap" /* AnimationType.Tap */]: createTypeState(),
4495
- ["whileDrag" /* AnimationType.Drag */]: createTypeState(),
4496
- ["whileFocus" /* AnimationType.Focus */]: createTypeState(),
4497
- ["exit" /* AnimationType.Exit */]: createTypeState(),
4475
+ animate: createTypeState(true),
4476
+ whileInView: createTypeState(),
4477
+ whileHover: createTypeState(),
4478
+ whileTap: createTypeState(),
4479
+ whileDrag: createTypeState(),
4480
+ whileFocus: createTypeState(),
4481
+ exit: createTypeState(),
4498
4482
  };
4499
4483
  }
4500
4484
 
@@ -4545,7 +4529,7 @@ class ExitAnimationFeature extends Feature {
4545
4529
  if (!this.node.animationState || isPresent === prevIsPresent) {
4546
4530
  return;
4547
4531
  }
4548
- const exitAnimation = this.node.animationState.setActive("exit" /* AnimationType.Exit */, !isPresent, { custom: custom !== null && custom !== void 0 ? custom : this.node.getProps().custom });
4532
+ const exitAnimation = this.node.animationState.setActive("exit", !isPresent, { custom: custom !== null && custom !== void 0 ? custom : this.node.getProps().custom });
4549
4533
  if (onExitComplete && !isPresent) {
4550
4534
  exitAnimation.then(() => onExitComplete(this.id));
4551
4535
  }
@@ -5159,7 +5143,7 @@ class VisualElementDragControls {
5159
5143
  // Fire onDragStart event
5160
5144
  onDragStart && onDragStart(event, info);
5161
5145
  const { animationState } = this.visualElement;
5162
- animationState && animationState.setActive("whileDrag" /* AnimationType.Drag */, true);
5146
+ animationState && animationState.setActive("whileDrag", true);
5163
5147
  };
5164
5148
  const onMove = (event, info) => {
5165
5149
  // latestPointerEvent = event
@@ -5224,7 +5208,7 @@ class VisualElementDragControls {
5224
5208
  this.openGlobalLock();
5225
5209
  this.openGlobalLock = null;
5226
5210
  }
5227
- animationState && animationState.setActive("whileDrag" /* AnimationType.Drag */, false);
5211
+ animationState && animationState.setActive("whileDrag", false);
5228
5212
  }
5229
5213
  updateAxis(axis, _point, offset) {
5230
5214
  const { drag } = this.getProps();
@@ -7828,16 +7812,6 @@ function initPrefersReducedMotion() {
7828
7812
  }
7829
7813
  }
7830
7814
 
7831
- const warned = new Set();
7832
- function warnOnce(condition, message, element) {
7833
- if (condition || warned.has(message))
7834
- return;
7835
- console.warn(message);
7836
- if (element)
7837
- console.warn(element);
7838
- warned.add(message);
7839
- }
7840
-
7841
7815
  function updateMotionValuesFromProps(element, next, prev) {
7842
7816
  const { willChange } = next;
7843
7817
  for (const key in next) {
@@ -7857,7 +7831,7 @@ function updateMotionValuesFromProps(element, next, prev) {
7857
7831
  * and warn against mismatches.
7858
7832
  */
7859
7833
  if (process.env.NODE_ENV === "development") {
7860
- warnOnce(nextValue.version === "9.1.6", `Attempting to mix Framer Motion versions ${nextValue.version} with 9.1.6 may not work as expected.`);
7834
+ warnOnce(nextValue.version === "10.0.0-alpha.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.0.0-alpha.0 may not work as expected.`);
7861
7835
  }
7862
7836
  }
7863
7837
  else if (isMotionValue(prevValue)) {
@@ -8935,13 +8909,7 @@ function onlyElements(children) {
8935
8909
  * @public
8936
8910
  */
8937
8911
  const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exitBeforeEnter, presenceAffectsLayout = true, mode = "sync", }) => {
8938
- // Support deprecated exitBeforeEnter prop
8939
- if (exitBeforeEnter) {
8940
- mode = "wait";
8941
- if (process.env.NODE_ENV !== "production") {
8942
- warnOnce(false, "Replace exitBeforeEnter with mode='wait'");
8943
- }
8944
- }
8912
+ exports.invariant(!exitBeforeEnter, "Replace exitBeforeEnter with mode='wait'");
8945
8913
  // We want to force a re-render once all exiting animations have finished. We
8946
8914
  // either use a local forceRender function, or one from a parent context if it exists.
8947
8915
  let [forceRender] = useForceUpdate();
@@ -9036,45 +9004,6 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exi
9036
9004
  : childrenToRender.map((child) => React.cloneElement(child))));
9037
9005
  };
9038
9006
 
9039
- /**
9040
- * @deprecated
9041
- */
9042
- const DeprecatedLayoutGroupContext = React.createContext(null);
9043
-
9044
- const shouldInheritGroup = (inherit) => inherit === true;
9045
- const shouldInheritId = (inherit) => shouldInheritGroup(inherit === true) || inherit === "id";
9046
- const LayoutGroup = ({ children, id, inheritId, inherit = true }) => {
9047
- // Maintain backwards-compatibility with inheritId until 7.0
9048
- if (inheritId !== undefined)
9049
- inherit = inheritId;
9050
- const layoutGroupContext = React.useContext(LayoutGroupContext);
9051
- const deprecatedLayoutGroupContext = React.useContext(DeprecatedLayoutGroupContext);
9052
- const [forceRender, key] = useForceUpdate();
9053
- const context = React.useRef(null);
9054
- const upstreamId = layoutGroupContext.id || deprecatedLayoutGroupContext;
9055
- if (context.current === null) {
9056
- if (shouldInheritId(inherit) && upstreamId) {
9057
- id = id ? upstreamId + "-" + id : upstreamId;
9058
- }
9059
- context.current = {
9060
- id,
9061
- group: shouldInheritGroup(inherit)
9062
- ? layoutGroupContext.group || nodeGroup()
9063
- : nodeGroup(),
9064
- };
9065
- }
9066
- const memoizedContext = React.useMemo(() => ({ ...context.current, forceRender }), [key]);
9067
- return (React__namespace.createElement(LayoutGroupContext.Provider, { value: memoizedContext }, children));
9068
- };
9069
-
9070
- let id = 0;
9071
- const AnimateSharedLayout = ({ children }) => {
9072
- React__namespace.useEffect(() => {
9073
- exports.warning(false, "AnimateSharedLayout is deprecated: https://www.framer.com/docs/guide-upgrade/##shared-layout-animations");
9074
- }, []);
9075
- return (React__namespace.createElement(LayoutGroup, { id: useConstant(() => `asl-${id++}`) }, children));
9076
- };
9077
-
9078
9007
  /**
9079
9008
  * `MotionConfig` is used to set configuration options for all children `motion` components.
9080
9009
  *
@@ -9172,6 +9101,28 @@ function isLazyBundle(features) {
9172
9101
  return typeof features === "function";
9173
9102
  }
9174
9103
 
9104
+ const shouldInheritGroup = (inherit) => inherit === true;
9105
+ const shouldInheritId = (inherit) => shouldInheritGroup(inherit === true) || inherit === "id";
9106
+ const LayoutGroup = ({ children, id, inherit = true }) => {
9107
+ const layoutGroupContext = React.useContext(LayoutGroupContext);
9108
+ const [forceRender, key] = useForceUpdate();
9109
+ const context = React.useRef(null);
9110
+ const upstreamId = layoutGroupContext.id;
9111
+ if (context.current === null) {
9112
+ if (shouldInheritId(inherit) && upstreamId) {
9113
+ id = id ? upstreamId + "-" + id : upstreamId;
9114
+ }
9115
+ context.current = {
9116
+ id,
9117
+ group: shouldInheritGroup(inherit)
9118
+ ? layoutGroupContext.group || nodeGroup()
9119
+ : nodeGroup(),
9120
+ };
9121
+ }
9122
+ const memoizedContext = React.useMemo(() => ({ ...context.current, forceRender }), [key]);
9123
+ return (React__namespace.createElement(LayoutGroupContext.Provider, { value: memoizedContext }, children));
9124
+ };
9125
+
9175
9126
  const ReorderContext = React.createContext(null);
9176
9127
 
9177
9128
  function checkReorder(order, value, offset, velocity) {
@@ -9372,17 +9323,6 @@ const Reorder = {
9372
9323
  Item,
9373
9324
  };
9374
9325
 
9375
- exports.AnimationType = void 0;
9376
- (function (AnimationType) {
9377
- AnimationType["Animate"] = "animate";
9378
- AnimationType["Hover"] = "whileHover";
9379
- AnimationType["Tap"] = "whileTap";
9380
- AnimationType["Drag"] = "whileDrag";
9381
- AnimationType["Focus"] = "whileFocus";
9382
- AnimationType["InView"] = "whileInView";
9383
- AnimationType["Exit"] = "exit";
9384
- })(exports.AnimationType || (exports.AnimationType = {}));
9385
-
9386
9326
  /**
9387
9327
  * @public
9388
9328
  */
@@ -10271,15 +10211,6 @@ const thresholds = {
10271
10211
  all: 1,
10272
10212
  };
10273
10213
  function inView(elementOrSelector, onStart, { root, margin: rootMargin, amount = "any" } = {}) {
10274
- /**
10275
- * If this browser doesn't support IntersectionObserver, return a dummy stop function.
10276
- * Default triggering of onStart is tricky - it could be used for starting/stopping
10277
- * videos, lazy loading content etc. We could provide an option to enable a fallback, or
10278
- * provide a fallback callback option.
10279
- */
10280
- if (typeof IntersectionObserver === "undefined") {
10281
- return () => { };
10282
- }
10283
10214
  const elements = resolveElements(elementOrSelector);
10284
10215
  const activeIntersections = new WeakMap();
10285
10216
  const onIntersectionChange = (entries) => {
@@ -10726,9 +10657,16 @@ function useInvertedScale(scale) {
10726
10657
  return { scaleX, scaleY };
10727
10658
  }
10728
10659
 
10660
+ let id = 0;
10661
+ const AnimateSharedLayout = ({ children }) => {
10662
+ React__namespace.useEffect(() => {
10663
+ exports.invariant(false, "AnimateSharedLayout is deprecated: https://www.framer.com/docs/guide-upgrade/##shared-layout-animations");
10664
+ }, []);
10665
+ return (React__namespace.createElement(LayoutGroup, { id: useConstant(() => `asl-${id++}`) }, children));
10666
+ };
10667
+
10729
10668
  exports.AnimatePresence = AnimatePresence;
10730
10669
  exports.AnimateSharedLayout = AnimateSharedLayout;
10731
- exports.DeprecatedLayoutGroupContext = DeprecatedLayoutGroupContext;
10732
10670
  exports.DragControls = DragControls;
10733
10671
  exports.FlatTree = FlatTree;
10734
10672
  exports.LayoutGroup = LayoutGroup;
@@ -13,6 +13,7 @@ const acceleratedValues = new Set([
13
13
  "clipPath",
14
14
  "filter",
15
15
  "transform",
16
+ "backgroundColor",
16
17
  ]);
17
18
  /**
18
19
  * 10ms is chosen here as it strikes a balance between smooth
@@ -32,7 +33,9 @@ function createAcceleratedAnimation(value, valueName, { onUpdate, onComplete, ..
32
33
  /**
33
34
  * If this animation needs pre-generated keyframes then generate.
34
35
  */
35
- if (options.type === "spring" || !isWaapiSupportedEasing(options.ease)) {
36
+ if (options.type === "spring" ||
37
+ valueName === "backgroundColor" ||
38
+ !isWaapiSupportedEasing(options.ease)) {
36
39
  /**
37
40
  * If we need to pre-generate keyframes and repeat is infinite then
38
41
  * early return as this will lock the thread.
@@ -6,7 +6,7 @@ import { PresenceChild } from './PresenceChild.mjs';
6
6
  import { LayoutGroupContext } from '../../context/LayoutGroupContext.mjs';
7
7
  import { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.mjs';
8
8
  import { useUnmountEffect } from '../../utils/use-unmount-effect.mjs';
9
- import { warnOnce } from '../../utils/warn-once.mjs';
9
+ import { invariant } from '../../utils/errors.mjs';
10
10
 
11
11
  const getChildKey = (child) => child.key || "";
12
12
  function updateChildLookup(children, allChildren) {
@@ -58,13 +58,7 @@ function onlyElements(children) {
58
58
  * @public
59
59
  */
60
60
  const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exitBeforeEnter, presenceAffectsLayout = true, mode = "sync", }) => {
61
- // Support deprecated exitBeforeEnter prop
62
- if (exitBeforeEnter) {
63
- mode = "wait";
64
- if (process.env.NODE_ENV !== "production") {
65
- warnOnce(false, "Replace exitBeforeEnter with mode='wait'");
66
- }
67
- }
61
+ invariant(!exitBeforeEnter, "Replace exitBeforeEnter with mode='wait'");
68
62
  // We want to force a re-render once all exiting animations have finished. We
69
63
  // either use a local forceRender function, or one from a parent context if it exists.
70
64
  let [forceRender] = useForceUpdate();
@@ -1,4 +1,4 @@
1
- import { warning } from '../utils/errors.mjs';
1
+ import { invariant } from '../utils/errors.mjs';
2
2
  import * as React from 'react';
3
3
  import { useConstant } from '../utils/use-constant.mjs';
4
4
  import { LayoutGroup } from './LayoutGroup/index.mjs';
@@ -6,7 +6,7 @@ import { LayoutGroup } from './LayoutGroup/index.mjs';
6
6
  let id = 0;
7
7
  const AnimateSharedLayout = ({ children }) => {
8
8
  React.useEffect(() => {
9
- warning(false, "AnimateSharedLayout is deprecated: https://www.framer.com/docs/guide-upgrade/##shared-layout-animations");
9
+ invariant(false, "AnimateSharedLayout is deprecated: https://www.framer.com/docs/guide-upgrade/##shared-layout-animations");
10
10
  }, []);
11
11
  return (React.createElement(LayoutGroup, { id: useConstant(() => `asl-${id++}`) }, children));
12
12
  };
@@ -1,21 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import { useContext, useRef, useMemo } from 'react';
3
3
  import { LayoutGroupContext } from '../../context/LayoutGroupContext.mjs';
4
- import { DeprecatedLayoutGroupContext } from '../../context/DeprecatedLayoutGroupContext.mjs';
5
4
  import { useForceUpdate } from '../../utils/use-force-update.mjs';
6
5
  import { nodeGroup } from '../../projection/node/group.mjs';
7
6
 
8
7
  const shouldInheritGroup = (inherit) => inherit === true;
9
8
  const shouldInheritId = (inherit) => shouldInheritGroup(inherit === true) || inherit === "id";
10
- const LayoutGroup = ({ children, id, inheritId, inherit = true }) => {
11
- // Maintain backwards-compatibility with inheritId until 7.0
12
- if (inheritId !== undefined)
13
- inherit = inheritId;
9
+ const LayoutGroup = ({ children, id, inherit = true }) => {
14
10
  const layoutGroupContext = useContext(LayoutGroupContext);
15
- const deprecatedLayoutGroupContext = useContext(DeprecatedLayoutGroupContext);
16
11
  const [forceRender, key] = useForceUpdate();
17
12
  const context = useRef(null);
18
- const upstreamId = layoutGroupContext.id || deprecatedLayoutGroupContext;
13
+ const upstreamId = layoutGroupContext.id;
19
14
  if (context.current === null) {
20
15
  if (shouldInheritId(inherit) && upstreamId) {
21
16
  id = id ? upstreamId + "-" + id : upstreamId;
@@ -96,7 +96,7 @@ class VisualElementDragControls {
96
96
  // Fire onDragStart event
97
97
  onDragStart && onDragStart(event, info);
98
98
  const { animationState } = this.visualElement;
99
- animationState && animationState.setActive("whileDrag" /* AnimationType.Drag */, true);
99
+ animationState && animationState.setActive("whileDrag", true);
100
100
  };
101
101
  const onMove = (event, info) => {
102
102
  // latestPointerEvent = event
@@ -161,7 +161,7 @@ class VisualElementDragControls {
161
161
  this.openGlobalLock();
162
162
  this.openGlobalLock = null;
163
163
  }
164
- animationState && animationState.setActive("whileDrag" /* AnimationType.Drag */, false);
164
+ animationState && animationState.setActive("whileDrag", false);
165
165
  }
166
166
  updateAxis(axis, _point, offset) {
167
167
  const { drag } = this.getProps();
@@ -23,13 +23,13 @@ class FocusGesture extends Feature {
23
23
  }
24
24
  if (!isFocusVisible || !this.node.animationState)
25
25
  return;
26
- this.node.animationState.setActive("whileFocus" /* AnimationType.Focus */, true);
26
+ this.node.animationState.setActive("whileFocus", true);
27
27
  this.isActive = true;
28
28
  }
29
29
  onBlur() {
30
30
  if (!this.isActive || !this.node.animationState)
31
31
  return;
32
- this.node.animationState.setActive("whileFocus" /* AnimationType.Focus */, false);
32
+ this.node.animationState.setActive("whileFocus", false);
33
33
  this.isActive = false;
34
34
  }
35
35
  mount() {
@@ -11,7 +11,7 @@ function addHoverEvent(node, isActive) {
11
11
  return;
12
12
  const props = node.getProps();
13
13
  if (node.animationState && props.whileHover) {
14
- node.animationState.setActive("whileHover" /* AnimationType.Hover */, isActive);
14
+ node.animationState.setActive("whileHover", isActive);
15
15
  }
16
16
  if (props[callbackName]) {
17
17
  props[callbackName](event, info);
@@ -73,7 +73,7 @@ class PressGesture extends Feature {
73
73
  * Ensure we trigger animations before firing event callback
74
74
  */
75
75
  if (whileTap && this.node.animationState) {
76
- this.node.animationState.setActive("whileTap" /* AnimationType.Tap */, true);
76
+ this.node.animationState.setActive("whileTap", true);
77
77
  }
78
78
  onTapStart && onTapStart(event, info);
79
79
  }
@@ -82,7 +82,7 @@ class PressGesture extends Feature {
82
82
  this.isPressing = false;
83
83
  const props = this.node.getProps();
84
84
  if (props.whileTap && this.node.animationState) {
85
- this.node.animationState.setActive("whileTap" /* AnimationType.Tap */, false);
85
+ this.node.animationState.setActive("whileTap", false);
86
86
  }
87
87
  return !isDragActive();
88
88
  }
package/dist/es/index.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  export { createDomMotionComponent, motion } from './render/dom/motion.mjs';
2
2
  export { m } from './render/dom/motion-minimal.mjs';
3
3
  export { AnimatePresence } from './components/AnimatePresence/index.mjs';
4
- export { AnimateSharedLayout } from './components/AnimateSharedLayout.mjs';
5
4
  export { MotionConfig } from './components/MotionConfig/index.mjs';
6
5
  export { LazyMotion } from './components/LazyMotion/index.mjs';
7
6
  export { LayoutGroup } from './components/LayoutGroup/index.mjs';
@@ -68,7 +67,6 @@ export { MotionContext, useVisualElementContext } from './context/MotionContext/
68
67
  export { MotionConfigContext } from './context/MotionConfigContext.mjs';
69
68
  export { PresenceContext } from './context/PresenceContext.mjs';
70
69
  export { LayoutGroupContext } from './context/LayoutGroupContext.mjs';
71
- export { DeprecatedLayoutGroupContext } from './context/DeprecatedLayoutGroupContext.mjs';
72
70
  export { SwitchLayoutGroupContext } from './context/SwitchLayoutGroupContext.mjs';
73
71
  export { anticipate } from './easing/anticipate.mjs';
74
72
  export { backIn, backInOut, backOut } from './easing/back.mjs';
@@ -78,7 +76,7 @@ export { cubicBezier } from './easing/cubic-bezier.mjs';
78
76
  export { FlatTree } from './render/utils/flat-tree.mjs';
79
77
  export { useAnimatedState as useDeprecatedAnimatedState } from './animation/hooks/use-animated-state.mjs';
80
78
  export { useInvertedScale as useDeprecatedInvertedScale } from './value/use-inverted-scale.mjs';
81
- export { AnimationType } from './render/utils/types.mjs';
79
+ export { AnimateSharedLayout } from './components/AnimateSharedLayout.mjs';
82
80
  export { animations } from './motion/features/animations.mjs';
83
81
  export { checkTargetForNewValues } from './render/utils/setters.mjs';
84
82
  export { createBox } from './projection/geometry/models.mjs';
@@ -14,7 +14,7 @@ class ExitAnimationFeature extends Feature {
14
14
  if (!this.node.animationState || isPresent === prevIsPresent) {
15
15
  return;
16
16
  }
17
- const exitAnimation = this.node.animationState.setActive("exit" /* AnimationType.Exit */, !isPresent, { custom: custom !== null && custom !== void 0 ? custom : this.node.getProps().custom });
17
+ const exitAnimation = this.node.animationState.setActive("exit", !isPresent, { custom: custom !== null && custom !== void 0 ? custom : this.node.getProps().custom });
18
18
  if (onExitComplete && !isPresent) {
19
19
  exitAnimation.then(() => onExitComplete(this.id));
20
20
  }
@@ -11,33 +11,10 @@ class InViewFeature extends Feature {
11
11
  this.hasEnteredView = false;
12
12
  this.isInView = false;
13
13
  }
14
- /**
15
- * TODO: Remove this in 10.0
16
- */
17
- viewportFallback() {
18
- /**
19
- * Fire this in an rAF because, at this point, the animation state
20
- * won't have flushed for the first time and there's certain logic in
21
- * there that behaves differently on the initial animation.
22
- */
23
- requestAnimationFrame(() => {
24
- this.hasEnteredView = true;
25
- const { onViewportEnter } = this.node.getProps();
26
- onViewportEnter && onViewportEnter(null);
27
- if (this.node.animationState) {
28
- this.node.animationState.setActive("whileInView" /* AnimationType.InView */, true);
29
- }
30
- });
31
- }
32
14
  startObserver() {
33
15
  this.unmount();
34
16
  const { viewport = {} } = this.node.getProps();
35
- const { root, margin: rootMargin, amount = "some", once, fallback = true, } = viewport;
36
- if (typeof IntersectionObserver === "undefined") {
37
- if (fallback)
38
- this.viewportFallback();
39
- return;
40
- }
17
+ const { root, margin: rootMargin, amount = "some", once } = viewport;
41
18
  const options = {
42
19
  root: root ? root.current : undefined,
43
20
  rootMargin,
@@ -62,7 +39,7 @@ class InViewFeature extends Feature {
62
39
  this.hasEnteredView = true;
63
40
  }
64
41
  if (this.node.animationState) {
65
- this.node.animationState.setActive("whileInView" /* AnimationType.InView */, isIntersecting);
42
+ this.node.animationState.setActive("whileInView", isIntersecting);
66
43
  }
67
44
  /**
68
45
  * Use the latest committed props rather than the ones in scope
@@ -5,15 +5,6 @@ const thresholds = {
5
5
  all: 1,
6
6
  };
7
7
  function inView(elementOrSelector, onStart, { root, margin: rootMargin, amount = "any" } = {}) {
8
- /**
9
- * If this browser doesn't support IntersectionObserver, return a dummy stop function.
10
- * Default triggering of onStart is tricky - it could be used for starting/stopping
11
- * videos, lazy loading content etc. We could provide an option to enable a fallback, or
12
- * provide a fallback callback option.
13
- */
14
- if (typeof IntersectionObserver === "undefined") {
15
- return () => { };
16
- }
17
8
  const elements = resolveElements(elementOrSelector);
18
9
  const activeIntersections = new WeakMap();
19
10
  const onIntersectionChange = (entries) => {