framer-motion 9.0.0 → 9.0.2

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.
package/README.md CHANGED
@@ -3,8 +3,20 @@
3
3
  </p>
4
4
  <h1 align="center">Framer Motion</h1>
5
5
  <h3 align="center">
6
- An open source motion library for React, <a href="https://www.framer.com">made by Framer</a>.
6
+ An open source motion library for React, made by Framer. Motion powers Framer, the web builder for creative pros. Design and ship your dream site. Zero code, maximum speed.
7
7
  </h3>
8
+ <br/>
9
+ <p align="center">
10
+ <a href="https://www.framer.com?utm_source=motion">
11
+ <img src="https://framerusercontent.com/images/atXqxn4JhKm4LXVncdNjkKV7yCU.png" width="140" alt="Start for free" />
12
+ </a>
13
+ </p>
14
+ <br/>
15
+ <p align="center">
16
+ <a href="https://www.framer.com?utm_source=motion">
17
+ <img src="https://framerusercontent.com/images/pMSOmGP2V8sSaZRV2D7i4HTBTe4.png" width="1000" alt="Framer Banner" />
18
+ </a>
19
+ </p>
8
20
 
9
21
  <br>
10
22
 
@@ -23,6 +35,8 @@
23
35
  </a>
24
36
  </p>
25
37
 
38
+ <br>
39
+ <hr>
26
40
  <br>
27
41
 
28
42
  Framer Motion is an open source, production-ready library that’s designed for all creative developers.
