framer-motion 12.4.6 → 12.4.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.
@@ -1106,7 +1106,7 @@
1106
1106
  * This will be replaced by the build step with the latest version number.
1107
1107
  * When MotionValues are provided to motion components, warn if versions are mixed.
1108
1108
  */
1109
- this.version = "12.4.6";
1109
+ this.version = "12.4.9";
1110
1110
  /**
1111
1111
  * Tracks whether this value can output a velocity. Currently this is only true
1112
1112
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -5305,8 +5305,9 @@
5305
5305
  // either be null or non-null for the lifespan of the component.
5306
5306
  const id = React$1.useId();
5307
5307
  React$1.useEffect(() => {
5308
- if (subscribe)
5309
- register(id);
5308
+ if (subscribe) {
5309
+ return register(id);
5310
+ }
5310
5311
  }, [subscribe]);
5311
5312
  const safeToRemove = React$1.useCallback(() => subscribe && onExitComplete && onExitComplete(id), [id, onExitComplete, subscribe]);
5312
5313
  return !isPresent && onExitComplete ? [false, safeToRemove] : [true];
@@ -5957,7 +5958,7 @@
5957
5958
  * and warn against mismatches.
5958
5959
  */
5959
5960
  {
5960
- warnOnce(nextValue.version === "12.4.6", `Attempting to mix Motion versions ${nextValue.version} with 12.4.6 may not work as expected.`);
5961
+ warnOnce(nextValue.version === "12.4.9", `Attempting to mix Motion versions ${nextValue.version} with 12.4.9 may not work as expected.`);
5961
5962
  }
5962
5963
  }
5963
5964
  else if (isMotionValue(prevValue)) {
@@ -10330,6 +10331,7 @@
10330
10331
  onMove && onMove(this.lastMoveEvent, info);
10331
10332
  };
10332
10333
  this.handlePointerMove = (event, info) => {
10334
+ this.index = getElementIndex(event.currentTarget);
10333
10335
  if (event.target instanceof Element &&
10334
10336
  event.target.hasPointerCapture &&
10335
10337
  event.pointerId !== undefined) {
@@ -10377,7 +10379,19 @@
10377
10379
  onSessionStart &&
10378
10380
  onSessionStart(event, getPanInfo(initialInfo, this.history));
10379
10381
  capturePointer(event, "set");
10380
- this.removeListeners = pipe(addPointerEvent(event.currentTarget, "pointermove", this.handlePointerMove), addPointerEvent(event.currentTarget, "pointerup", this.handlePointerUp), addPointerEvent(event.currentTarget, "pointercancel", this.handlePointerUp), addPointerEvent(event.currentTarget, "lostpointercapture", this.handlePointerUp));
10382
+ this.removeListeners = pipe(addPointerEvent(event.currentTarget, "pointermove", this.handlePointerMove), addPointerEvent(event.currentTarget, "pointerup", this.handlePointerUp), addPointerEvent(event.currentTarget, "pointercancel", this.handlePointerUp), addPointerEvent(event.currentTarget, "lostpointercapture", (lostPointerEvent, lostPointerInfo) => {
10383
+ const index = getElementIndex(lostPointerEvent.currentTarget);
10384
+ /**
10385
+ * If the pointer has lost capture because it's moved in the DOM
10386
+ * then we need to re-capture it.
10387
+ */
10388
+ if (index !== this.index) {
10389
+ capturePointer(lostPointerEvent, "set");
10390
+ }
10391
+ else {
10392
+ this.handlePointerUp(lostPointerEvent, lostPointerInfo);
10393
+ }
10394
+ }));
10381
10395
  }
10382
10396
  updateHandlers(handlers) {
10383
10397
  this.handlers = handlers;
@@ -10441,6 +10455,11 @@
10441
10455
  }
10442
10456
  return currentVelocity;
10443
10457
  }
10458
+ function getElementIndex(element) {
10459
+ if (!element.parentNode)
10460
+ return -1;
10461
+ return Array.from(element.parentNode.children).indexOf(element);
10462
+ }
10444
10463
 
10445
10464
  /**
10446
10465
  * Apply constraints to a point. These constraints are both physical along an
@@ -11137,7 +11156,8 @@
11137
11156
  projection.isPresent = isPresent;
11138
11157
  if (drag ||
11139
11158
  prevProps.layoutDependency !== layoutDependency ||
11140
- layoutDependency === undefined) {
11159
+ layoutDependency === undefined ||
11160
+ prevProps.isPresent !== isPresent) {
11141
11161
  projection.willUpdate();
11142
11162
  }
11143
11163
  else {