framer-motion 7.6.13 → 7.6.15

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
@@ -2257,7 +2257,7 @@ class MotionValue {
2257
2257
  * This will be replaced by the build step with the latest version number.
2258
2258
  * When MotionValues are provided to motion components, warn if versions are mixed.
2259
2259
  */
2260
- this.version = "7.6.13";
2260
+ this.version = "7.6.15";
2261
2261
  /**
2262
2262
  * Duration, in milliseconds, since last updating frame.
2263
2263
  *
@@ -3330,7 +3330,7 @@ function calcLength(axis) {
3330
3330
  return axis.max - axis.min;
3331
3331
  }
3332
3332
  function isNear(value, target = 0, maxDistance = 0.01) {
3333
- return popmotion.distance(value, target) < maxDistance;
3333
+ return Math.abs(value - target) <= maxDistance;
3334
3334
  }
3335
3335
  function calcAxisDelta(delta, source, target, origin = 0.5) {
3336
3336
  delta.origin = origin;
@@ -3630,6 +3630,17 @@ function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
3630
3630
  transformBox(box, node.latestValues);
3631
3631
  }
3632
3632
  }
3633
+ /**
3634
+ * Snap tree scale back to 1 if it's within a non-perceivable threshold.
3635
+ * This will help reduce useless scales getting rendered.
3636
+ */
3637
+ treeScale.x = snapToDefault(treeScale.x);
3638
+ treeScale.y = snapToDefault(treeScale.y);
3639
+ }
3640
+ function snapToDefault(scale) {
3641
+ if (Number.isInteger(scale))
3642
+ return scale;
3643
+ return scale > 1.0000000000001 || scale < 0.999999999999 ? scale : 1;
3633
3644
  }
3634
3645
  function translateAxis(axis, distance) {
3635
3646
  axis.min = axis.min + distance;
@@ -4523,7 +4534,7 @@ function updateMotionValuesFromProps(element, next, prev) {
4523
4534
  * and warn against mismatches.
4524
4535
  */
4525
4536
  if (process.env.NODE_ENV === "development") {
4526
- warnOnce(nextValue.version === "7.6.13", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.13 may not work as expected.`);
4537
+ warnOnce(nextValue.version === "7.6.15", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.15 may not work as expected.`);
4527
4538
  }
4528
4539
  }
4529
4540
  else if (isMotionValue(prevValue)) {
@@ -4677,17 +4688,6 @@ class VisualElement {
4677
4688
  }
4678
4689
  }
4679
4690
  }
4680
- /**
4681
- * Update external values with initial values
4682
- */
4683
- if (props.values) {
4684
- for (const key in props.values) {
4685
- const value = props.values[key];
4686
- if (latestValues[key] !== undefined && isMotionValue(value)) {
4687
- value.set(latestValues[key]);
4688
- }
4689
- }
4690
- }
4691
4691
  }
4692
4692
  /**
4693
4693
  * This method takes React props and returns found MotionValues. For example, HTML
@@ -5550,9 +5550,6 @@ function boxEquals(a, b) {
5550
5550
  function aspectRatio(box) {
5551
5551
  return calcLength(box.x) / calcLength(box.y);
5552
5552
  }
5553
- function isCloseTo(a, b, max = 0.1) {
5554
- return popmotion.distance(a, b) <= max;
5555
- }
5556
5553
 
5557
5554
  class NodeStack {
5558
5555
  constructor() {
@@ -7012,7 +7009,7 @@ function roundBox(box) {
7012
7009
  function shouldAnimatePositionOnly(animationType, snapshot, layout) {
7013
7010
  return (animationType === "position" ||
7014
7011
  (animationType === "preserve-aspect" &&
7015
- !isCloseTo(aspectRatio(snapshot), aspectRatio(layout), 0.2)));
7012
+ !isNear(aspectRatio(snapshot), aspectRatio(layout), 0.2)));
7016
7013
  }
7017
7014
 
7018
7015
  const DocumentProjectionNode = createProjectionNode({
@@ -72,6 +72,17 @@ function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
72
72
  transformBox(box, node.latestValues);
73
73
  }
74
74
  }
75
+ /**
76
+ * Snap tree scale back to 1 if it's within a non-perceivable threshold.
77
+ * This will help reduce useless scales getting rendered.
78
+ */
79
+ treeScale.x = snapToDefault(treeScale.x);
80
+ treeScale.y = snapToDefault(treeScale.y);
81
+ }
82
+ function snapToDefault(scale) {
83
+ if (Number.isInteger(scale))
84
+ return scale;
85
+ return scale > 1.0000000000001 || scale < 0.999999999999 ? scale : 1;
75
86
  }
