framer-motion 6.3.8 → 6.3.11

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
@@ -36,10 +36,10 @@ var sync__default = /*#__PURE__*/_interopDefaultLegacy(sync);
36
36
  /**
37
37
  * Browser-safe usage of process
38
38
  */
39
- var mockProcess = { env: { NODE_ENV: "production" } };
40
- var safeProcess = typeof process === "undefined" ? mockProcess : process;
41
- // eslint-disable-next-line import/no-default-export
42
- var process$1 = safeProcess;
39
+ var defaultEnvironment = "production";
40
+ var env = typeof process === "undefined" || process.env === undefined
41
+ ? defaultEnvironment
42
+ : process.env.NODE_ENV || defaultEnvironment;
43
43
 
44
44
  var createDefinition = function (propNames) { return ({
45
45
  isEnabled: function (props) { return propNames.some(function (name) { return !!props[name]; }); },
@@ -102,9 +102,7 @@ function useFeatures(props, visualElement, preloadedFeatures) {
102
102
  * If we're in development mode, check to make sure we're not rendering a motion component
103
103
  * as a child of LazyMotion, as this will break the file-size benefits of using it.
104
104
  */
105
- if (process$1.env.NODE_ENV !== "production" &&
106
- preloadedFeatures &&
107
- lazyContext.strict) {
105
+ if (env !== "production" && preloadedFeatures && lazyContext.strict) {
108
106
  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.");
109
107
  }
110
108
  for (var i = 0; i < numFeatures; i++) {
@@ -474,7 +472,7 @@ var MotionValue = /** @class */ (function () {
474
472
  * This will be replaced by the build step with the latest version number.
475
473
  * When MotionValues are provided to motion components, warn if versions are mixed.
476
474
  */
477
- this.version = "6.3.8";
475
+ this.version = "6.3.11";
478
476
  /**
479
477
  * Duration, in milliseconds, since last updating frame.
480
478
  *
@@ -1698,7 +1696,7 @@ function addScaleCorrector(correctors) {
1698
1696
  Object.assign(scaleCorrectors, correctors);
1699
1697
  }
1700
1698
 
1701
- var identityProjection = "translate3d(0px, 0px, 0) scale(1, 1)";
1699
+ var identityProjection = "translate3d(0px, 0px, 0) scale(1, 1) scale(1, 1)";
1702
1700
  function buildProjectionTransform(delta, treeScale, latestTransform) {
1703
1701
  /**
1704
1702
  * The translations we use to calculate are always relative to the viewport coordinate space.
@@ -1709,6 +1707,11 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
1709
1707
  var xTranslate = delta.x.translate / treeScale.x;
1710
1708
  var yTranslate = delta.y.translate / treeScale.y;
1711
1709
  var transform = "translate3d(".concat(xTranslate, "px, ").concat(yTranslate, "px, 0) ");
1710
+ /**
1711
+ * Apply scale correction for the tree transform.
1712
+ * This will apply scale to the screen-orientated axes.
1713
+ */
1714
+ transform += "scale(".concat(1 / treeScale.x, ", ").concat(1 / treeScale.y, ") ");
1712
1715
  if (latestTransform) {
1713
1716
  var rotate = latestTransform.rotate, rotateX = latestTransform.rotateX, rotateY = latestTransform.rotateY;
1714
1717
  if (rotate)
@@ -1718,7 +1721,13 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
1718
1721
  if (rotateY)
1719
1722
  transform += "rotateY(".concat(rotateY, "deg) ");
1720
1723
  }
1721
- transform += "scale(".concat(delta.x.scale, ", ").concat(delta.y.scale, ")");
1724
+ /**
1725
+ * Apply scale to match the size of the element to the size we want it.
1726
+ * This will apply scale to the element-orientated axes.
1727
+ */
1728
+ var elementScaleX = delta.x.scale * treeScale.x;
1729
+ var elementScaleY = delta.y.scale * treeScale.y;
1730
+ transform += "scale(".concat(elementScaleX, ", ").concat(elementScaleY, ")");
1722
1731
  return transform === identityProjection ? "none" : transform;
1723
1732
  }
1724
1733
 
@@ -4337,7 +4346,7 @@ function useMissingIntersectionObserver(shouldObserve, state, visualElement, _a)
4337
4346
  React.useEffect(function () {
4338
4347
  if (!shouldObserve || !fallback)
4339
4348
  return;
4340
- if (process$1.env.NODE_ENV !== "production") {
4349
+ if (env !== "production") {
4341
4350
  warnOnce(false, "IntersectionObserver not available on this device. whileInView animations will trigger on mount.");
4342
4351
  }
4343
4352
  /**
@@ -5972,7 +5981,7 @@ function updateMotionValuesFromProps(element, next, prev) {
5972
5981
  * and warn against mismatches.
5973
5982
  */
5974
5983
  if (process.env.NODE_ENV === "development") {
5975
- warnOnce(nextValue.version !== "6.3.8", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 6.3.8 may not work as expected."));
5984
+ warnOnce(nextValue.version === "6.3.11", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 6.3.11 may not work as expected."));
5976
5985
  }
5977
5986
  }
5978
5987
  else if (isMotionValue(prevValue)) {
@@ -7359,7 +7368,7 @@ var AnimatePresence = function (_a) {
7359
7368
  var key = child.key;
7360
7369
  return exiting.has(key) ? (child) : (React__namespace.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, presenceAffectsLayout: presenceAffectsLayout }, child));
7361
7370
  });
7362
- if (process$1.env.NODE_ENV !== "production" &&
7371
+ if (env !== "production" &&
7363
7372
  exitBeforeEnter &&
7364
7373
  childrenToRender.length > 1) {
7365
7374
  console.warn("You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This will lead to odd visual behaviour.");
@@ -1,7 +1,7 @@
1
1
  import { __read, __spreadArray } from 'tslib';
2
2
  import * as React from 'react';
3
3
  import { useContext, useRef, cloneElement, Children, isValidElement } from 'react';
4
- import process from '../../utils/process.mjs';
4
+ import { env } from '../../utils/process.mjs';
5
5
  import { useForceUpdate } from '../../utils/use-force-update.mjs';
6
6
  import { useIsMounted } from '../../utils/use-is-mounted.mjs';
7
7
  import { PresenceChild } from './PresenceChild.mjs';
@@ -144,7 +144,7 @@ var AnimatePresence = function (_a) {
144
144
  var key = child.key;
145
145
  return exiting.has(key) ? (child) : (React.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, presenceAffectsLayout: presenceAffectsLayout }, child));
146
146
  });
147
- if (process.env.NODE_ENV !== "production" &&
147
+ if (env !== "production" &&
148
148
  exitBeforeEnter &&
149
149
  childrenToRender.length > 1) {
150
150
  console.warn("You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This will lead to odd visual behaviour.");
@@ -1,7 +1,7 @@
1
1
  import { __assign } from 'tslib';
2
2
  import * as React from 'react';
3
3
  import { useContext } from 'react';
4
- import process from '../../utils/process.mjs';
4
+ import { env } from '../../utils/process.mjs';
5
5
  import { featureDefinitions } from './definitions.mjs';
6
6
  import { invariant } from 'hey-listen';
7
7
  import { LazyContext } from '../../context/LazyContext.mjs';
@@ -20,9 +20,7 @@ function useFeatures(props, visualElement, preloadedFeatures) {
20
20
  * If we're in development mode, check to make sure we're not rendering a motion component
21
21
  * as a child of LazyMotion, as this will break the file-size benefits of using it.
22
22
  */
23
- if (process.env.NODE_ENV !== "production" &&
24
- preloadedFeatures &&
25
- lazyContext.strict) {
23
+ if (env !== "production" && preloadedFeatures && lazyContext.strict) {
26
24
  invariant(false, "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.");
27
25
  }
28
26
  for (var i = 0; i < numFeatures; i++) {
@@ -1,4 +1,4 @@
1
- import process from '../../../utils/process.mjs';
1
+ import { env } from '../../../utils/process.mjs';
2
2
  import { useRef, useEffect } from 'react';
3
3
  import { AnimationType } from '../../../render/utils/types.mjs';
4
4
  import { warnOnce } from '../../../utils/warn-once.mjs';
@@ -75,7 +75,7 @@ function useMissingIntersectionObserver(shouldObserve, state, visualElement, _a)
75
75
  useEffect(function () {
76
76
  if (!shouldObserve || !fallback)
77
77
  return;
78
- if (process.env.NODE_ENV !== "production") {
78
+ if (env !== "production") {
79
79
  warnOnce(false, "IntersectionObserver not available on this device. whileInView animations will trigger on mount.");
80
80
  }
81
81
  /**
@@ -1,4 +1,4 @@
1
- var identityProjection = "translate3d(0px, 0px, 0) scale(1, 1)";
1
+ var identityProjection = "translate3d(0px, 0px, 0) scale(1, 1) scale(1, 1)";
2
2
  function buildProjectionTransform(delta, treeScale, latestTransform) {
3
3
  /**
4
4
  * The translations we use to calculate are always relative to the viewport coordinate space.
@@ -9,6 +9,11 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
9
9
  var xTranslate = delta.x.translate / treeScale.x;
10
10
  var yTranslate = delta.y.translate / treeScale.y;
11
11
  var transform = "translate3d(".concat(xTranslate, "px, ").concat(yTranslate, "px, 0) ");
12
+ /**
13
+ * Apply scale correction for the tree transform.
14
+ * This will apply scale to the screen-orientated axes.
15
+ */
16
+ transform += "scale(".concat(1 / treeScale.x, ", ").concat(1 / treeScale.y, ") ");
12
17
  if (latestTransform) {
13
18
  var rotate = latestTransform.rotate, rotateX = latestTransform.rotateX, rotateY = latestTransform.rotateY;
14
19
  if (rotate)
@@ -18,7 +23,13 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
18
23
  if (rotateY)
19
24
  transform += "rotateY(".concat(rotateY, "deg) ");
20
25
  }
21
- transform += "scale(".concat(delta.x.scale, ", ").concat(delta.y.scale, ")");
26
+ /**
27
+ * Apply scale to match the size of the element to the size we want it.
28
+ * This will apply scale to the element-orientated axes.
29
+ */
30
+ var elementScaleX = delta.x.scale * treeScale.x;
31
+ var elementScaleY = delta.y.scale * treeScale.y;
32
+ transform += "scale(".concat(elementScaleX, ", ").concat(elementScaleY, ")");
22
33
  return transform === identityProjection ? "none" : transform;
23
34
  }
24
35
 
@@ -18,7 +18,7 @@ function updateMotionValuesFromProps(element, next, prev) {
18
18
  * and warn against mismatches.
19
19
  */
20
20
  if (process.env.NODE_ENV === "development") {
21
- warnOnce(nextValue.version !== "6.3.8", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 6.3.8 may not work as expected."));
21
+ warnOnce(nextValue.version === "6.3.11", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 6.3.11 may not work as expected."));
22
22
  }
23
23
  }
24
24
  else if (isMotionValue(prevValue)) {
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Browser-safe usage of process
3
3
  */
4
- var mockProcess = { env: { NODE_ENV: "production" } };
5
- var safeProcess = typeof process === "undefined" ? mockProcess : process;
6
- // eslint-disable-next-line import/no-default-export
7
- var process$1 = safeProcess;
4
+ var defaultEnvironment = "production";
5
+ var env = typeof process === "undefined" || process.env === undefined
6
+ ? defaultEnvironment
7
+ : process.env.NODE_ENV || defaultEnvironment;
8
8
 
9
- export { process$1 as default };
9
+ export { env };
@@ -25,7 +25,7 @@ var MotionValue = /** @class */ (function () {
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 = "6.3.8";
28
+ this.version = "6.3.11";
29
29
  /**
30
30
  * Duration, in milliseconds, since last updating frame.
31
31
  *
@@ -120,6 +120,14 @@
120
120
  return to.concat(ar || Array.prototype.slice.call(from));
121
121
  }
122
122
 
123
+ /**
124
+ * Browser-safe usage of process
125
+ */
126
+ var defaultEnvironment = "production";
127
+ var env = typeof process === "undefined" || process.env === undefined
128
+ ? defaultEnvironment
129
+ : "development" ;
130
+
123
131
  var createDefinition = function (propNames) { return ({
124
132
  isEnabled: function (props) { return propNames.some(function (name) { return !!props[name]; }); },
125
133
  }); };
@@ -196,8 +204,7 @@
196
204
  * If we're in development mode, check to make sure we're not rendering a motion component
197
205
  * as a child of LazyMotion, as this will break the file-size benefits of using it.
198
206
  */
199
- if (preloadedFeatures &&
200
- lazyContext.strict) {
207
+ if (env !== "production" && preloadedFeatures && lazyContext.strict) {
201
208
  invariant(false, "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.");
202
209
  }
203
210
  for (var i = 0; i < numFeatures; i++) {
@@ -1699,7 +1706,7 @@
1699
1706
  * This will be replaced by the build step with the latest version number.
1700
1707
  * When MotionValues are provided to motion components, warn if versions are mixed.
1701
1708
  */
1702
- this.version = "6.3.8";
1709
+ this.version = "6.3.11";
1703
1710
  /**
1704
1711
  * Duration, in milliseconds, since last updating frame.
1705
1712
  *
@@ -2923,7 +2930,7 @@
2923
2930
  Object.assign(scaleCorrectors, correctors);
2924
2931
  }
2925
2932
 
2926
- var identityProjection = "translate3d(0px, 0px, 0) scale(1, 1)";
2933
+ var identityProjection = "translate3d(0px, 0px, 0) scale(1, 1) scale(1, 1)";
2927
2934
  function buildProjectionTransform(delta, treeScale, latestTransform) {
2928
2935
  /**
2929
2936
  * The translations we use to calculate are always relative to the viewport coordinate space.
@@ -2934,6 +2941,11 @@
2934
2941
  var xTranslate = delta.x.translate / treeScale.x;
2935
2942
  var yTranslate = delta.y.translate / treeScale.y;
2936
2943
  var transform = "translate3d(".concat(xTranslate, "px, ").concat(yTranslate, "px, 0) ");
2944
+ /**
2945
+ * Apply scale correction for the tree transform.
2946
+ * This will apply scale to the screen-orientated axes.
2947
+ */
2948
+ transform += "scale(".concat(1 / treeScale.x, ", ").concat(1 / treeScale.y, ") ");
2937
2949
  if (latestTransform) {
2938
2950
  var rotate = latestTransform.rotate, rotateX = latestTransform.rotateX, rotateY = latestTransform.rotateY;
2939
2951
  if (rotate)
@@ -2943,7 +2955,13 @@
2943
2955
  if (rotateY)
2944
2956
  transform += "rotateY(".concat(rotateY, "deg) ");
2945
2957
  }
2946
- transform += "scale(".concat(delta.x.scale, ", ").concat(delta.y.scale, ")");
2958
+ /**
2959
+ * Apply scale to match the size of the element to the size we want it.
2960
+ * This will apply scale to the element-orientated axes.
2961
+ */
2962
+ var elementScaleX = delta.x.scale * treeScale.x;
2963
+ var elementScaleY = delta.y.scale * treeScale.y;
2964
+ transform += "scale(".concat(elementScaleX, ", ").concat(elementScaleY, ")");
2947
2965
  return transform === identityProjection ? "none" : transform;
2948
2966
  }
2949
2967
 
@@ -5562,7 +5580,7 @@
5562
5580
  React.useEffect(function () {
5563
5581
  if (!shouldObserve || !fallback)
5564
5582
  return;
5565
- {
5583
+ if (env !== "production") {
5566
5584
  warnOnce(false, "IntersectionObserver not available on this device. whileInView animations will trigger on mount.");
5567
5585
  }
5568
5586
  /**
@@ -7197,7 +7215,7 @@
7197
7215
  * and warn against mismatches.
7198
7216
  */
7199
7217
  {
7200
- warnOnce(nextValue.version !== "6.3.8", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 6.3.8 may not work as expected."));
7218
+ warnOnce(nextValue.version === "6.3.11", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 6.3.11 may not work as expected."));
7201
7219
  }
7202
7220
  }
7203
7221
  else if (isMotionValue(prevValue)) {
@@ -8584,7 +8602,8 @@
8584
8602
  var key = child.key;
8585
8603
  return exiting.has(key) ? (child) : (React__namespace.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, presenceAffectsLayout: presenceAffectsLayout }, child));
8586
8604
  });
8587
- if (exitBeforeEnter &&
8605
+ if (env !== "production" &&
8606
+ exitBeforeEnter &&
8588
8607
  childrenToRender.length > 1) {
8589
8608
  console.warn("You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This will lead to odd visual behaviour.");
8590
8609
  }