framer-motion 8.1.4 → 8.1.6

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/dist/cjs/index.js CHANGED
@@ -1560,14 +1560,6 @@ function useTapGesture({ onTap, onTapStart, onTapCancel, whileTap, visualElement
1560
1560
  useUnmountEffect(removePointerEndListener);
1561
1561
  }
1562
1562
 
1563
- /**
1564
- * Browser-safe usage of process
1565
- */
1566
- const defaultEnvironment = "production";
1567
- const env = typeof process === "undefined" || process.env === undefined
1568
- ? defaultEnvironment
1569
- : process.env.NODE_ENV || defaultEnvironment;
1570
-
1571
1563
  const warned = new Set();
1572
1564
  function warnOnce(condition, message, element) {
1573
1565
  if (condition || warned.has(message))
@@ -1695,7 +1687,7 @@ function useMissingIntersectionObserver(shouldObserve, state, visualElement, { f
1695
1687
  React.useEffect(() => {
1696
1688
  if (!shouldObserve || !fallback)
1697
1689
  return;
1698
- if (env !== "production") {
1690
+ if (process.env.NODE_ENV !== "production") {
1699
1691
  warnOnce(false, "IntersectionObserver not available on this device. whileInView animations will trigger on mount.");
1700
1692
  }
1701
1693
  /**
@@ -2061,7 +2053,7 @@ class MotionValue {
2061
2053
  * This will be replaced by the build step with the latest version number.
2062
2054
  * When MotionValues are provided to motion components, warn if versions are mixed.
2063
2055
  */
2064
- this.version = "8.1.4";
2056
+ this.version = "8.1.6";
2065
2057
  /**
2066
2058
  * Duration, in milliseconds, since last updating frame.
2067
2059
  *
@@ -5883,7 +5875,7 @@ function updateMotionValuesFromProps(element, next, prev) {
5883
5875
  * and warn against mismatches.
5884
5876
  */
5885
5877
  if (process.env.NODE_ENV === "development") {
5886
- warnOnce(nextValue.version === "8.1.4", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.1.4 may not work as expected.`);
5878
+ warnOnce(nextValue.version === "8.1.6", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.1.6 may not work as expected.`);
5887
5879
  }
5888
5880
  }
5889
5881
  else if (isMotionValue(prevValue)) {
@@ -6066,6 +6058,9 @@ class VisualElement {
6066
6058
  : this.reducedMotionConfig === "always"
6067
6059
  ? true
6068
6060
  : prefersReducedMotion.current;
6061
+ if (process.env.NODE_ENV !== "production") {
6062
+ warnOnce(this.shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.");
6063
+ }
6069
6064
  if (this.parent)
6070
6065
  this.parent.children.add(this);
6071
6066
  this.setProps(this.props);
@@ -6115,7 +6110,9 @@ class VisualElement {
6115
6110
  * If we're in development mode, check to make sure we're not rendering a motion component
6116
6111
  * as a child of LazyMotion, as this will break the file-size benefits of using it.
6117
6112
  */
6118
- if (env !== "production" && preloadedFeatures && isStrict) {
6113
+ if (process.env.NODE_ENV !== "production" &&
6114
+ preloadedFeatures &&
6115
+ isStrict) {
6119
6116
  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.");
6120
6117
  }
6121
6118
  for (let i = 0; i < numFeatures; i++) {
@@ -8627,7 +8624,9 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exi
8627
8624
  // Support deprecated exitBeforeEnter prop
8628
8625
  if (exitBeforeEnter) {
8629
8626
  mode = "wait";
8630
- warnOnce(false, "Replace exitBeforeEnter with mode='wait'");
8627
+ if (process.env.NODE_ENV !== "production") {
8628
+ warnOnce(false, "Replace exitBeforeEnter with mode='wait'");
8629
+ }
8631
8630
  }
8632
8631
  // We want to force a re-render once all exiting animations have finished. We
8633
8632
  // either use a local forceRender function, or one from a parent context if it exists.
@@ -8713,7 +8712,7 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exi
8713
8712
  const key = child.key;
8714
8713
  return exiting.has(key) ? (child) : (React__namespace.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, presenceAffectsLayout: presenceAffectsLayout, mode: mode }, child));
8715
8714
  });
8716
- if (env !== "production" &&
8715
+ if (process.env.NODE_ENV !== "production" &&
8717
8716
  mode === "wait" &&
8718
8717
  childrenToRender.length > 1) {
8719
8718
  console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
@@ -9250,7 +9249,9 @@ function useScroll({ container, target, layoutEffect = true, ...options } = {})
9250
9249
  * @deprecated useElementScroll is deprecated. Convert to useScroll({ container: ref })
9251
9250
  */
9252
9251
  function useElementScroll(ref) {
9253
- warnOnce(false, "useElementScroll is deprecated. Convert to useScroll({ container: ref }).");
9252
+ if (process.env.NODE_ENV === "development") {
9253
+ warnOnce(false, "useElementScroll is deprecated. Convert to useScroll({ container: ref }).");
9254
+ }
9254
9255
  return useScroll({ container: ref });
9255
9256
  }
9256
9257
 
@@ -9258,7 +9259,9 @@ function useElementScroll(ref) {
9258
9259
  * @deprecated useViewportScroll is deprecated. Convert to useScroll()
9259
9260
  */
9260
9261
  function useViewportScroll() {
9261
- warnOnce(false, "useViewportScroll is deprecated. Convert to useScroll().");
9262
+ if (process.env.NODE_ENV !== "production") {
9263
+ warnOnce(false, "useViewportScroll is deprecated. Convert to useScroll().");
9264
+ }
9262
9265
  return useScroll();
9263
9266
  }
9264
9267
 
@@ -9368,6 +9371,9 @@ function useReducedMotion() {
9368
9371
  */
9369
9372
  !hasReducedMotionListener.current && initPrefersReducedMotion();
9370
9373
  const [shouldReduceMotion] = React.useState(prefersReducedMotion.current);
9374
+ if (process.env.NODE_ENV !== "production") {
9375
+ warnOnce(shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.");
9376
+ }
9371
9377
  /**
9372
9378
  * TODO See if people miss automatically updating shouldReduceMotion setting
9373
9379
  */
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { useContext, useRef, cloneElement, Children, isValidElement } from 'react';
3
- import { env } from '../../utils/process.mjs';
4
3
  import { useForceUpdate } from '../../utils/use-force-update.mjs';
5
4
  import { useIsMounted } from '../../utils/use-is-mounted.mjs';
6
5
  import { PresenceChild } from './PresenceChild.mjs';
@@ -62,7 +61,9 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exi
62
61
  // Support deprecated exitBeforeEnter prop
63
62
  if (exitBeforeEnter) {
64
63
  mode = "wait";
65
- warnOnce(false, "Replace exitBeforeEnter with mode='wait'");
64
+ if (process.env.NODE_ENV !== "production") {
65
+ warnOnce(false, "Replace exitBeforeEnter with mode='wait'");
66
+ }
66
67
  }
67
68
  // We want to force a re-render once all exiting animations have finished. We
68
69
  // either use a local forceRender function, or one from a parent context if it exists.
@@ -148,7 +149,7 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exi
148
149
  const key = child.key;
149
150
  return exiting.has(key) ? (child) : (React.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, presenceAffectsLayout: presenceAffectsLayout, mode: mode }, child));
150
151
  });
151
- if (env !== "production" &&
152
+ if (process.env.NODE_ENV !== "production" &&
152
153
  mode === "wait" &&
153
154
  childrenToRender.length > 1) {
154
155
  console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
@@ -1,4 +1,3 @@
1
- import { env } from '../../../utils/process.mjs';
2
1
  import { useRef, useEffect } from 'react';
3
2
  import { AnimationType } from '../../../render/utils/types.mjs';
4
3
  import { warnOnce } from '../../../utils/warn-once.mjs';
@@ -73,7 +72,7 @@ function useMissingIntersectionObserver(shouldObserve, state, visualElement, { f
73
72
  useEffect(() => {
74
73
  if (!shouldObserve || !fallback)
75
74
  return;
76
- if (env !== "production") {
75
+ if (process.env.NODE_ENV !== "production") {
77
76
  warnOnce(false, "IntersectionObserver not available on this device. whileInView animations will trigger on mount.");
78
77
  }
79
78
  /**
@@ -4,7 +4,6 @@ import { createElement } from 'react';
4
4
  import { featureDefinitions } from '../motion/features/definitions.mjs';
5
5
  import { createBox } from '../projection/geometry/models.mjs';
6
6
  import { isRefObject } from '../utils/is-ref-object.mjs';
7
- import { env } from '../utils/process.mjs';
8
7
  import { initPrefersReducedMotion } from '../utils/reduced-motion/index.mjs';
9
8
  import { hasReducedMotionListener, prefersReducedMotion } from '../utils/reduced-motion/state.mjs';
10
9
  import { SubscriptionManager } from '../utils/subscription-manager.mjs';
@@ -17,6 +16,7 @@ import { isControllingVariants, isVariantNode } from './utils/is-controlling-var
17
16
  import { isVariantLabel } from './utils/is-variant-label.mjs';
18
17
  import { updateMotionValuesFromProps } from './utils/motion-values.mjs';
19
18
  import { resolveVariantFromProps } from './utils/resolve-variants.mjs';
19
+ import { warnOnce } from '../utils/warn-once.mjs';
20
20
 
21
21
  const featureNames = Object.keys(featureDefinitions);
22
22
  const numFeatures = featureNames.length;
@@ -163,6 +163,9 @@ class VisualElement {
163
163
  : this.reducedMotionConfig === "always"
164
164
  ? true
165
165
  : prefersReducedMotion.current;
166
+ if (process.env.NODE_ENV !== "production") {
167
+ warnOnce(this.shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.");
168
+ }
166
169
  if (this.parent)
167
170
  this.parent.children.add(this);
168
171
  this.setProps(this.props);
@@ -212,7 +215,9 @@ class VisualElement {
212
215
  * If we're in development mode, check to make sure we're not rendering a motion component
213
216
  * as a child of LazyMotion, as this will break the file-size benefits of using it.
214
217
  */
215
- if (env !== "production" && preloadedFeatures && isStrict) {
218
+ if (process.env.NODE_ENV !== "production" &&
219
+ preloadedFeatures &&
220
+ isStrict) {
216
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.");
217
222
  }
218
223
  for (let i = 0; i < numFeatures; 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 === "8.1.4", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.1.4 may not work as expected.`);
25
+ warnOnce(nextValue.version === "8.1.6", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.1.6 may not work as expected.`);
26
26
  }
27
27
  }
28
28
  else if (isMotionValue(prevValue)) {
@@ -1,5 +1,6 @@
1
1
  import { useState } from 'react';
2
2
  import { initPrefersReducedMotion } from './index.mjs';
3
+ import { warnOnce } from '../warn-once.mjs';
3
4
  import { hasReducedMotionListener, prefersReducedMotion } from './state.mjs';
4
5
 
5
6
  /**
@@ -34,6 +35,9 @@ function useReducedMotion() {
34
35
  */
35
36
  !hasReducedMotionListener.current && initPrefersReducedMotion();
36
37
  const [shouldReduceMotion] = useState(prefersReducedMotion.current);
38
+ if (process.env.NODE_ENV !== "production") {
39
+ warnOnce(shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.");
40
+ }
37
41
  /**
38
42
  * TODO See if people miss automatically updating shouldReduceMotion setting
39
43
  */
@@ -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 = "8.1.4";
28
+ this.version = "8.1.6";
29
29
  /**
30
30
  * Duration, in milliseconds, since last updating frame.
31
31
  *
@@ -5,7 +5,9 @@ import { useScroll } from '../use-scroll.mjs';
5
5
  * @deprecated useElementScroll is deprecated. Convert to useScroll({ container: ref })
6
6
  */
7
7
  function useElementScroll(ref) {
8
- warnOnce(false, "useElementScroll is deprecated. Convert to useScroll({ container: ref }).");
8
+ if (process.env.NODE_ENV === "development") {
9
+ warnOnce(false, "useElementScroll is deprecated. Convert to useScroll({ container: ref }).");
10
+ }
9
11
  return useScroll({ container: ref });
10
12
  }
11
13
 
@@ -5,7 +5,9 @@ import { useScroll } from '../use-scroll.mjs';
5
5
  * @deprecated useViewportScroll is deprecated. Convert to useScroll()
6
6
  */
7
7
  function useViewportScroll() {
8
- warnOnce(false, "useViewportScroll is deprecated. Convert to useScroll().");
8
+ if (process.env.NODE_ENV !== "production") {
9
+ warnOnce(false, "useViewportScroll is deprecated. Convert to useScroll().");
10
+ }
9
11
  return useScroll();
10
12
  }
11
13
 
@@ -1558,14 +1558,6 @@
1558
1558
  useUnmountEffect(removePointerEndListener);
1559
1559
  }
1560
1560
 
1561
- /**
1562
- * Browser-safe usage of process
1563
- */
1564
- const defaultEnvironment = "production";
1565
- const env = typeof process === "undefined" || process.env === undefined
1566
- ? defaultEnvironment
1567
- : "development" ;
1568
-
1569
1561
  const warned = new Set();
1570
1562
  function warnOnce(condition, message, element) {
1571
1563
  if (condition || warned.has(message))
@@ -1693,7 +1685,7 @@
1693
1685
  React.useEffect(() => {
1694
1686
  if (!shouldObserve || !fallback)
1695
1687
  return;
1696
- if (env !== "production") {
1688
+ {
1697
1689
  warnOnce(false, "IntersectionObserver not available on this device. whileInView animations will trigger on mount.");
1698
1690
  }
1699
1691
  /**
@@ -2059,7 +2051,7 @@
2059
2051
  * This will be replaced by the build step with the latest version number.
2060
2052
  * When MotionValues are provided to motion components, warn if versions are mixed.
2061
2053
  */
2062
- this.version = "8.1.4";
2054
+ this.version = "8.1.6";
2063
2055
  /**
2064
2056
  * Duration, in milliseconds, since last updating frame.
2065
2057
  *
@@ -5896,7 +5888,7 @@
5896
5888
  * and warn against mismatches.
5897
5889
  */
5898
5890
  {
5899
- warnOnce(nextValue.version === "8.1.4", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.1.4 may not work as expected.`);
5891
+ warnOnce(nextValue.version === "8.1.6", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.1.6 may not work as expected.`);
5900
5892
  }
5901
5893
  }
5902
5894
  else if (isMotionValue(prevValue)) {
@@ -6079,6 +6071,9 @@
6079
6071
  : this.reducedMotionConfig === "always"
6080
6072
  ? true
6081
6073
  : prefersReducedMotion.current;
6074
+ {
6075
+ warnOnce(this.shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.");
6076
+ }
6082
6077
  if (this.parent)
6083
6078
  this.parent.children.add(this);
6084
6079
  this.setProps(this.props);
@@ -6128,7 +6123,8 @@
6128
6123
  * If we're in development mode, check to make sure we're not rendering a motion component
6129
6124
  * as a child of LazyMotion, as this will break the file-size benefits of using it.
6130
6125
  */
6131
- if (env !== "production" && preloadedFeatures && isStrict) {
6126
+ if (preloadedFeatures &&
6127
+ isStrict) {
6132
6128
  invariant(false, "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.");
6133
6129
  }
6134
6130
  for (let i = 0; i < numFeatures; i++) {
@@ -8640,7 +8636,9 @@
8640
8636
  // Support deprecated exitBeforeEnter prop
8641
8637
  if (exitBeforeEnter) {
8642
8638
  mode = "wait";
8643
- warnOnce(false, "Replace exitBeforeEnter with mode='wait'");
8639
+ {
8640
+ warnOnce(false, "Replace exitBeforeEnter with mode='wait'");
8641
+ }
8644
8642
  }
8645
8643
  // We want to force a re-render once all exiting animations have finished. We
8646
8644
  // either use a local forceRender function, or one from a parent context if it exists.
@@ -8726,8 +8724,7 @@
8726
8724
  const key = child.key;
8727
8725
  return exiting.has(key) ? (child) : (React__namespace.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, presenceAffectsLayout: presenceAffectsLayout, mode: mode }, child));
8728
8726
  });
8729
- if (env !== "production" &&
8730
- mode === "wait" &&
8727
+ if (mode === "wait" &&
8731
8728
  childrenToRender.length > 1) {
8732
8729
  console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
8733
8730
  }
@@ -9871,7 +9868,9 @@
9871
9868
  * @deprecated useElementScroll is deprecated. Convert to useScroll({ container: ref })
9872
9869
  */
9873
9870
  function useElementScroll(ref) {
9874
- warnOnce(false, "useElementScroll is deprecated. Convert to useScroll({ container: ref }).");
9871
+ {
9872
+ warnOnce(false, "useElementScroll is deprecated. Convert to useScroll({ container: ref }).");
9873
+ }
9875
9874
  return useScroll({ container: ref });
9876
9875
  }
9877
9876
 
@@ -9879,7 +9878,9 @@
9879
9878
  * @deprecated useViewportScroll is deprecated. Convert to useScroll()
9880
9879
  */
9881
9880
  function useViewportScroll() {
9882
- warnOnce(false, "useViewportScroll is deprecated. Convert to useScroll().");
9881
+ {
9882
+ warnOnce(false, "useViewportScroll is deprecated. Convert to useScroll().");
9883
+ }
9883
9884
  return useScroll();
9884
9885
  }
9885
9886
 
@@ -9989,6 +9990,9 @@
9989
9990
  */
9990
9991
  !hasReducedMotionListener.current && initPrefersReducedMotion();
9991
9992
  const [shouldReduceMotion] = React.useState(prefersReducedMotion.current);
9993
+ {
9994
+ warnOnce(shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.");
9995
+ }
9992
9996
  /**
9993
9997
  * TODO See if people miss automatically updating shouldReduceMotion setting
9994
9998
  */