76
87
  function translateAxis(axis, distance) {
77
88
  axis.min = axis.min + distance;
@@ -1,10 +1,10 @@
1
- import { mix, distance } from 'popmotion';
1
+ import { mix } from 'popmotion';
2
2
 
3
3
  function calcLength(axis) {
4
4
  return axis.max - axis.min;
5
5
  }
6
6
  function isNear(value, target = 0, maxDistance = 0.01) {
7
- return distance(value, target) < maxDistance;
7
+ return Math.abs(value - target) <= maxDistance;
8
8
  }
9
9
  function calcAxisDelta(delta, source, target, origin = 0.5) {
10
10
  delta.origin = origin;
@@ -1,4 +1,3 @@
1
- import { distance } from 'popmotion';
2
1
  import { calcLength } from './delta-calc.mjs';
3
2
 
4
3
  function isAxisDeltaZero(delta) {
@@ -16,8 +15,5 @@ function boxEquals(a, b) {
16
15
  function aspectRatio(box) {
17
16
  return calcLength(box.x) / calcLength(box.y);
18
17
  }
19
- function isCloseTo(a, b, max = 0.1) {
20
- return distance(a, b) <= max;
21
- }
22
18
 
23
- export { aspectRatio, boxEquals, isCloseTo, isDeltaZero };
19
+ export { aspectRatio, boxEquals, isDeltaZero };
@@ -5,11 +5,11 @@ import { SubscriptionManager } from '../../utils/subscription-manager.mjs';
5
5
  import { mixValues } from '../animation/mix-values.mjs';
6
6
  import { copyBoxInto } from '../geometry/copy.mjs';
7
7
  import { translateAxis, transformBox, applyBoxDelta, applyTreeDeltas } from '../geometry/delta-apply.mjs';
8
- import { calcRelativePosition, calcRelativeBox, calcBoxDelta, calcLength } from '../geometry/delta-calc.mjs';
8
+ import { calcRelativePosition, calcRelativeBox, calcBoxDelta, calcLength, isNear } from '../geometry/delta-calc.mjs';
9
9
  import { removeBoxTransforms } from '../geometry/delta-remove.mjs';
10
10
  import { createBox, createDelta } from '../geometry/models.mjs';
11
11
  import { getValueTransition } from '../../animation/utils/transitions.mjs';
12
- import { boxEquals, isDeltaZero, isCloseTo, aspectRatio } from '../geometry/utils.mjs';
12
+ import { boxEquals, isDeltaZero, aspectRatio } from '../geometry/utils.mjs';
13
13
  import { NodeStack } from '../shared/stack.mjs';
14
14
  import { scaleCorrectors } from '../styles/scale-correction.mjs';
15
15
  import { buildProjectionTransform } from '../styles/transform.mjs';
@@ -1308,7 +1308,7 @@ function roundBox(box) {
1308
1308
  function shouldAnimatePositionOnly(animationType, snapshot, layout) {
1309
1309
  return (animationType === "position" ||
1310
1310
  (animationType === "preserve-aspect" &&
1311
- !isCloseTo(aspectRatio(snapshot), aspectRatio(layout), 0.2)));
1311
+ !isNear(aspectRatio(snapshot), aspectRatio(layout), 0.2)));
1312
1312
  }
1313
1313
 
1314
1314
  export { createProjectionNode, mixAxis, mixAxisDelta, mixBox, propagateDirtyNodes };
@@ -134,17 +134,6 @@ class VisualElement {
134
134
  }
135
135
  }
136
136
  }
137
- /**
138
- * Update external values with initial values
139
- */
140
- if (props.values) {
141
- for (const key in props.values) {
142
- const value = props.values[key];
143
- if (latestValues[key] !== undefined && isMotionValue(value)) {
144
- value.set(latestValues[key]);
145
- }
146
- }
147
- }
148
137
  }
