framer-motion 7.6.8 → 7.6.9

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
@@ -2258,7 +2258,7 @@ class MotionValue {
2258
2258
  * This will be replaced by the build step with the latest version number.
2259
2259
  * When MotionValues are provided to motion components, warn if versions are mixed.
2260
2260
  */
2261
- this.version = "7.6.8";
2261
+ this.version = "7.6.9";
2262
2262
  /**
2263
2263
  * Duration, in milliseconds, since last updating frame.
2264
2264
  *
@@ -4524,7 +4524,7 @@ function updateMotionValuesFromProps(element, next, prev) {
4524
4524
  * and warn against mismatches.
4525
4525
  */
4526
4526
  if (process.env.NODE_ENV === "development") {
4527
- warnOnce(nextValue.version === "7.6.8", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.8 may not work as expected.`);
4527
+ warnOnce(nextValue.version === "7.6.9", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.9 may not work as expected.`);
4528
4528
  }
4529
4529
  }
4530
4530
  else if (isMotionValue(prevValue)) {
@@ -4726,10 +4726,14 @@ class VisualElement {
4726
4726
  this.current = null;
4727
4727
  }
4728
4728
  bindToMotionValue(key, value) {
4729
+ const valueIsTransform = transformProps.has(key);
4729
4730
  const removeOnChange = value.onChange((latestValue) => {
4730
4731
  this.latestValues[key] = latestValue;
4731
4732
  this.props.onUpdate &&
4732
4733
  sync__default["default"].update(this.notifyUpdate, false, true);
4734
+ if (valueIsTransform && this.projection) {
4735
+ this.projection.isProjectionDirty = true;
4736
+ }
4733
4737
  });
4734
4738
  const removeOnRenderRequest = value.onRenderRequest(this.scheduleRender);
4735
4739
  this.valueSubscriptions.set(key, () => {
@@ -5754,6 +5758,11 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
5754
5758
  * and if one node is dirtied, they all are.
5755
5759
  */
5756
5760
  this.isLayoutDirty = false;
5761
+ /**
5762
+ * Flag to true if we think the projection calculations for this or any
5763
+ * child might need recalculating as a result of an updated transform or layout animation.
5764
+ */
5765
+ this.isProjectionDirty = false;
5757
5766
  /**
5758
5767
  * Block layout updates for instant layout transitions throughout the tree.
5759
5768
  */
@@ -6256,6 +6265,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6256
6265
  */
6257
6266
  setTargetDelta(delta) {
6258
6267
  this.targetDelta = delta;
6268
+ this.isProjectionDirty = true;
6259
6269
  this.root.scheduleUpdateProjection();
6260
6270
  }
6261
6271
  setOptions(options) {
@@ -6279,6 +6289,14 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6279
6289
  */
6280
6290
  resolveTargetDelta() {
6281
6291
  var _a;
6292
+ /**
6293
+ * Propagate isProjectionDirty. Nodes are ordered by depth, so if the parent here
6294
+ * is dirty we can simply pass this forward.
6295
+ */
6296
+ this.isProjectionDirty || (this.isProjectionDirty = this.getLead().isProjectionDirty ||
6297
+ Boolean(this.parent && this.parent.isProjectionDirty));
6298
+ if (!this.isProjectionDirty)
6299
+ return;
6282
6300
  const { layout, layoutId } = this.options;
6283
6301
  /**
6284
6302
  * If we have no layout, we can't perform projection, so early return
@@ -6382,6 +6400,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6382
6400
  }
6383
6401
  calcProjection() {
6384
6402
  var _a;
6403
+ if (!this.isProjectionDirty)
6404
+ return;
6405
+ this.isProjectionDirty = false;
6385
6406
  const { layout, layoutId } = this.options;
6386
6407
  /**
6387
6408
  * If this section of the tree isn't animating we can
@@ -64,6 +64,11 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
64
64
  * and if one node is dirtied, they all are.
65
65
  */
66
66
  this.isLayoutDirty = false;
67
+ /**
68
+ * Flag to true if we think the projection calculations for this or any
69
+ * child might need recalculating as a result of an updated transform or layout animation.
70
+ */
71
+ this.isProjectionDirty = false;
67
72
  /**
68
73
  * Block layout updates for instant layout transitions throughout the tree.
69
74
  */
@@ -566,6 +571,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
566
571
  */
567
572
  setTargetDelta(delta) {
568
573
  this.targetDelta = delta;
574
+ this.isProjectionDirty = true;
569
575
  this.root.scheduleUpdateProjection();
570
576
  }
571
577
  setOptions(options) {
@@ -589,6 +595,14 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
589
595
  */
590
596
  resolveTargetDelta() {
591
597
  var _a;
598
+ /**
599
+ * Propagate isProjectionDirty. Nodes are ordered by depth, so if the parent here
600
+ * is dirty we can simply pass this forward.
601
+ */
602
+ this.isProjectionDirty || (this.isProjectionDirty = this.getLead().isProjectionDirty ||
603
+ Boolean(this.parent && this.parent.isProjectionDirty));
604
+ if (!this.isProjectionDirty)
605
+ return;
592
606
  const { layout, layoutId } = this.options;
593
607
  /**
594
608
  * If we have no layout, we can't perform projection, so early return
@@ -692,6 +706,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
692
706
  }
693
707
  calcProjection() {
694
708
  var _a;
709
+ if (!this.isProjectionDirty)
710
+ return;
711
+ this.isProjectionDirty = false;
695
712
  const { layout, layoutId } = this.options;
696
713
  /**
697
714
  * If this section of the tree isn't animating we can
@@ -11,6 +11,7 @@ import { SubscriptionManager } from '../utils/subscription-manager.mjs';
11
11
  import { motionValue } from '../value/index.mjs';
12
12
  import { isWillChangeMotionValue } from '../value/use-will-change/is.mjs';
13
13
  import { isMotionValue } from '../value/utils/is-motion-value.mjs';
14
+ import { transformProps } from './html/utils/transform.mjs';
14
15
  import { variantPriorityOrder } from './utils/animation-state.mjs';
15
16
  import { isControllingVariants, isVariantNode } from './utils/is-controlling-variants.mjs';
16
17
  import { isVariantLabel } from './utils/is-variant-label.mjs';
@@ -181,10 +182,14 @@ class VisualElement {
181
182
  this.current = null;
182
183
  }
183
184
  bindToMotionValue(key, value) {
185
+ const valueIsTransform = transformProps.has(key);
184
186
  const removeOnChange = value.onChange((latestValue) => {
185
187
  this.latestValues[key] = latestValue;
186
188
  this.props.onUpdate &&
187
189
  sync.update(this.notifyUpdate, false, true);
190
+ if (valueIsTransform && this.projection) {
191
+ this.projection.isProjectionDirty = true;
192
+ }
188
193
  });
189
194
  const removeOnRenderRequest = value.onRenderRequest(this.scheduleRender);
190
195
  this.valueSubscriptions.set(key, () => {
@@ -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.8", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.8 may not work as expected.`);
25
+ warnOnce(nextValue.version === "7.6.9", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.9 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.8";
27
+ this.version = "7.6.9";
28
28
  /**
29
29
  * Duration, in milliseconds, since last updating frame.
30
30
  *
@@ -3426,7 +3426,7 @@
3426
3426
  * This will be replaced by the build step with the latest version number.
3427
3427
  * When MotionValues are provided to motion components, warn if versions are mixed.
3428
3428
  */
3429
- this.version = "7.6.8";
3429
+ this.version = "7.6.9";
3430
3430
  /**
3431
3431
  * Duration, in milliseconds, since last updating frame.
3432
3432
  *
@@ -5692,7 +5692,7 @@
5692
5692
  * and warn against mismatches.
5693
5693
  */
5694
5694
  {
5695
- warnOnce(nextValue.version === "7.6.8", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.8 may not work as expected.`);
5695
+ warnOnce(nextValue.version === "7.6.9", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.9 may not work as expected.`);
5696
5696
  }
5697
5697
  }
5698
5698
  else if (isMotionValue(prevValue)) {
@@ -5894,10 +5894,14 @@
5894
5894
  this.current = null;
5895
5895
  }
5896
5896
  bindToMotionValue(key, value) {
5897
+ const valueIsTransform = transformProps.has(key);
5897
5898
  const removeOnChange = value.onChange((latestValue) => {
5898
5899
  this.latestValues[key] = latestValue;
5899
5900
  this.props.onUpdate &&
5900
5901
  sync.update(this.notifyUpdate, false, true);
5902
+ if (valueIsTransform && this.projection) {
5903
+ this.projection.isProjectionDirty = true;
5904
+ }
5901
5905
  });
5902
5906
  const removeOnRenderRequest = value.onRenderRequest(this.scheduleRender);
5903
5907
  this.valueSubscriptions.set(key, () => {
@@ -6922,6 +6926,11 @@
6922
6926
  * and if one node is dirtied, they all are.
6923
6927
  */
6924
6928
  this.isLayoutDirty = false;
6929
+ /**
6930
+ * Flag to true if we think the projection calculations for this or any
6931
+ * child might need recalculating as a result of an updated transform or layout animation.
6932
+ */
6933
+ this.isProjectionDirty = false;
6925
6934
  /**
6926
6935
  * Block layout updates for instant layout transitions throughout the tree.
6927
6936
  */
@@ -7424,6 +7433,7 @@
7424
7433
  */
7425
7434
  setTargetDelta(delta) {
7426
7435
  this.targetDelta = delta;
7436
+ this.isProjectionDirty = true;
7427
7437
  this.root.scheduleUpdateProjection();
7428
7438
  }
7429
7439
  setOptions(options) {
@@ -7447,6 +7457,14 @@
7447
7457
  */
7448
7458
  resolveTargetDelta() {
7449
7459
  var _a;
7460
+ /**
7461
+ * Propagate isProjectionDirty. Nodes are ordered by depth, so if the parent here
7462
+ * is dirty we can simply pass this forward.
7463
+ */
7464
+ this.isProjectionDirty || (this.isProjectionDirty = this.getLead().isProjectionDirty ||
7465
+ Boolean(this.parent && this.parent.isProjectionDirty));
7466
+ if (!this.isProjectionDirty)
7467
+ return;
7450
7468
  const { layout, layoutId } = this.options;
7451
7469
  /**
7452
7470
  * If we have no layout, we can't perform projection, so early return
@@ -7550,6 +7568,9 @@
7550
7568
  }
7551
7569
  calcProjection() {
7552
7570
  var _a;
7571
+ if (!this.isProjectionDirty)
7572
+ return;
7573
+ this.isProjectionDirty = false;
7553
7574
  const { layout, layoutId } = this.options;
7554
7575
  /**
7555
7576
  * If this section of the tree isn't animating we can