@@ -85,4 +99,4 @@ export const MyComponent = ({ isVisible }) => (
85
99
 
86
100
  ### ✨ Framer
87
101
 
88
- - Design and publish sites that inspire. [Try Framer for free](https://www.framer.com/).
102
+ - Design and publish sites that inspire. [Try Framer for free](https://www.framer.com/?utm_source=motion-readme).
package/dist/cjs/index.js CHANGED
@@ -344,12 +344,11 @@ function createMotionComponent({ preloadedFeatures, createVisualElement, project
344
344
  * Load Motion gesture and animation features. These are rendered as renderless
345
345
  * components so each feature can optionally make use of React lifecycle methods.
346
346
  */
347
- const lazyStrictMode = React.useContext(LazyContext).strict;
348
347
  const initialLayoutGroupConfig = React.useContext(SwitchLayoutGroupContext);
349
348
  if (context.visualElement) {
350
349
  features = context.visualElement.loadFeatures(
351
350
  // Note: Pass the full new combined props to correctly re-render dynamic feature components.
352
- configAndProps, lazyStrictMode, preloadedFeatures, projectionId, projectionNodeConstructor ||
351
+ configAndProps, React.useContext(LazyContext).strict, preloadedFeatures, projectionId, projectionNodeConstructor ||
353
352
  featureDefinitions.projectionNodeConstructor, initialLayoutGroupConfig);
354
353
  }
355
354
  }
@@ -855,6 +854,7 @@ const validMotionProps = new Set([
855
854
  "onHoverEnd",
856
855
  "onViewportEnter",
857
856
  "onViewportLeave",
857
+ "ignoreStrict",
858
858
  "viewport",
859
859
  ]);
860
860
  /**
@@ -1550,7 +1550,6 @@ function useTapGesture({ onTap, onTapStart, onTapCancel, whileTap, visualElement
1550
1550
  const hasPressListeners = onTap || onTapStart || onTapCancel || whileTap;
1551
1551
  const isPressing = React.useRef(false);
1552
1552
  const cancelPointerEndListeners = React.useRef(null);
1553
- const suspendedTabIndex = React.useRef(null);
1554
1553
  /**
1555
1554
  * Only set listener to passive if there are no external listeners.
1556
1555
  */
@@ -1571,9 +1570,6 @@ function useTapGesture({ onTap, onTapStart, onTapCancel, whileTap, visualElement
1571
1570
  if (latestProps.whileTap && visualElement.animationState) {
1572
1571
  visualElement.animationState.setActive(exports.AnimationType.Tap, false);
1573
1572
  }
1574
- if (suspendedTabIndex.current !== null) {
1575
- visualElement.current.setAttribute("tabindex", suspendedTabIndex.current);
1576
- }
1577
1573
  return !isDragActive();
1578
1574
  }
1579
1575
  function onPointerUp(event, info) {
@@ -1616,9 +1612,6 @@ function useTapGesture({ onTap, onTapStart, onTapCancel, whileTap, visualElement
1616
1612
  if (isPressing.current)
1617
1613
  return;
1618
1614
  isPressing.current = true;
1619
- suspendedTabIndex.current =
1620
- visualElement.current.getAttribute("tabindex");
1621
- visualElement.current.setAttribute("tabindex", "-1");
1622
1615
  cancelPointerEndListeners.current = pipe(addPointerEvent(window, "pointerup", onPointerUp, eventOptions), addPointerEvent(window, "pointercancel", onPointerCancel, eventOptions));
1623
1616
  onPointerStart(event, info);
1624
1617
  }, callbackDependencies);
@@ -2140,7 +2133,7 @@ class MotionValue {
2140
2133
  * This will be replaced by the build step with the latest version number.
2141
2134
  * When MotionValues are provided to motion components, warn if versions are mixed.
2142
2135
  */
2143
- this.version = "9.0.0";
2136
+ this.version = "9.0.2";
2144
2137
  /**
2145
2138
  * Duration, in milliseconds, since last updating frame.
2146
2139
  *
@@ -5989,7 +5982,7 @@ function updateMotionValuesFromProps(element, next, prev) {
5989
5982
  * and warn against mismatches.
5990
5983
  */
5991
5984
  if (process.env.NODE_ENV === "development") {
5992
- warnOnce(nextValue.version === "9.0.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 9.0.0 may not work as expected.`);
5985
+ warnOnce(nextValue.version === "9.0.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 9.0.2 may not work as expected.`);
5993
5986
  }
5994
5987
  }
5995
5988
  else if (isMotionValue(prevValue)) {
@@ -6227,7 +6220,10 @@ class VisualElement {
6227
6220
  if (process.env.NODE_ENV !== "production" &&
6228
6221
  preloadedFeatures &&
6229
6222
  isStrict) {
6230
- heyListen.invariant(false, "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.");
6223
+ const strictMessage = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";
6224
+ renderedProps.ignoreStrict
6225
+ ? heyListen.warning(false, strictMessage)
6226
+ : heyListen.invariant(false, strictMessage);
6231
6227
  }
6232
6228
  for (let i = 0; i < numFeatures; i++) {
6233
6229
  const name = featureNames[i];
@@ -9091,7 +9087,7 @@ function ReorderGroup({ children, as = "ul", axis = "y", onReorder, values, ...p
9091
9087
  React.useEffect(() => {
9092
9088
  isReordering.current = false;
9093
9089
  });
9094
- return (React__namespace.createElement(Component, { ...props, ref: externalRef },
9090
+ return (React__namespace.createElement(Component, { ...props, ref: externalRef, ignoreStrict: true },
9095
9091
  React__namespace.createElement(ReorderContext.Provider, { value: context }, children)));
9096
9092
  }
9097
9093
  const Group = React.forwardRef(ReorderGroup);
@@ -9228,7 +9224,7 @@ function ReorderItem({ children, style = {}, value, as = "li", onDrag, layout =
9228
9224
  onDrag && onDrag(event, gesturePoint);
9229
9225
  }, onLayoutMeasure: (measured) => {
9230
9226
  measuredLayout.current = measured;
9231
- }, ref: externalRef }, children));
9227
+ }, ref: externalRef, ignoreStrict: true }, children));
9232
9228
  }
9233
9229
  const Item = React.forwardRef(ReorderItem);
9234
9230
 
@@ -38,7 +38,7 @@ function ReorderGroup({ children, as = "ul", axis = "y", onReorder, values, ...p
38
38
  useEffect(() => {
39
39
  isReordering.current = false;
40
40
  });
41
- return (React.createElement(Component, { ...props, ref: externalRef },
41
+ return (React.createElement(Component, { ...props, ref: externalRef, ignoreStrict: true },
42
42
  React.createElement(ReorderContext.Provider, { value: context }, children)));
43
43
  }
44
44
  const Group = forwardRef(ReorderGroup);
@@ -32,7 +32,7 @@ function ReorderItem({ children, style = {}, value, as = "li", onDrag, layout =
32
32
  onDrag && onDrag(event, gesturePoint);
33
33
  }, onLayoutMeasure: (measured) => {
34
34
  measuredLayout.current = measured;
35
- }, ref: externalRef }, children));
35
+ }, ref: externalRef, ignoreStrict: true }, children));
36
36
  }
37
37
  const Item = forwardRef(ReorderItem);
38
38
 
@@ -22,7 +22,6 @@ function useTapGesture({ onTap, onTapStart, onTapCancel, whileTap, visualElement
22
22
  const hasPressListeners = onTap || onTapStart || onTapCancel || whileTap;
23
23
  const isPressing = useRef(false);
24
24
  const cancelPointerEndListeners = useRef(null);
25
- const suspendedTabIndex = useRef(null);
26
25
  /**
27
26
  * Only set listener to passive if there are no external listeners.
28
27
  */
@@ -43,9 +42,6 @@ function useTapGesture({ onTap, onTapStart, onTapCancel, whileTap, visualElement
43
42
  if (latestProps.whileTap && visualElement.animationState) {
44
43
  visualElement.animationState.setActive(AnimationType.Tap, false);
45
44
  }
46
- if (suspendedTabIndex.current !== null) {
47
- visualElement.current.setAttribute("tabindex", suspendedTabIndex.current);
48
- }
49
45
  return !isDragActive();
50
46
  }
51
47
  function onPointerUp(event, info) {
@@ -88,9 +84,6 @@ function useTapGesture({ onTap, onTapStart, onTapCancel, whileTap, visualElement
88
84
  if (isPressing.current)
89
85
  return;
90
86
  isPressing.current = true;
91
- suspendedTabIndex.current =
92
- visualElement.current.getAttribute("tabindex");
93
- visualElement.current.setAttribute("tabindex", "-1");
94
87
  cancelPointerEndListeners.current = pipe(addPointerEvent(window, "pointerup", onPointerUp, eventOptions), addPointerEvent(window, "pointercancel", onPointerCancel, eventOptions));
95
88
  onPointerStart(event, info);
96
89
  }, callbackDependencies);
@@ -63,12 +63,11 @@ function createMotionComponent({ preloadedFeatures, createVisualElement, project
63
63
  * Load Motion gesture and animation features. These are rendered as renderless
64
64
  * components so each feature can optionally make use of React lifecycle methods.
65
65
  */
66
- const lazyStrictMode = useContext(LazyContext).strict;
67
66
  const initialLayoutGroupConfig = useContext(SwitchLayoutGroupContext);
68
67
  if (context.visualElement) {
69
68
  features = context.visualElement.loadFeatures(
70
69
  // Note: Pass the full new combined props to correctly re-render dynamic feature components.
71
- configAndProps, lazyStrictMode, preloadedFeatures, projectionId, projectionNodeConstructor ||
70
+ configAndProps, useContext(LazyContext).strict, preloadedFeatures, projectionId, projectionNodeConstructor ||
72
71
  featureDefinitions.projectionNodeConstructor, initialLayoutGroupConfig);
73
72
  }
74
73
  }
@@ -36,6 +36,7 @@ const validMotionProps = new Set([
36
36
  "onHoverEnd",
37
37
  "onViewportEnter",
38
38
  "onViewportLeave",
39
+ "ignoreStrict",
39
40
  "viewport",
40
41
  ]);
41
42
  /**
@@ -1,5 +1,5 @@
1
1
  import { sync, cancelSync } from '../frameloop/index.mjs';
2
- import { invariant } from 'hey-listen';
2
+ import { warning, invariant } from 'hey-listen';
3
3
  import { createElement } from 'react';
4
4
  import { featureDefinitions } from '../motion/features/definitions.mjs';
5
5
  import { createBox } from '../projection/geometry/models.mjs';
@@ -218,7 +218,10 @@ class VisualElement {
218
218
  if (process.env.NODE_ENV !== "production" &&
219
219
  preloadedFeatures &&
220
220
  isStrict) {
221
- invariant(false, "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.");
221
+ const strictMessage = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";
222
+ renderedProps.ignoreStrict
223
+ ? warning(false, strictMessage)
224
+ : invariant(false, strictMessage);
222
225
  }
223
226
  for (let i = 0; i < numFeatures; i++) {
224
227
  const name = featureNames[i];
@@ -22,7 +22,7 @@ function updateMotionValuesFromProps(element, next, prev) {
22
22
  * and warn against mismatches.
23
23
  */
24
24
  if (process.env.NODE_ENV === "development") {
25
- warnOnce(nextValue.version === "9.0.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 9.0.0 may not work as expected.`);
25
+ warnOnce(nextValue.version === "9.0.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 9.0.2 may not work as expected.`);
26
26
  }
27
27
  }
28
28
  else if (isMotionValue(prevValue)) {
@@ -25,7 +25,7 @@ class MotionValue {
25
25
  * This will be replaced by the build step with the latest version number.
26
26
  * When MotionValues are provided to motion components, warn if versions are mixed.
27
27
  */
28
- this.version = "9.0.0";
28
+ this.version = "9.0.2";
29
29
  /**
30
30
  * Duration, in milliseconds, since last updating frame.
31
31
  *
@@ -342,12 +342,11 @@
342
342
  * Load Motion gesture and animation features. These are rendered as renderless
343
343
  * components so each feature can optionally make use of React lifecycle methods.
344
344
  */
345
- const lazyStrictMode = React.useContext(LazyContext).strict;
346
345
  const initialLayoutGroupConfig = React.useContext(SwitchLayoutGroupContext);
347
346
  if (context.visualElement) {
348
347
  features = context.visualElement.loadFeatures(
349
348
  // Note: Pass the full new combined props to correctly re-render dynamic feature components.
350
- configAndProps, lazyStrictMode, preloadedFeatures, projectionId, projectionNodeConstructor ||
349
+ configAndProps, React.useContext(LazyContext).strict, preloadedFeatures, projectionId, projectionNodeConstructor ||
351
350
  featureDefinitions.projectionNodeConstructor, initialLayoutGroupConfig);
352
351
  }
353
352
  }
@@ -853,6 +852,7 @@
853
852
  "onHoverEnd",
854
853
  "onViewportEnter",
855
854
  "onViewportLeave",
855
+ "ignoreStrict",
856
856
  "viewport",
857
857
  ]);
858
858
  /**
@@ -1548,7 +1548,6 @@
1548
1548
  const hasPressListeners = onTap || onTapStart || onTapCancel || whileTap;
1549
1549
  const isPressing = React.useRef(false);
1550
1550
  const cancelPointerEndListeners = React.useRef(null);
1551
- const suspendedTabIndex = React.useRef(null);
1552
1551
  /**
1553
1552
  * Only set listener to passive if there are no external listeners.
1554
1553
  */
@@ -1569,9 +1568,6 @@
1569
1568
  if (latestProps.whileTap && visualElement.animationState) {
1570
1569
  visualElement.animationState.setActive(exports.AnimationType.Tap, false);
1571
1570
  }
1572
- if (suspendedTabIndex.current !== null) {
1573
- visualElement.current.setAttribute("tabindex", suspendedTabIndex.current);
1574
- }
1575
1571
  return !isDragActive();
1576
1572
  }
1577
1573
  function onPointerUp(event, info) {
@@ -1614,9 +1610,6 @@
1614
1610
  if (isPressing.current)
1615
1611
  return;
1616
1612
  isPressing.current = true;
1617
- suspendedTabIndex.current =
1618
- visualElement.current.getAttribute("tabindex");
1619
- visualElement.current.setAttribute("tabindex", "-1");
1620
1613
  cancelPointerEndListeners.current = pipe(addPointerEvent(window, "pointerup", onPointerUp, eventOptions), addPointerEvent(window, "pointercancel", onPointerCancel, eventOptions));
1621
1614
  onPointerStart(event, info);
1622
1615
  }, callbackDependencies);
@@ -2138,7 +2131,7 @@
2138
2131
  * This will be replaced by the build step with the latest version number.
2139
2132
  * When MotionValues are provided to motion components, warn if versions are mixed.
2140
2133
  */
2141
- this.version = "9.0.0";
2134
+ this.version = "9.0.2";
2142
2135
  /**
2143
2136
  * Duration, in milliseconds, since last updating frame.
2144
2137
  *
@@ -6002,7 +5995,7 @@
6002
5995
  * and warn against mismatches.
6003
5996
  */
6004
5997
  {
6005
- warnOnce(nextValue.version === "9.0.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 9.0.0 may not work as expected.`);
5998
+ warnOnce(nextValue.version === "9.0.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 9.0.2 may not work as expected.`);
6006
5999
  }
6007
6000
  }
6008
6001
  else if (isMotionValue(prevValue)) {
@@ -6239,7 +6232,10 @@
6239
6232
  */
6240
6233
  if (preloadedFeatures &&
6241
6234
  isStrict) {
6242
- invariant(false, "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.");
6235
+ const strictMessage = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";
6236
+ renderedProps.ignoreStrict
6237
+ ? warning(false, strictMessage)
6238
+ : invariant(false, strictMessage);
6243
6239
  }
6244
6240
  for (let i = 0; i < numFeatures; i++) {
6245
6241
  const name = featureNames[i];
@@ -9102,7 +9098,7 @@
9102
9098
  React.useEffect(() => {
9103
9099
  isReordering.current = false;
9104
9100
  });
9105
- return (React__namespace.createElement(Component, { ...props, ref: externalRef },
9101
+ return (React__namespace.createElement(Component, { ...props, ref: externalRef, ignoreStrict: true },
9106
9102
  React__namespace.createElement(ReorderContext.Provider, { value: context }, children)));
9107
9103
  }
9108
9104
  const Group = React.forwardRef(ReorderGroup);
@@ -9239,7 +9235,7 @@
9239
9235
  onDrag && onDrag(event, gesturePoint);
9240
9236
  }, onLayoutMeasure: (measured) => {
9241
9237
  measuredLayout.current = measured;
9242
- }, ref: externalRef }, children));
9238
+ }, ref: externalRef, ignoreStrict: true }, children));
9243
9239
  }
9244
9240
  const Item = React.forwardRef(ReorderItem);
9245
9241