149
138
  /**
150
139
  * This method takes React props and returns found MotionValues. For example, HTML
@@ -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 === "7.6.13", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.13 may not work as expected.`);
25
+ warnOnce(nextValue.version === "7.6.15", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.15 may not work as expected.`);
26
26
  }
27
27
  }
28
28
  else if (isMotionValue(prevValue)) {
@@ -24,7 +24,7 @@ class MotionValue {
24
24
  * This will be replaced by the build step with the latest version number.
25
25
  * When MotionValues are provided to motion components, warn if versions are mixed.
26
26
  */
27
- this.version = "7.6.13";
27
+ this.version = "7.6.15";
28
28
  /**
29
29
  * Duration, in milliseconds, since last updating frame.
30
30
  *
@@ -3425,7 +3425,7 @@
3425
3425
  * This will be replaced by the build step with the latest version number.
3426
3426
  * When MotionValues are provided to motion components, warn if versions are mixed.
3427
3427
  */
3428
- this.version = "7.6.13";
3428
+ this.version = "7.6.15";
3429
3429
  /**
3430
3430
  * Duration, in milliseconds, since last updating frame.
3431
3431
  *
@@ -4498,7 +4498,7 @@
4498
4498
  return axis.max - axis.min;
4499
4499
  }
4500
4500
  function isNear(value, target = 0, maxDistance = 0.01) {
4501
- return distance(value, target) < maxDistance;
4501
+ return Math.abs(value - target) <= maxDistance;
4502
4502
  }
4503
4503
  function calcAxisDelta(delta, source, target, origin = 0.5) {
4504
4504
  delta.origin = origin;
@@ -4798,6 +4798,17 @@
4798
4798
  transformBox(box, node.latestValues);
4799
4799
  }
4800
4800
  }
4801
+ /**
4802
+ * Snap tree scale back to 1 if it's within a non-perceivable threshold.
4803
+ * This will help reduce useless scales getting rendered.
4804
+ */
4805
+ treeScale.x = snapToDefault(treeScale.x);
4806
+ treeScale.y = snapToDefault(treeScale.y);
4807
+ }
4808
+ function snapToDefault(scale) {
4809
+ if (Number.isInteger(scale))
4810
+ return scale;
4811
+ return scale > 1.0000000000001 || scale < 0.999999999999 ? scale : 1;
4801
4812
  }
4802
4813
  function translateAxis(axis, distance) {
4803
4814
  axis.min = axis.min + distance;
@@ -5691,7 +5702,7 @@
5691
5702
  * and warn against mismatches.
5692
5703
  */
5693
5704
  {
5694
- warnOnce(nextValue.version === "7.6.13", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.13 may not work as expected.`);
5705
+ warnOnce(nextValue.version === "7.6.15", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.15 may not work as expected.`);
5695
5706
  }
5696
5707
  }
5697
5708
  else if (isMotionValue(prevValue)) {
@@ -5845,17 +5856,6 @@
5845
5856
  }
5846
5857
  }
5847
5858
  }
5848
- /**
5849
- * Update external values with initial values
5850
- */
5851
- if (props.values) {
5852
- for (const key in props.values) {
5853
- const value = props.values[key];
5854
- if (latestValues[key] !== undefined && isMotionValue(value)) {
5855
- value.set(latestValues[key]);
5856
- }
5857
- }
5858
- }
5859
5859
  }
5860
5860
  /**
5861
5861
  * This method takes React props and returns found MotionValues. For example, HTML
@@ -6718,9 +6718,6 @@
6718
6718
  function aspectRatio(box) {
6719
6719
  return calcLength(box.x) / calcLength(box.y);
6720
6720
  }
6721
- function isCloseTo(a, b, max = 0.1) {
6722
- return distance(a, b) <= max;
6723
- }
6724
6721
 
6725
6722
  class NodeStack {
6726
6723
  constructor() {
@@ -8180,7 +8177,7 @@
8180
8177
  function shouldAnimatePositionOnly(animationType, snapshot, layout) {
8181
8178
  return (animationType === "position" ||
8182
8179
  (animationType === "preserve-aspect" &&
8183
- !isCloseTo(aspectRatio(snapshot), aspectRatio(layout), 0.2)));
8180
+ !isNear(aspectRatio(snapshot), aspectRatio(layout), 0.2)));
8184
8181
  }
8185
8182
 
8186
8183
  const DocumentProjectionNode = createProjectionNode({