motion 12.4.3 → 12.4.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.
- package/dist/cjs/index.js +64 -23
- package/dist/cjs/mini.js +1 -1
- package/dist/cjs/react-client.js +440 -387
- package/dist/cjs/react-mini.js +1 -1
- package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +8 -10
- package/dist/es/framer-motion/dist/es/gestures/pan/PanSession.mjs +27 -8
- package/dist/es/framer-motion/dist/es/gestures/pan/index.mjs +3 -5
- package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/framer-motion/dist/es/value/index.mjs +1 -1
- package/dist/es/motion-dom/dist/es/gestures/press/index.mjs +61 -20
- package/dist/es/motion-dom/dist/es/utils/resolve-elements.mjs +1 -1
- package/dist/motion.dev.js +64 -23
- package/dist/motion.js +1 -1
- package/package.json +3 -3
- package/dist/es/framer-motion/dist/es/utils/get-context-window.mjs +0 -6
package/dist/cjs/index.js
CHANGED
|
@@ -364,7 +364,7 @@ function isDragActive() {
|
|
|
364
364
|
|
|
365
365
|
function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
366
366
|
var _a;
|
|
367
|
-
if (elementOrSelector instanceof
|
|
367
|
+
if (elementOrSelector instanceof EventTarget) {
|
|
368
368
|
return [elementOrSelector];
|
|
369
369
|
}
|
|
370
370
|
else if (typeof elementOrSelector === "string") {
|
|
@@ -539,46 +539,87 @@ function isValidPressEvent(event) {
|
|
|
539
539
|
*
|
|
540
540
|
* @public
|
|
541
541
|
*/
|
|
542
|
-
function press(
|
|
543
|
-
const [
|
|
542
|
+
function press(targetOrSelector, onPressStart, options = {}) {
|
|
543
|
+
const [targets, eventOptions, cancelEvents] = setupGesture(targetOrSelector, options);
|
|
544
544
|
const startPress = (startEvent) => {
|
|
545
|
-
const
|
|
546
|
-
if (!isValidPressEvent(startEvent) || isPressing.has(
|
|
545
|
+
const target = startEvent.currentTarget;
|
|
546
|
+
if (!target || !isValidPressEvent(startEvent) || isPressing.has(target))
|
|
547
547
|
return;
|
|
548
|
-
isPressing.add(
|
|
549
|
-
|
|
548
|
+
isPressing.add(target);
|
|
549
|
+
if (target.setPointerCapture && startEvent.pointerId !== undefined) {
|
|
550
|
+
try {
|
|
551
|
+
target.setPointerCapture(startEvent.pointerId);
|
|
552
|
+
}
|
|
553
|
+
catch (e) { }
|
|
554
|
+
}
|
|
555
|
+
const onPressEnd = onPressStart(target, startEvent);
|
|
550
556
|
const onPointerEnd = (endEvent, success) => {
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
if (
|
|
557
|
+
target.removeEventListener("pointerup", onPointerUp);
|
|
558
|
+
target.removeEventListener("pointercancel", onPointerCancel);
|
|
559
|
+
if (target.releasePointerCapture &&
|
|
560
|
+
endEvent.pointerId !== undefined) {
|
|
561
|
+
try {
|
|
562
|
+
target.releasePointerCapture(endEvent.pointerId);
|
|
563
|
+
}
|
|
564
|
+
catch (e) { }
|
|
565
|
+
}
|
|
566
|
+
if (!isValidPressEvent(endEvent) || !isPressing.has(target)) {
|
|
554
567
|
return;
|
|
555
568
|
}
|
|
556
|
-
isPressing.delete(
|
|
569
|
+
isPressing.delete(target);
|
|
557
570
|
if (typeof onPressEnd === "function") {
|
|
558
571
|
onPressEnd(endEvent, { success });
|
|
559
572
|
}
|
|
560
573
|
};
|
|
561
574
|
const onPointerUp = (upEvent) => {
|
|
562
|
-
|
|
563
|
-
|
|
575
|
+
const isOutside = !upEvent.isTrusted
|
|
576
|
+
? false
|
|
577
|
+
: checkOutside(upEvent, target instanceof Element
|
|
578
|
+
? target.getBoundingClientRect()
|
|
579
|
+
: {
|
|
580
|
+
left: 0,
|
|
581
|
+
top: 0,
|
|
582
|
+
right: window.innerWidth,
|
|
583
|
+
bottom: window.innerHeight,
|
|
584
|
+
});
|
|
585
|
+
if (isOutside) {
|
|
586
|
+
onPointerEnd(upEvent, false);
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
onPointerEnd(upEvent, !(target instanceof Element) ||
|
|
590
|
+
isNodeOrChild(target, upEvent.target));
|
|
591
|
+
}
|
|
564
592
|
};
|
|
565
593
|
const onPointerCancel = (cancelEvent) => {
|
|
566
594
|
onPointerEnd(cancelEvent, false);
|
|
567
595
|
};
|
|
568
|
-
|
|
569
|
-
|
|
596
|
+
target.addEventListener("pointerup", onPointerUp, eventOptions);
|
|
597
|
+
target.addEventListener("pointercancel", onPointerCancel, eventOptions);
|
|
598
|
+
target.addEventListener("lostpointercapture", onPointerCancel, eventOptions);
|
|
570
599
|
};
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
600
|
+
targets.forEach((target) => {
|
|
601
|
+
target = options.useGlobalTarget ? window : target;
|
|
602
|
+
let canAddKeyboardAccessibility = false;
|
|
603
|
+
if (target instanceof HTMLElement) {
|
|
604
|
+
canAddKeyboardAccessibility = true;
|
|
605
|
+
if (!isElementKeyboardAccessible(target) &&
|
|
606
|
+
target.getAttribute("tabindex") === null) {
|
|
607
|
+
target.tabIndex = 0;
|
|
608
|
+
}
|
|
575
609
|
}
|
|
576
|
-
const target = options.useGlobalTarget ? window : element;
|
|
577
610
|
target.addEventListener("pointerdown", startPress, eventOptions);
|
|
578
|
-
|
|
611
|
+
if (canAddKeyboardAccessibility) {
|
|
612
|
+
target.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions), eventOptions);
|
|
613
|
+
}
|
|
579
614
|
});
|
|
580
615
|
return cancelEvents;
|
|
581
616
|
}
|
|
617
|
+
function checkOutside(event, rect) {
|
|
618
|
+
return (event.clientX < rect.left ||
|
|
619
|
+
event.clientX > rect.right ||
|
|
620
|
+
event.clientY < rect.top ||
|
|
621
|
+
event.clientY > rect.bottom);
|
|
622
|
+
}
|
|
582
623
|
|
|
583
624
|
const clamp = (min, max, v) => {
|
|
584
625
|
if (v > max)
|
|
@@ -1586,7 +1627,7 @@ class MotionValue {
|
|
|
1586
1627
|
* This will be replaced by the build step with the latest version number.
|
|
1587
1628
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
1588
1629
|
*/
|
|
1589
|
-
this.version = "12.4.
|
|
1630
|
+
this.version = "12.4.4";
|
|
1590
1631
|
/**
|
|
1591
1632
|
* Tracks whether this value can output a velocity. Currently this is only true
|
|
1592
1633
|
* if the value is numerical, but we might be able to widen the scope here and support
|
|
@@ -4522,7 +4563,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
4522
4563
|
* and warn against mismatches.
|
|
4523
4564
|
*/
|
|
4524
4565
|
if (process.env.NODE_ENV === "development") {
|
|
4525
|
-
warnOnce(nextValue.version === "12.4.
|
|
4566
|
+
warnOnce(nextValue.version === "12.4.4", `Attempting to mix Motion versions ${nextValue.version} with 12.4.4 may not work as expected.`);
|
|
4526
4567
|
}
|
|
4527
4568
|
}
|
|
4528
4569
|
else if (isMotionValue(prevValue)) {
|
package/dist/cjs/mini.js
CHANGED
|
@@ -342,7 +342,7 @@ function mapEasingToNativeEasing(easing, duration) {
|
|
|
342
342
|
|
|
343
343
|
function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
344
344
|
var _a;
|
|
345
|
-
if (elementOrSelector instanceof
|
|
345
|
+
if (elementOrSelector instanceof EventTarget) {
|
|
346
346
|
return [elementOrSelector];
|
|
347
347
|
}
|
|
348
348
|
else if (typeof elementOrSelector === "string") {
|