framer-motion 12.7.2 → 12.7.4

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.
@@ -170,33 +170,36 @@
170
170
  const PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, mode, anchorX, }) => {
171
171
  const presenceChildren = useConstant(newChildrenMap);
172
172
  const id = React$1.useId();
173
- const memoizedOnExitComplete = React$1.useCallback((childId) => {
174
- presenceChildren.set(childId, true);
175
- for (const isComplete of presenceChildren.values()) {
176
- if (!isComplete)
177
- return; // can stop searching when any is incomplete
178
- }
179
- onExitComplete && onExitComplete();
180
- }, [presenceChildren, onExitComplete]);
181
- const context = React$1.useMemo(() => ({
182
- id,
183
- initial,
184
- isPresent,
185
- custom,
186
- onExitComplete: memoizedOnExitComplete,
187
- register: (childId) => {
188
- presenceChildren.set(childId, false);
189
- return () => presenceChildren.delete(childId);
190
- },
191
- }),
173
+ let isReusedContext = true;
174
+ let context = React$1.useMemo(() => {
175
+ isReusedContext = false;
176
+ return {
177
+ id,
178
+ initial,
179
+ isPresent,
180
+ custom,
181
+ onExitComplete: (childId) => {
182
+ presenceChildren.set(childId, true);
183
+ for (const isComplete of presenceChildren.values()) {
184
+ if (!isComplete)
185
+ return; // can stop searching when any is incomplete
186
+ }
187
+ onExitComplete && onExitComplete();
188
+ },
189
+ register: (childId) => {
190
+ presenceChildren.set(childId, false);
191
+ return () => presenceChildren.delete(childId);
192
+ },
193
+ };
194
+ }, [isPresent, presenceChildren, onExitComplete]);
192
195
  /**
193
196
  * If the presence of a child affects the layout of the components around it,
194
197
  * we want to make a new context value to ensure they get re-rendered
195
198
  * so they can detect that layout change.
196
199
  */
197
- presenceAffectsLayout
198
- ? [Math.random(), memoizedOnExitComplete]
199
- : [isPresent, memoizedOnExitComplete]);
200
+ if (presenceAffectsLayout && isReusedContext) {
201
+ context = { ...context };
202
+ }
200
203
  React$1.useMemo(() => {
201
204
  presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
202
205
  }, [isPresent]);
@@ -911,6 +914,7 @@
911
914
  }
912
915
  const { element, name, keyframes: unresolvedKeyframes, pseudoElement, allowFlatten = false, } = options;
913
916
  let { transition } = options;
917
+ this.isPseudoElement = Boolean(pseudoElement);
914
918
  this.allowFlatten = allowFlatten;
915
919
  /**
916
920
  * Stop any existing animations on the element before reading existing keyframes.
@@ -982,10 +986,11 @@
982
986
  * while deferring the commit until the next animation frame.
983
987
  */
984
988
  commitStyles() {
985
- this.animation.commitStyles?.();
989
+ if (!this.isPseudoElement) {
990
+ this.animation.commitStyles?.();
991
+ }
986
992
  }
987
993
  get duration() {
988
- console.log(this.animation.effect?.getComputedTiming());
989
994
  const duration = this.animation.effect?.getComputedTiming().duration || 0;
990
995
  return millisecondsToSeconds(Number(duration));
991
996
  }
@@ -1560,7 +1565,7 @@
1560
1565
  * This will be replaced by the build step with the latest version number.
1561
1566
  * When MotionValues are provided to motion components, warn if versions are mixed.
1562
1567
  */
1563
- this.version = "12.7.2";
1568
+ this.version = "12.7.4";
1564
1569
  /**
1565
1570
  * Tracks whether this value can output a velocity. Currently this is only true
1566
1571
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -7149,7 +7154,7 @@
7149
7154
  * and warn against mismatches.
7150
7155
  */
7151
7156
  {
7152
- warnOnce(nextValue.version === "12.7.2", `Attempting to mix Motion versions ${nextValue.version} with 12.7.2 may not work as expected.`);
7157
+ warnOnce(nextValue.version === "12.7.4", `Attempting to mix Motion versions ${nextValue.version} with 12.7.4 may not work as expected.`);
7153
7158
  }
7154
7159
  }
7155
7160
  else if (isMotionValue(prevValue)) {