framer-motion 10.2.4 → 10.3.0

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.
@@ -20,6 +20,7 @@ import { globalProjectionState } from './state.mjs';
20
20
  import { delay } from '../../utils/delay.mjs';
21
21
  import { mix } from '../../utils/mix.mjs';
22
22
  import { record } from '../../debug/record.mjs';
23
+ import { frameData } from '../../frameloop/data.mjs';
23
24
 
24
25
  const transformAxes = ["", "X", "Y", "Z"];
25
26
  /**
@@ -629,10 +630,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
629
630
  this.target = undefined;
630
631
  this.isLayoutDirty = false;
631
632
  }
632
- /**
633
- * Frame calculations
634
- */
635
- resolveTargetDelta() {
633
+ resolveTargetDelta(forceRecalculation = false) {
636
634
  var _a;
637
635
  /**
638
636
  * Once the dirty status of nodes has been spread through the tree, we also
@@ -648,7 +646,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
648
646
  * We don't use transform for this step of processing so we don't
649
647
  * need to check whether any nodes have changed transform.
650
648
  */
651
- const canSkip = !((isShared && this.isSharedProjectionDirty) ||
649
+ const canSkip = !(forceRecalculation ||
650
+ (isShared && this.isSharedProjectionDirty) ||
652
651
  this.isProjectionDirty ||
653
652
  ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.isProjectionDirty) ||
654
653
  this.attemptToResolveRelativeTarget);
@@ -660,6 +659,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
660
659
  */
661
660
  if (!this.layout || !(layout || layoutId))
662
661
  return;
662
+ this.resolvedRelativeTargetAt = frameData.timestamp;
663
663
  /**
664
664
  * If we don't have a targetDelta but do have a layout, we can attempt to resolve
665
665
  * a relativeParent. This will allow a component to perform scale correction
@@ -700,6 +700,16 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
700
700
  this.relativeTargetOrigin &&
701
701
  this.relativeParent &&
702
702
  this.relativeParent.target) {
703
+ /**
704
+ * If the parent target isn't up-to-date, force it to update.
705
+ * This is an unfortunate de-optimisation as it means any updating relative
706
+ * projection will cause all the relative parents to recalculate back
707
+ * up the tree.
708
+ */
709
+ if (this.relativeParent.resolvedRelativeTargetAt !==
710
+ frameData.timestamp) {
711
+ this.relativeParent.resolveTargetDelta(true);
712
+ }
703
713
  calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target);
704
714
  /**
705
715
  * If we've only got a targetDelta, resolve it into a target
@@ -786,6 +796,13 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
786
796
  (this.isSharedProjectionDirty || this.isTransformDirty)) {
787
797
  canSkip = false;
788
798
  }
799
+ /**
800
+ * If we have resolved the target this frame we must recalculate the
801
+ * projection to ensure it visually represents the internal calculations.
802
+ */
803
+ if (this.resolvedRelativeTargetAt === frameData.timestamp) {
804
+ canSkip = false;
805
+ }
789
806
  if (canSkip)
790
807
  return;
791
808
  const { layout, layoutId } = this.options;
@@ -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 === "10.2.4", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.2.4 may not work as expected.`);
25
+ warnOnce(nextValue.version === "10.3.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.3.0 may not work as expected.`);
26
26
  }
27
27
  }
28
28
  else if (isMotionValue(prevValue)) {
@@ -26,7 +26,7 @@ class MotionValue {
26
26
  * This will be replaced by the build step with the latest version number.
27
27
  * When MotionValues are provided to motion components, warn if versions are mixed.
28
28
  */
29
- this.version = "10.2.4";
29
+ this.version = "10.3.0";
30
30
  /**
31
31
  * Duration, in milliseconds, since last updating frame.
32
32
  *