framer-motion 7.10.3 → 8.0.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.
- package/dist/cjs/index.js +18 -87
- package/dist/es/events/event-info.mjs +6 -34
- package/dist/es/events/use-pointer-event.mjs +2 -31
- package/dist/es/events/utils/is-primary-pointer.mjs +7 -0
- package/dist/es/gestures/PanSession.mjs +2 -7
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +1 -1
- package/dist/es/gestures/use-hover-gesture.mjs +3 -1
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/value/index.mjs +1 -1
- package/dist/framer-motion.dev.js +18 -87
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/projection.dev.js +2 -2
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-motion.js +1 -1
- package/dist/size-webpack-dom-animation.js +1 -1
- package/dist/size-webpack-dom-max.js +1 -1
- package/dist/three-entry.d.ts +2 -2
- package/package.json +7 -7
- package/dist/es/events/utils.mjs +0 -8
- package/dist/es/gestures/utils/event-type.mjs +0 -13
package/dist/cjs/index.js
CHANGED
|
@@ -1368,99 +1368,32 @@ function useFocusGesture({ whileFocus, visualElement, }) {
|
|
|
1368
1368
|
useDomEvent(visualElement, "blur", whileFocus ? onBlur : undefined);
|
|
1369
1369
|
}
|
|
1370
1370
|
|
|
1371
|
-
function isMouseEvent(event) {
|
|
1372
|
-
// PointerEvent inherits from MouseEvent so we can't use a straight instanceof check.
|
|
1373
|
-
if (typeof PointerEvent !== "undefined" && event instanceof PointerEvent) {
|
|
1374
|
-
return !!(event.pointerType === "mouse");
|
|
1375
|
-
}
|
|
1376
|
-
return event instanceof MouseEvent;
|
|
1377
|
-
}
|
|
1378
|
-
function isTouchEvent(event) {
|
|
1379
|
-
const hasTouches = !!event.touches;
|
|
1380
|
-
return hasTouches;
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
1371
|
/**
|
|
1384
|
-
*
|
|
1385
|
-
*
|
|
1372
|
+
* Specifically match against false here as incomplete versions of
|
|
1373
|
+
* PointerEvents in very old browser might have it set as undefined.
|
|
1386
1374
|
*/
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
const isMouseEvent = event instanceof MouseEvent;
|
|
1390
|
-
const isPrimaryPointer = !isMouseEvent ||
|
|
1391
|
-
(isMouseEvent && event.button === 0);
|
|
1392
|
-
if (isPrimaryPointer) {
|
|
1393
|
-
eventHandler(event);
|
|
1394
|
-
}
|
|
1395
|
-
};
|
|
1396
|
-
}
|
|
1397
|
-
const defaultPagePoint = { pageX: 0, pageY: 0 };
|
|
1398
|
-
function pointFromTouch(e, pointType = "page") {
|
|
1399
|
-
const primaryTouch = e.touches[0] || e.changedTouches[0];
|
|
1400
|
-
const point = primaryTouch || defaultPagePoint;
|
|
1401
|
-
return {
|
|
1402
|
-
x: point[pointType + "X"],
|
|
1403
|
-
y: point[pointType + "Y"],
|
|
1404
|
-
};
|
|
1405
|
-
}
|
|
1406
|
-
function pointFromMouse(point, pointType = "page") {
|
|
1407
|
-
return {
|
|
1408
|
-
x: point[pointType + "X"],
|
|
1409
|
-
y: point[pointType + "Y"],
|
|
1410
|
-
};
|
|
1411
|
-
}
|
|
1375
|
+
const isPrimaryPointer = (event) => event.isPrimary !== false;
|
|
1376
|
+
|
|
1412
1377
|
function extractEventInfo(event, pointType = "page") {
|
|
1413
1378
|
return {
|
|
1414
|
-
point:
|
|
1415
|
-
|
|
1416
|
-
:
|
|
1379
|
+
point: {
|
|
1380
|
+
x: event[pointType + "X"],
|
|
1381
|
+
y: event[pointType + "Y"],
|
|
1382
|
+
},
|
|
1417
1383
|
};
|
|
1418
1384
|
}
|
|
1419
1385
|
const wrapHandler = (handler, shouldFilterPrimaryPointer = false) => {
|
|
1420
1386
|
const listener = (event) => handler(event, extractEventInfo(event));
|
|
1421
1387
|
return shouldFilterPrimaryPointer
|
|
1422
|
-
?
|
|
1388
|
+
? (event) => isPrimaryPointer(event) && listener(event)
|
|
1423
1389
|
: listener;
|
|
1424
1390
|
};
|
|
1425
1391
|
|
|
1426
|
-
// We check for event support via functions in case they've been mocked by a testing suite.
|
|
1427
|
-
const supportsPointerEvents = () => isBrowser && window.onpointerdown === null;
|
|
1428
|
-
const supportsTouchEvents = () => isBrowser && window.ontouchstart === null;
|
|
1429
|
-
const supportsMouseEvents = () => isBrowser && window.onmousedown === null;
|
|
1430
|
-
|
|
1431
|
-
const mouseEventNames = {
|
|
1432
|
-
pointerdown: "mousedown",
|
|
1433
|
-
pointermove: "mousemove",
|
|
1434
|
-
pointerup: "mouseup",
|
|
1435
|
-
pointercancel: "mousecancel",
|
|
1436
|
-
pointerover: "mouseover",
|
|
1437
|
-
pointerout: "mouseout",
|
|
1438
|
-
pointerenter: "mouseenter",
|
|
1439
|
-
pointerleave: "mouseleave",
|
|
1440
|
-
};
|
|
1441
|
-
const touchEventNames = {
|
|
1442
|
-
pointerdown: "touchstart",
|
|
1443
|
-
pointermove: "touchmove",
|
|
1444
|
-
pointerup: "touchend",
|
|
1445
|
-
pointercancel: "touchcancel",
|
|
1446
|
-
};
|
|
1447
|
-
function getPointerEventName(name) {
|
|
1448
|
-
if (supportsPointerEvents()) {
|
|
1449
|
-
return name;
|
|
1450
|
-
}
|
|
1451
|
-
else if (supportsTouchEvents()) {
|
|
1452
|
-
return touchEventNames[name];
|
|
1453
|
-
}
|
|
1454
|
-
else if (supportsMouseEvents()) {
|
|
1455
|
-
return mouseEventNames[name];
|
|
1456
|
-
}
|
|
1457
|
-
return name;
|
|
1458
|
-
}
|
|
1459
1392
|
function addPointerEvent(target, eventName, handler, options) {
|
|
1460
|
-
return addDomEvent(target,
|
|
1393
|
+
return addDomEvent(target, eventName, wrapHandler(handler, eventName === "pointerdown"), options);
|
|
1461
1394
|
}
|
|
1462
1395
|
function usePointerEvent(ref, eventName, handler, options) {
|
|
1463
|
-
return useDomEvent(ref,
|
|
1396
|
+
return useDomEvent(ref, eventName, handler && wrapHandler(handler, eventName === "pointerdown"), options);
|
|
1464
1397
|
}
|
|
1465
1398
|
|
|
1466
1399
|
function createLock(name) {
|
|
@@ -1515,6 +1448,9 @@ function isDragActive() {
|
|
|
1515
1448
|
return false;
|
|
1516
1449
|
}
|
|
1517
1450
|
|
|
1451
|
+
function isMouseEvent(event) {
|
|
1452
|
+
return event.type !== "pen" && event.type !== "touch";
|
|
1453
|
+
}
|
|
1518
1454
|
function createHoverEvent(visualElement, isActive, callback) {
|
|
1519
1455
|
return (event, info) => {
|
|
1520
1456
|
if (!isMouseEvent(event) || isDragActive())
|
|
@@ -2129,7 +2065,7 @@ class MotionValue {
|
|
|
2129
2065
|
* This will be replaced by the build step with the latest version number.
|
|
2130
2066
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
2131
2067
|
*/
|
|
2132
|
-
this.version = "
|
|
2068
|
+
this.version = "8.0.0";
|
|
2133
2069
|
/**
|
|
2134
2070
|
* Duration, in milliseconds, since last updating frame.
|
|
2135
2071
|
*
|
|
@@ -4636,11 +4572,6 @@ class PanSession {
|
|
|
4636
4572
|
this.handlePointerMove = (event, info) => {
|
|
4637
4573
|
this.lastMoveEvent = event;
|
|
4638
4574
|
this.lastMoveEventInfo = transformPoint(info, this.transformPagePoint);
|
|
4639
|
-
// Because Safari doesn't trigger mouseup events when it's above a `<select>`
|
|
4640
|
-
if (isMouseEvent(event) && event.buttons === 0) {
|
|
4641
|
-
this.handlePointerUp(event, info);
|
|
4642
|
-
return;
|
|
4643
|
-
}
|
|
4644
4575
|
// Throttle mouse move event to once per frame
|
|
4645
4576
|
sync.update(this.updatePoint, true);
|
|
4646
4577
|
};
|
|
@@ -4654,7 +4585,7 @@ class PanSession {
|
|
|
4654
4585
|
onSessionEnd && onSessionEnd(event, panInfo);
|
|
4655
4586
|
};
|
|
4656
4587
|
// If we have more than one touch, don't start detecting this gesture
|
|
4657
|
-
if (
|
|
4588
|
+
if (!isPrimaryPointer(event))
|
|
4658
4589
|
return;
|
|
4659
4590
|
this.handlers = handlers;
|
|
4660
4591
|
this.transformPagePoint = transformPagePoint;
|
|
@@ -5091,7 +5022,7 @@ const elementDragControls = new WeakMap();
|
|
|
5091
5022
|
/**
|
|
5092
5023
|
*
|
|
5093
5024
|
*/
|
|
5094
|
-
// let latestPointerEvent:
|
|
5025
|
+
// let latestPointerEvent: PointerEvent
|
|
5095
5026
|
class VisualElementDragControls {
|
|
5096
5027
|
constructor(visualElement) {
|
|
5097
5028
|
// This is a reference to the global drag gesture lock, ensuring only one component
|
|
@@ -5937,7 +5868,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
5937
5868
|
* and warn against mismatches.
|
|
5938
5869
|
*/
|
|
5939
5870
|
if (process.env.NODE_ENV === "development") {
|
|
5940
|
-
warnOnce(nextValue.version === "
|
|
5871
|
+
warnOnce(nextValue.version === "8.0.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.0.0 may not work as expected.`);
|
|
5941
5872
|
}
|
|
5942
5873
|
}
|
|
5943
5874
|
else if (isMotionValue(prevValue)) {
|
|
@@ -1,45 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isPrimaryPointer } from './utils/is-primary-pointer.mjs';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Filters out events not attached to the primary pointer (currently left mouse button)
|
|
5
|
-
* @param eventHandler
|
|
6
|
-
*/
|
|
7
|
-
function filterPrimaryPointer(eventHandler) {
|
|
8
|
-
return (event) => {
|
|
9
|
-
const isMouseEvent = event instanceof MouseEvent;
|
|
10
|
-
const isPrimaryPointer = !isMouseEvent ||
|
|
11
|
-
(isMouseEvent && event.button === 0);
|
|
12
|
-
if (isPrimaryPointer) {
|
|
13
|
-
eventHandler(event);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
const defaultPagePoint = { pageX: 0, pageY: 0 };
|
|
18
|
-
function pointFromTouch(e, pointType = "page") {
|
|
19
|
-
const primaryTouch = e.touches[0] || e.changedTouches[0];
|
|
20
|
-
const point = primaryTouch || defaultPagePoint;
|
|
21
|
-
return {
|
|
22
|
-
x: point[pointType + "X"],
|
|
23
|
-
y: point[pointType + "Y"],
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function pointFromMouse(point, pointType = "page") {
|
|
27
|
-
return {
|
|
28
|
-
x: point[pointType + "X"],
|
|
29
|
-
y: point[pointType + "Y"],
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
3
|
function extractEventInfo(event, pointType = "page") {
|
|
33
4
|
return {
|
|
34
|
-
point:
|
|
35
|
-
|
|
36
|
-
:
|
|
5
|
+
point: {
|
|
6
|
+
x: event[pointType + "X"],
|
|
7
|
+
y: event[pointType + "Y"],
|
|
8
|
+
},
|
|
37
9
|
};
|
|
38
10
|
}
|
|
39
11
|
const wrapHandler = (handler, shouldFilterPrimaryPointer = false) => {
|
|
40
12
|
const listener = (event) => handler(event, extractEventInfo(event));
|
|
41
13
|
return shouldFilterPrimaryPointer
|
|
42
|
-
?
|
|
14
|
+
? (event) => isPrimaryPointer(event) && listener(event)
|
|
43
15
|
: listener;
|
|
44
16
|
};
|
|
45
17
|
|
|
@@ -1,40 +1,11 @@
|
|
|
1
1
|
import { addDomEvent, useDomEvent } from './use-dom-event.mjs';
|
|
2
2
|
import { wrapHandler } from './event-info.mjs';
|
|
3
|
-
import { supportsPointerEvents, supportsTouchEvents, supportsMouseEvents } from './utils.mjs';
|
|
4
3
|
|
|
5
|
-
const mouseEventNames = {
|
|
6
|
-
pointerdown: "mousedown",
|
|
7
|
-
pointermove: "mousemove",
|
|
8
|
-
pointerup: "mouseup",
|
|
9
|
-
pointercancel: "mousecancel",
|
|
10
|
-
pointerover: "mouseover",
|
|
11
|
-
pointerout: "mouseout",
|
|
12
|
-
pointerenter: "mouseenter",
|
|
13
|
-
pointerleave: "mouseleave",
|
|
14
|
-
};
|
|
15
|
-
const touchEventNames = {
|
|
16
|
-
pointerdown: "touchstart",
|
|
17
|
-
pointermove: "touchmove",
|
|
18
|
-
pointerup: "touchend",
|
|
19
|
-
pointercancel: "touchcancel",
|
|
20
|
-
};
|
|
21
|
-
function getPointerEventName(name) {
|
|
22
|
-
if (supportsPointerEvents()) {
|
|
23
|
-
return name;
|
|
24
|
-
}
|
|
25
|
-
else if (supportsTouchEvents()) {
|
|
26
|
-
return touchEventNames[name];
|
|
27
|
-
}
|
|
28
|
-
else if (supportsMouseEvents()) {
|
|
29
|
-
return mouseEventNames[name];
|
|
30
|
-
}
|
|
31
|
-
return name;
|
|
32
|
-
}
|
|
33
4
|
function addPointerEvent(target, eventName, handler, options) {
|
|
34
|
-
return addDomEvent(target,
|
|
5
|
+
return addDomEvent(target, eventName, wrapHandler(handler, eventName === "pointerdown"), options);
|
|
35
6
|
}
|
|
36
7
|
function usePointerEvent(ref, eventName, handler, options) {
|
|
37
|
-
return useDomEvent(ref,
|
|
8
|
+
return useDomEvent(ref, eventName, handler && wrapHandler(handler, eventName === "pointerdown"), options);
|
|
38
9
|
}
|
|
39
10
|
|
|
40
11
|
export { addPointerEvent, usePointerEvent };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isMouseEvent, isTouchEvent } from './utils/event-type.mjs';
|
|
2
1
|
import { extractEventInfo } from '../events/event-info.mjs';
|
|
3
2
|
import { sync, cancelSync } from '../frameloop/index.mjs';
|
|
4
3
|
import { secondsToMilliseconds } from '../utils/time-conversion.mjs';
|
|
@@ -6,6 +5,7 @@ import { addPointerEvent } from '../events/use-pointer-event.mjs';
|
|
|
6
5
|
import { pipe } from '../utils/pipe.mjs';
|
|
7
6
|
import { distance2D } from '../utils/distance.mjs';
|
|
8
7
|
import { frameData } from '../frameloop/data.mjs';
|
|
8
|
+
import { isPrimaryPointer } from '../events/utils/is-primary-pointer.mjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @internal
|
|
@@ -52,11 +52,6 @@ class PanSession {
|
|
|
52
52
|
this.handlePointerMove = (event, info) => {
|
|
53
53
|
this.lastMoveEvent = event;
|
|
54
54
|
this.lastMoveEventInfo = transformPoint(info, this.transformPagePoint);
|
|
55
|
-
// Because Safari doesn't trigger mouseup events when it's above a `<select>`
|
|
56
|
-
if (isMouseEvent(event) && event.buttons === 0) {
|
|
57
|
-
this.handlePointerUp(event, info);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
55
|
// Throttle mouse move event to once per frame
|
|
61
56
|
sync.update(this.updatePoint, true);
|
|
62
57
|
};
|
|
@@ -70,7 +65,7 @@ class PanSession {
|
|
|
70
65
|
onSessionEnd && onSessionEnd(event, panInfo);
|
|
71
66
|
};
|
|
72
67
|
// If we have more than one touch, don't start detecting this gesture
|
|
73
|
-
if (
|
|
68
|
+
if (!isPrimaryPointer(event))
|
|
74
69
|
return;
|
|
75
70
|
this.handlers = handlers;
|
|
76
71
|
this.transformPagePoint = transformPagePoint;
|
|
@@ -20,7 +20,7 @@ const elementDragControls = new WeakMap();
|
|
|
20
20
|
/**
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
// let latestPointerEvent:
|
|
23
|
+
// let latestPointerEvent: PointerEvent
|
|
24
24
|
class VisualElementDragControls {
|
|
25
25
|
constructor(visualElement) {
|
|
26
26
|
// This is a reference to the global drag gesture lock, ensuring only one component
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { isMouseEvent } from './utils/event-type.mjs';
|
|
2
1
|
import { AnimationType } from '../render/utils/types.mjs';
|
|
3
2
|
import { usePointerEvent } from '../events/use-pointer-event.mjs';
|
|
4
3
|
import { isDragActive } from './drag/utils/lock.mjs';
|
|
5
4
|
|
|
5
|
+
function isMouseEvent(event) {
|
|
6
|
+
return event.type !== "pen" && event.type !== "touch";
|
|
7
|
+
}
|
|
6
8
|
function createHoverEvent(visualElement, isActive, callback) {
|
|
7
9
|
return (event, info) => {
|
|
8
10
|
if (!isMouseEvent(event) || isDragActive())
|
|
@@ -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 === "
|
|
25
|
+
warnOnce(nextValue.version === "8.0.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.0.0 may not work as expected.`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
else if (isMotionValue(prevValue)) {
|
package/dist/es/value/index.mjs
CHANGED
|
@@ -25,7 +25,7 @@ class MotionValue {
|
|
|
25
25
|
* This will be replaced by the build step with the latest version number.
|
|
26
26
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
27
27
|
*/
|
|
28
|
-
this.version = "
|
|
28
|
+
this.version = "8.0.0";
|
|
29
29
|
/**
|
|
30
30
|
* Duration, in milliseconds, since last updating frame.
|
|
31
31
|
*
|
|
@@ -1366,99 +1366,32 @@
|
|
|
1366
1366
|
useDomEvent(visualElement, "blur", whileFocus ? onBlur : undefined);
|
|
1367
1367
|
}
|
|
1368
1368
|
|
|
1369
|
-
function isMouseEvent(event) {
|
|
1370
|
-
// PointerEvent inherits from MouseEvent so we can't use a straight instanceof check.
|
|
1371
|
-
if (typeof PointerEvent !== "undefined" && event instanceof PointerEvent) {
|
|
1372
|
-
return !!(event.pointerType === "mouse");
|
|
1373
|
-
}
|
|
1374
|
-
return event instanceof MouseEvent;
|
|
1375
|
-
}
|
|
1376
|
-
function isTouchEvent(event) {
|
|
1377
|
-
const hasTouches = !!event.touches;
|
|
1378
|
-
return hasTouches;
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
1369
|
/**
|
|
1382
|
-
*
|
|
1383
|
-
*
|
|
1370
|
+
* Specifically match against false here as incomplete versions of
|
|
1371
|
+
* PointerEvents in very old browser might have it set as undefined.
|
|
1384
1372
|
*/
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
const isMouseEvent = event instanceof MouseEvent;
|
|
1388
|
-
const isPrimaryPointer = !isMouseEvent ||
|
|
1389
|
-
(isMouseEvent && event.button === 0);
|
|
1390
|
-
if (isPrimaryPointer) {
|
|
1391
|
-
eventHandler(event);
|
|
1392
|
-
}
|
|
1393
|
-
};
|
|
1394
|
-
}
|
|
1395
|
-
const defaultPagePoint = { pageX: 0, pageY: 0 };
|
|
1396
|
-
function pointFromTouch(e, pointType = "page") {
|
|
1397
|
-
const primaryTouch = e.touches[0] || e.changedTouches[0];
|
|
1398
|
-
const point = primaryTouch || defaultPagePoint;
|
|
1399
|
-
return {
|
|
1400
|
-
x: point[pointType + "X"],
|
|
1401
|
-
y: point[pointType + "Y"],
|
|
1402
|
-
};
|
|
1403
|
-
}
|
|
1404
|
-
function pointFromMouse(point, pointType = "page") {
|
|
1405
|
-
return {
|
|
1406
|
-
x: point[pointType + "X"],
|
|
1407
|
-
y: point[pointType + "Y"],
|
|
1408
|
-
};
|
|
1409
|
-
}
|
|
1373
|
+
const isPrimaryPointer = (event) => event.isPrimary !== false;
|
|
1374
|
+
|
|
1410
1375
|
function extractEventInfo(event, pointType = "page") {
|
|
1411
1376
|
return {
|
|
1412
|
-
point:
|
|
1413
|
-
|
|
1414
|
-
:
|
|
1377
|
+
point: {
|
|
1378
|
+
x: event[pointType + "X"],
|
|
1379
|
+
y: event[pointType + "Y"],
|
|
1380
|
+
},
|
|
1415
1381
|
};
|
|
1416
1382
|
}
|
|
1417
1383
|
const wrapHandler = (handler, shouldFilterPrimaryPointer = false) => {
|
|
1418
1384
|
const listener = (event) => handler(event, extractEventInfo(event));
|
|
1419
1385
|
return shouldFilterPrimaryPointer
|
|
1420
|
-
?
|
|
1386
|
+
? (event) => isPrimaryPointer(event) && listener(event)
|
|
1421
1387
|
: listener;
|
|
1422
1388
|
};
|
|
1423
1389
|
|
|
1424
|
-
// We check for event support via functions in case they've been mocked by a testing suite.
|
|
1425
|
-
const supportsPointerEvents = () => isBrowser && window.onpointerdown === null;
|
|
1426
|
-
const supportsTouchEvents = () => isBrowser && window.ontouchstart === null;
|
|
1427
|
-
const supportsMouseEvents = () => isBrowser && window.onmousedown === null;
|
|
1428
|
-
|
|
1429
|
-
const mouseEventNames = {
|
|
1430
|
-
pointerdown: "mousedown",
|
|
1431
|
-
pointermove: "mousemove",
|
|
1432
|
-
pointerup: "mouseup",
|
|
1433
|
-
pointercancel: "mousecancel",
|
|
1434
|
-
pointerover: "mouseover",
|
|
1435
|
-
pointerout: "mouseout",
|
|
1436
|
-
pointerenter: "mouseenter",
|
|
1437
|
-
pointerleave: "mouseleave",
|
|
1438
|
-
};
|
|
1439
|
-
const touchEventNames = {
|
|
1440
|
-
pointerdown: "touchstart",
|
|
1441
|
-
pointermove: "touchmove",
|
|
1442
|
-
pointerup: "touchend",
|
|
1443
|
-
pointercancel: "touchcancel",
|
|
1444
|
-
};
|
|
1445
|
-
function getPointerEventName(name) {
|
|
1446
|
-
if (supportsPointerEvents()) {
|
|
1447
|
-
return name;
|
|
1448
|
-
}
|
|
1449
|
-
else if (supportsTouchEvents()) {
|
|
1450
|
-
return touchEventNames[name];
|
|
1451
|
-
}
|
|
1452
|
-
else if (supportsMouseEvents()) {
|
|
1453
|
-
return mouseEventNames[name];
|
|
1454
|
-
}
|
|
1455
|
-
return name;
|
|
1456
|
-
}
|
|
1457
1390
|
function addPointerEvent(target, eventName, handler, options) {
|
|
1458
|
-
return addDomEvent(target,
|
|
1391
|
+
return addDomEvent(target, eventName, wrapHandler(handler, eventName === "pointerdown"), options);
|
|
1459
1392
|
}
|
|
1460
1393
|
function usePointerEvent(ref, eventName, handler, options) {
|
|
1461
|
-
return useDomEvent(ref,
|
|
1394
|
+
return useDomEvent(ref, eventName, handler && wrapHandler(handler, eventName === "pointerdown"), options);
|
|
1462
1395
|
}
|
|
1463
1396
|
|
|
1464
1397
|
function createLock(name) {
|
|
@@ -1513,6 +1446,9 @@
|
|
|
1513
1446
|
return false;
|
|
1514
1447
|
}
|
|
1515
1448
|
|
|
1449
|
+
function isMouseEvent(event) {
|
|
1450
|
+
return event.type !== "pen" && event.type !== "touch";
|
|
1451
|
+
}
|
|
1516
1452
|
function createHoverEvent(visualElement, isActive, callback) {
|
|
1517
1453
|
return (event, info) => {
|
|
1518
1454
|
if (!isMouseEvent(event) || isDragActive())
|
|
@@ -2127,7 +2063,7 @@
|
|
|
2127
2063
|
* This will be replaced by the build step with the latest version number.
|
|
2128
2064
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
2129
2065
|
*/
|
|
2130
|
-
this.version = "
|
|
2066
|
+
this.version = "8.0.0";
|
|
2131
2067
|
/**
|
|
2132
2068
|
* Duration, in milliseconds, since last updating frame.
|
|
2133
2069
|
*
|
|
@@ -4649,11 +4585,6 @@
|
|
|
4649
4585
|
this.handlePointerMove = (event, info) => {
|
|
4650
4586
|
this.lastMoveEvent = event;
|
|
4651
4587
|
this.lastMoveEventInfo = transformPoint(info, this.transformPagePoint);
|
|
4652
|
-
// Because Safari doesn't trigger mouseup events when it's above a `<select>`
|
|
4653
|
-
if (isMouseEvent(event) && event.buttons === 0) {
|
|
4654
|
-
this.handlePointerUp(event, info);
|
|
4655
|
-
return;
|
|
4656
|
-
}
|
|
4657
4588
|
// Throttle mouse move event to once per frame
|
|
4658
4589
|
sync.update(this.updatePoint, true);
|
|
4659
4590
|
};
|
|
@@ -4667,7 +4598,7 @@
|
|
|
4667
4598
|
onSessionEnd && onSessionEnd(event, panInfo);
|
|
4668
4599
|
};
|
|
4669
4600
|
// If we have more than one touch, don't start detecting this gesture
|
|
4670
|
-
if (
|
|
4601
|
+
if (!isPrimaryPointer(event))
|
|
4671
4602
|
return;
|
|
4672
4603
|
this.handlers = handlers;
|
|
4673
4604
|
this.transformPagePoint = transformPagePoint;
|
|
@@ -5104,7 +5035,7 @@
|
|
|
5104
5035
|
/**
|
|
5105
5036
|
*
|
|
5106
5037
|
*/
|
|
5107
|
-
// let latestPointerEvent:
|
|
5038
|
+
// let latestPointerEvent: PointerEvent
|
|
5108
5039
|
class VisualElementDragControls {
|
|
5109
5040
|
constructor(visualElement) {
|
|
5110
5041
|
// This is a reference to the global drag gesture lock, ensuring only one component
|
|
@@ -5950,7 +5881,7 @@
|
|
|
5950
5881
|
* and warn against mismatches.
|
|
5951
5882
|
*/
|
|
5952
5883
|
{
|
|
5953
|
-
warnOnce(nextValue.version === "
|
|
5884
|
+
warnOnce(nextValue.version === "8.0.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.0.0 may not work as expected.`);
|
|
5954
5885
|
}
|
|
5955
5886
|
}
|
|
5956
5887
|
else if (isMotionValue(prevValue)) {
|