framer-motion 6.3.5 → 6.3.6
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 +16 -12
- package/dist/es/events/use-dom-event.mjs +2 -1
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +1 -1
- package/dist/es/gestures/use-hover-gesture.mjs +2 -2
- package/dist/es/gestures/use-tap-gesture.mjs +8 -2
- package/dist/es/projection/node/DocumentProjectionNode.mjs +2 -4
- package/dist/es/value/scroll/use-element-scroll.mjs +1 -1
- package/dist/es/value/scroll/use-viewport-scroll.mjs +1 -1
- package/dist/framer-motion.dev.js +16 -12
- package/dist/framer-motion.js +1 -1
- package/dist/projection.dev.js +9 -6
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-webpack-dom-animation.js +1 -1
- package/dist/size-webpack-dom-max.js +1 -1
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -3884,8 +3884,9 @@ exports.AnimationType = void 0;
|
|
|
3884
3884
|
})(exports.AnimationType || (exports.AnimationType = {}));
|
|
3885
3885
|
|
|
3886
3886
|
function addDomEvent(target, eventName, handler, options) {
|
|
3887
|
+
if (options === void 0) { options = { passive: true }; }
|
|
3887
3888
|
target.addEventListener(eventName, handler, options);
|
|
3888
|
-
return function () { return target.removeEventListener(eventName, handler
|
|
3889
|
+
return function () { return target.removeEventListener(eventName, handler); };
|
|
3889
3890
|
}
|
|
3890
3891
|
/**
|
|
3891
3892
|
* Attaches an event listener directly to the provided DOM element.
|
|
@@ -4112,10 +4113,10 @@ function useHoverGesture(_a) {
|
|
|
4112
4113
|
var onHoverStart = _a.onHoverStart, onHoverEnd = _a.onHoverEnd, whileHover = _a.whileHover, visualElement = _a.visualElement;
|
|
4113
4114
|
usePointerEvent(visualElement, "pointerenter", onHoverStart || whileHover
|
|
4114
4115
|
? createHoverEvent(visualElement, true, onHoverStart)
|
|
4115
|
-
: undefined);
|
|
4116
|
+
: undefined, { passive: !onHoverStart });
|
|
4116
4117
|
usePointerEvent(visualElement, "pointerleave", onHoverEnd || whileHover
|
|
4117
4118
|
? createHoverEvent(visualElement, false, onHoverEnd)
|
|
4118
|
-
: undefined);
|
|
4119
|
+
: undefined, { passive: !onHoverEnd });
|
|
4119
4120
|
}
|
|
4120
4121
|
|
|
4121
4122
|
/**
|
|
@@ -4150,6 +4151,12 @@ function useTapGesture(_a) {
|
|
|
4150
4151
|
var hasPressListeners = onTap || onTapStart || onTapCancel || whileTap;
|
|
4151
4152
|
var isPressing = React.useRef(false);
|
|
4152
4153
|
var cancelPointerEndListeners = React.useRef(null);
|
|
4154
|
+
/**
|
|
4155
|
+
* Only set listener to passive if there are no external listeners.
|
|
4156
|
+
*/
|
|
4157
|
+
var eventOptions = {
|
|
4158
|
+
passive: !(onTapStart || onTap || onTapCancel || onPointerDown),
|
|
4159
|
+
};
|
|
4153
4160
|
function removePointerEndListener() {
|
|
4154
4161
|
var _a;
|
|
4155
4162
|
(_a = cancelPointerEndListeners.current) === null || _a === void 0 ? void 0 : _a.call(cancelPointerEndListeners);
|
|
@@ -4184,14 +4191,14 @@ function useTapGesture(_a) {
|
|
|
4184
4191
|
if (isPressing.current)
|
|
4185
4192
|
return;
|
|
4186
4193
|
isPressing.current = true;
|
|
4187
|
-
cancelPointerEndListeners.current = popmotion.pipe(addPointerEvent(window, "pointerup", onPointerUp), addPointerEvent(window, "pointercancel", onPointerCancel));
|
|
4194
|
+
cancelPointerEndListeners.current = popmotion.pipe(addPointerEvent(window, "pointerup", onPointerUp, eventOptions), addPointerEvent(window, "pointercancel", onPointerCancel, eventOptions));
|
|
4188
4195
|
/**
|
|
4189
4196
|
* Ensure we trigger animations before firing event callback
|
|
4190
4197
|
*/
|
|
4191
4198
|
(_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(exports.AnimationType.Tap, true);
|
|
4192
4199
|
onTapStart === null || onTapStart === void 0 ? void 0 : onTapStart(event, info);
|
|
4193
4200
|
}
|
|
4194
|
-
usePointerEvent(visualElement, "pointerdown", hasPressListeners ? onPointerDown : undefined);
|
|
4201
|
+
usePointerEvent(visualElement, "pointerdown", hasPressListeners ? onPointerDown : undefined, eventOptions);
|
|
4195
4202
|
useUnmountEffect(removePointerEndListener);
|
|
4196
4203
|
}
|
|
4197
4204
|
|
|
@@ -5783,7 +5790,7 @@ var VisualElementDragControls = /** @class */ (function () {
|
|
|
5783
5790
|
* constraints as the window resizes.
|
|
5784
5791
|
*/
|
|
5785
5792
|
var stopResizeListener = addDomEvent(window, "resize", function () {
|
|
5786
|
-
_this.scalePositionWithinConstraints();
|
|
5793
|
+
return _this.scalePositionWithinConstraints();
|
|
5787
5794
|
});
|
|
5788
5795
|
/**
|
|
5789
5796
|
* If the element's layout changes, calculate the delta and apply that to
|
|
@@ -7056,10 +7063,7 @@ var layoutFeatures = {
|
|
|
7056
7063
|
};
|
|
7057
7064
|
|
|
7058
7065
|
var DocumentProjectionNode = createProjectionNode({
|
|
7059
|
-
attachResizeListener: function (ref, notify) {
|
|
7060
|
-
ref.addEventListener("resize", notify, { passive: true });
|
|
7061
|
-
return function () { return ref.removeEventListener("resize", notify); };
|
|
7062
|
-
},
|
|
7066
|
+
attachResizeListener: function (ref, notify) { return addDomEvent(ref, "resize", notify); },
|
|
7063
7067
|
measureScroll: function () { return ({
|
|
7064
7068
|
x: document.documentElement.scrollLeft || document.body.scrollLeft,
|
|
7065
7069
|
y: document.documentElement.scrollTop || document.body.scrollTop,
|
|
@@ -7915,7 +7919,7 @@ function useElementScroll(ref) {
|
|
|
7915
7919
|
if (!element)
|
|
7916
7920
|
return;
|
|
7917
7921
|
var updateScrollValues = createScrollUpdater(values, getElementScrollOffsets(element));
|
|
7918
|
-
var scrollListener = addDomEvent(element, "scroll", updateScrollValues
|
|
7922
|
+
var scrollListener = addDomEvent(element, "scroll", updateScrollValues);
|
|
7919
7923
|
var resizeListener = addDomEvent(element, "resize", updateScrollValues);
|
|
7920
7924
|
return function () {
|
|
7921
7925
|
scrollListener && scrollListener();
|
|
@@ -7938,7 +7942,7 @@ var hasListeners = false;
|
|
|
7938
7942
|
function addEventListeners() {
|
|
7939
7943
|
hasListeners = true;
|
|
7940
7944
|
var updateScrollValues = createScrollUpdater(viewportScrollValues, getViewportScrollOffsets);
|
|
7941
|
-
addDomEvent(window, "scroll", updateScrollValues
|
|
7945
|
+
addDomEvent(window, "scroll", updateScrollValues);
|
|
7942
7946
|
addDomEvent(window, "resize", updateScrollValues);
|
|
7943
7947
|
}
|
|
7944
7948
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
function addDomEvent(target, eventName, handler, options) {
|
|
4
|
+
if (options === void 0) { options = { passive: true }; }
|
|
4
5
|
target.addEventListener(eventName, handler, options);
|
|
5
|
-
return function () { return target.removeEventListener(eventName, handler
|
|
6
|
+
return function () { return target.removeEventListener(eventName, handler); };
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* Attaches an event listener directly to the provided DOM element.
|
|
@@ -388,7 +388,7 @@ var VisualElementDragControls = /** @class */ (function () {
|
|
|
388
388
|
* constraints as the window resizes.
|
|
389
389
|
*/
|
|
390
390
|
var stopResizeListener = addDomEvent(window, "resize", function () {
|
|
391
|
-
_this.scalePositionWithinConstraints();
|
|
391
|
+
return _this.scalePositionWithinConstraints();
|
|
392
392
|
});
|
|
393
393
|
/**
|
|
394
394
|
* If the element's layout changes, calculate the delta and apply that to
|
|
@@ -19,10 +19,10 @@ function useHoverGesture(_a) {
|
|
|
19
19
|
var onHoverStart = _a.onHoverStart, onHoverEnd = _a.onHoverEnd, whileHover = _a.whileHover, visualElement = _a.visualElement;
|
|
20
20
|
usePointerEvent(visualElement, "pointerenter", onHoverStart || whileHover
|
|
21
21
|
? createHoverEvent(visualElement, true, onHoverStart)
|
|
22
|
-
: undefined);
|
|
22
|
+
: undefined, { passive: !onHoverStart });
|
|
23
23
|
usePointerEvent(visualElement, "pointerleave", onHoverEnd || whileHover
|
|
24
24
|
? createHoverEvent(visualElement, false, onHoverEnd)
|
|
25
|
-
: undefined);
|
|
25
|
+
: undefined, { passive: !onHoverEnd });
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export { useHoverGesture };
|
|
@@ -15,6 +15,12 @@ function useTapGesture(_a) {
|
|
|
15
15
|
var hasPressListeners = onTap || onTapStart || onTapCancel || whileTap;
|
|
16
16
|
var isPressing = useRef(false);
|
|
17
17
|
var cancelPointerEndListeners = useRef(null);
|
|
18
|
+
/**
|
|
19
|
+
* Only set listener to passive if there are no external listeners.
|
|
20
|
+
*/
|
|
21
|
+
var eventOptions = {
|
|
22
|
+
passive: !(onTapStart || onTap || onTapCancel || onPointerDown),
|
|
23
|
+
};
|
|
18
24
|
function removePointerEndListener() {
|
|
19
25
|
var _a;
|
|
20
26
|
(_a = cancelPointerEndListeners.current) === null || _a === void 0 ? void 0 : _a.call(cancelPointerEndListeners);
|
|
@@ -49,14 +55,14 @@ function useTapGesture(_a) {
|
|
|
49
55
|
if (isPressing.current)
|
|
50
56
|
return;
|
|
51
57
|
isPressing.current = true;
|
|
52
|
-
cancelPointerEndListeners.current = pipe(addPointerEvent(window, "pointerup", onPointerUp), addPointerEvent(window, "pointercancel", onPointerCancel));
|
|
58
|
+
cancelPointerEndListeners.current = pipe(addPointerEvent(window, "pointerup", onPointerUp, eventOptions), addPointerEvent(window, "pointercancel", onPointerCancel, eventOptions));
|
|
53
59
|
/**
|
|
54
60
|
* Ensure we trigger animations before firing event callback
|
|
55
61
|
*/
|
|
56
62
|
(_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.Tap, true);
|
|
57
63
|
onTapStart === null || onTapStart === void 0 ? void 0 : onTapStart(event, info);
|
|
58
64
|
}
|
|
59
|
-
usePointerEvent(visualElement, "pointerdown", hasPressListeners ? onPointerDown : undefined);
|
|
65
|
+
usePointerEvent(visualElement, "pointerdown", hasPressListeners ? onPointerDown : undefined, eventOptions);
|
|
60
66
|
useUnmountEffect(removePointerEndListener);
|
|
61
67
|
}
|
|
62
68
|
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { createProjectionNode } from './create-projection-node.mjs';
|
|
2
|
+
import { addDomEvent } from '../../events/use-dom-event.mjs';
|
|
2
3
|
|
|
3
4
|
var DocumentProjectionNode = createProjectionNode({
|
|
4
|
-
attachResizeListener: function (ref, notify) {
|
|
5
|
-
ref.addEventListener("resize", notify, { passive: true });
|
|
6
|
-
return function () { return ref.removeEventListener("resize", notify); };
|
|
7
|
-
},
|
|
5
|
+
attachResizeListener: function (ref, notify) { return addDomEvent(ref, "resize", notify); },
|
|
8
6
|
measureScroll: function () { return ({
|
|
9
7
|
x: document.documentElement.scrollLeft || document.body.scrollLeft,
|
|
10
8
|
y: document.documentElement.scrollTop || document.body.scrollTop,
|
|
@@ -45,7 +45,7 @@ function useElementScroll(ref) {
|
|
|
45
45
|
if (!element)
|
|
46
46
|
return;
|
|
47
47
|
var updateScrollValues = createScrollUpdater(values, getElementScrollOffsets(element));
|
|
48
|
-
var scrollListener = addDomEvent(element, "scroll", updateScrollValues
|
|
48
|
+
var scrollListener = addDomEvent(element, "scroll", updateScrollValues);
|
|
49
49
|
var resizeListener = addDomEvent(element, "resize", updateScrollValues);
|
|
50
50
|
return function () {
|
|
51
51
|
scrollListener && scrollListener();
|
|
@@ -15,7 +15,7 @@ var hasListeners = false;
|
|
|
15
15
|
function addEventListeners() {
|
|
16
16
|
hasListeners = true;
|
|
17
17
|
var updateScrollValues = createScrollUpdater(viewportScrollValues, getViewportScrollOffsets);
|
|
18
|
-
addDomEvent(window, "scroll", updateScrollValues
|
|
18
|
+
addDomEvent(window, "scroll", updateScrollValues);
|
|
19
19
|
addDomEvent(window, "resize", updateScrollValues);
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
@@ -5109,8 +5109,9 @@
|
|
|
5109
5109
|
})(exports.AnimationType || (exports.AnimationType = {}));
|
|
5110
5110
|
|
|
5111
5111
|
function addDomEvent(target, eventName, handler, options) {
|
|
5112
|
+
if (options === void 0) { options = { passive: true }; }
|
|
5112
5113
|
target.addEventListener(eventName, handler, options);
|
|
5113
|
-
return function () { return target.removeEventListener(eventName, handler
|
|
5114
|
+
return function () { return target.removeEventListener(eventName, handler); };
|
|
5114
5115
|
}
|
|
5115
5116
|
/**
|
|
5116
5117
|
* Attaches an event listener directly to the provided DOM element.
|
|
@@ -5337,10 +5338,10 @@
|
|
|
5337
5338
|
var onHoverStart = _a.onHoverStart, onHoverEnd = _a.onHoverEnd, whileHover = _a.whileHover, visualElement = _a.visualElement;
|
|
5338
5339
|
usePointerEvent(visualElement, "pointerenter", onHoverStart || whileHover
|
|
5339
5340
|
? createHoverEvent(visualElement, true, onHoverStart)
|
|
5340
|
-
: undefined);
|
|
5341
|
+
: undefined, { passive: !onHoverStart });
|
|
5341
5342
|
usePointerEvent(visualElement, "pointerleave", onHoverEnd || whileHover
|
|
5342
5343
|
? createHoverEvent(visualElement, false, onHoverEnd)
|
|
5343
|
-
: undefined);
|
|
5344
|
+
: undefined, { passive: !onHoverEnd });
|
|
5344
5345
|
}
|
|
5345
5346
|
|
|
5346
5347
|
/**
|
|
@@ -5375,6 +5376,12 @@
|
|
|
5375
5376
|
var hasPressListeners = onTap || onTapStart || onTapCancel || whileTap;
|
|
5376
5377
|
var isPressing = React.useRef(false);
|
|
5377
5378
|
var cancelPointerEndListeners = React.useRef(null);
|
|
5379
|
+
/**
|
|
5380
|
+
* Only set listener to passive if there are no external listeners.
|
|
5381
|
+
*/
|
|
5382
|
+
var eventOptions = {
|
|
5383
|
+
passive: !(onTapStart || onTap || onTapCancel || onPointerDown),
|
|
5384
|
+
};
|
|
5378
5385
|
function removePointerEndListener() {
|
|
5379
5386
|
var _a;
|
|
5380
5387
|
(_a = cancelPointerEndListeners.current) === null || _a === void 0 ? void 0 : _a.call(cancelPointerEndListeners);
|
|
@@ -5409,14 +5416,14 @@
|
|
|
5409
5416
|
if (isPressing.current)
|
|
5410
5417
|
return;
|
|
5411
5418
|
isPressing.current = true;
|
|
5412
|
-
cancelPointerEndListeners.current = pipe(addPointerEvent(window, "pointerup", onPointerUp), addPointerEvent(window, "pointercancel", onPointerCancel));
|
|
5419
|
+
cancelPointerEndListeners.current = pipe(addPointerEvent(window, "pointerup", onPointerUp, eventOptions), addPointerEvent(window, "pointercancel", onPointerCancel, eventOptions));
|
|
5413
5420
|
/**
|
|
5414
5421
|
* Ensure we trigger animations before firing event callback
|
|
5415
5422
|
*/
|
|
5416
5423
|
(_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(exports.AnimationType.Tap, true);
|
|
5417
5424
|
onTapStart === null || onTapStart === void 0 ? void 0 : onTapStart(event, info);
|
|
5418
5425
|
}
|
|
5419
|
-
usePointerEvent(visualElement, "pointerdown", hasPressListeners ? onPointerDown : undefined);
|
|
5426
|
+
usePointerEvent(visualElement, "pointerdown", hasPressListeners ? onPointerDown : undefined, eventOptions);
|
|
5420
5427
|
useUnmountEffect(removePointerEndListener);
|
|
5421
5428
|
}
|
|
5422
5429
|
|
|
@@ -7008,7 +7015,7 @@
|
|
|
7008
7015
|
* constraints as the window resizes.
|
|
7009
7016
|
*/
|
|
7010
7017
|
var stopResizeListener = addDomEvent(window, "resize", function () {
|
|
7011
|
-
_this.scalePositionWithinConstraints();
|
|
7018
|
+
return _this.scalePositionWithinConstraints();
|
|
7012
7019
|
});
|
|
7013
7020
|
/**
|
|
7014
7021
|
* If the element's layout changes, calculate the delta and apply that to
|
|
@@ -8281,10 +8288,7 @@
|
|
|
8281
8288
|
};
|
|
8282
8289
|
|
|
8283
8290
|
var DocumentProjectionNode = createProjectionNode({
|
|
8284
|
-
attachResizeListener: function (ref, notify) {
|
|
8285
|
-
ref.addEventListener("resize", notify, { passive: true });
|
|
8286
|
-
return function () { return ref.removeEventListener("resize", notify); };
|
|
8287
|
-
},
|
|
8291
|
+
attachResizeListener: function (ref, notify) { return addDomEvent(ref, "resize", notify); },
|
|
8288
8292
|
measureScroll: function () { return ({
|
|
8289
8293
|
x: document.documentElement.scrollLeft || document.body.scrollLeft,
|
|
8290
8294
|
y: document.documentElement.scrollTop || document.body.scrollTop,
|
|
@@ -9139,7 +9143,7 @@
|
|
|
9139
9143
|
if (!element)
|
|
9140
9144
|
return;
|
|
9141
9145
|
var updateScrollValues = createScrollUpdater(values, getElementScrollOffsets(element));
|
|
9142
|
-
var scrollListener = addDomEvent(element, "scroll", updateScrollValues
|
|
9146
|
+
var scrollListener = addDomEvent(element, "scroll", updateScrollValues);
|
|
9143
9147
|
var resizeListener = addDomEvent(element, "resize", updateScrollValues);
|
|
9144
9148
|
return function () {
|
|
9145
9149
|
scrollListener && scrollListener();
|
|
@@ -9162,7 +9166,7 @@
|
|
|
9162
9166
|
function addEventListeners() {
|
|
9163
9167
|
hasListeners = true;
|
|
9164
9168
|
var updateScrollValues = createScrollUpdater(viewportScrollValues, getViewportScrollOffsets);
|
|
9165
|
-
addDomEvent(window, "scroll", updateScrollValues
|
|
9169
|
+
addDomEvent(window, "scroll", updateScrollValues);
|
|
9166
9170
|
addDomEvent(window, "resize", updateScrollValues);
|
|
9167
9171
|
}
|
|
9168
9172
|
/**
|