framer-motion 7.6.14 → 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.14";
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.14", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.14 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)) {
@@ -5539,9 +5550,6 @@ function boxEquals(a, b) {
5539
5550
  function aspectRatio(box) {
5540
5551
  return calcLength(box.x) / calcLength(box.y);
5541
5552
  }
5542
- function isCloseTo(a, b, max = 0.1) {
5543
- return popmotion.distance(a, b) <= max;
5544
- }
5545
5553
 
5546
5554
  class NodeStack {
5547
5555
  constructor() {
@@ -7001,7 +7009,7 @@ function roundBox(box) {
7001
7009
  function shouldAnimatePositionOnly(animationType, snapshot, layout) {
7002
7010
  return (animationType === "position" ||
7003
7011
  (animationType === "preserve-aspect" &&
7004
- !isCloseTo(aspectRatio(snapshot), aspectRatio(layout), 0.2)));
7012
+ !isNear(aspectRatio(snapshot), aspectRatio(layout), 0.2)));
7005
7013
  }
7006
7014
 
7007
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 };
@@ -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.14", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.14 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.14";
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.14";
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.14", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.14 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)) {
@@ -6707,9 +6718,6 @@
6707
6718
  function aspectRatio(box) {
6708
6719
  return calcLength(box.x) / calcLength(box.y);
6709
6720
  }
6710
- function isCloseTo(a, b, max = 0.1) {
6711
- return distance(a, b) <= max;
6712
- }
6713
6721
 
6714
6722
  class NodeStack {
6715
6723
  constructor() {
@@ -8169,7 +8177,7 @@
8169
8177
  function shouldAnimatePositionOnly(animationType, snapshot, layout) {
8170
8178
  return (animationType === "position" ||
8171
8179
  (animationType === "preserve-aspect" &&
8172
- !isCloseTo(aspectRatio(snapshot), aspectRatio(layout), 0.2)));
8180
+ !isNear(aspectRatio(snapshot), aspectRatio(layout), 0.2)));
8173
8181
  }
8174
8182
 
8175
8183
  const DocumentProjectionNode = createProjectionNode({