framer-motion 5.3.1 → 5.3.2
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/es/motion/features/viewport/use-viewport.mjs +2 -2
- package/dist/es/render/html/use-props.mjs +5 -3
- package/dist/es/utils/use-force-update.mjs +13 -9
- package/dist/framer-motion.cjs.js +18 -13
- package/dist/framer-motion.dev.js +18 -13
- package/dist/framer-motion.js +1 -1
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-m.js +1 -1
- package/package.json +1 -1
- package/types/motion/features/viewport/types.d.ts +1 -1
|
@@ -59,7 +59,7 @@ function useIntersectionObserver(shouldObserve, state, visualElement, _a) {
|
|
|
59
59
|
var callback = isIntersecting
|
|
60
60
|
? props.onViewportEnter
|
|
61
61
|
: props.onViewportLeave;
|
|
62
|
-
callback === null || callback === void 0 ? void 0 : callback();
|
|
62
|
+
callback === null || callback === void 0 ? void 0 : callback(entry);
|
|
63
63
|
};
|
|
64
64
|
return observeIntersection(visualElement.getInstance(), options, intersectionCallback);
|
|
65
65
|
}, [shouldObserve, root, rootMargin, amount]);
|
|
@@ -88,7 +88,7 @@ function useMissingIntersectionObserver(shouldObserve, state, visualElement) {
|
|
|
88
88
|
var _a;
|
|
89
89
|
state.hasEnteredView = true;
|
|
90
90
|
var onViewportEnter = visualElement.getProps().onViewportEnter;
|
|
91
|
-
onViewportEnter === null || onViewportEnter === void 0 ? void 0 : onViewportEnter();
|
|
91
|
+
onViewportEnter === null || onViewportEnter === void 0 ? void 0 : onViewportEnter(null);
|
|
92
92
|
(_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.InView, true);
|
|
93
93
|
});
|
|
94
94
|
}, [shouldObserve]);
|
|
@@ -38,12 +38,14 @@ function useHTMLProps(props, visualState, isStatic) {
|
|
|
38
38
|
// The `any` isn't ideal but it is the type of createElement props argument
|
|
39
39
|
var htmlProps = {};
|
|
40
40
|
var style = useStyle(props, visualState, isStatic);
|
|
41
|
-
if (Boolean(props.drag)) {
|
|
41
|
+
if (Boolean(props.drag) && props.dragListener !== false) {
|
|
42
42
|
// Disable the ghost element when a user drags
|
|
43
43
|
htmlProps.draggable = false;
|
|
44
44
|
// Disable text selection
|
|
45
|
-
style.userSelect =
|
|
46
|
-
|
|
45
|
+
style.userSelect =
|
|
46
|
+
style.WebkitUserSelect =
|
|
47
|
+
style.WebkitTouchCallout =
|
|
48
|
+
"none";
|
|
47
49
|
// Disable scrolling on the draggable direction
|
|
48
50
|
style.touchAction =
|
|
49
51
|
props.drag === true
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { __read } from 'tslib';
|
|
2
|
-
import
|
|
2
|
+
import sync from 'framesync';
|
|
3
|
+
import { useRef, useState, useCallback } from 'react';
|
|
3
4
|
import { useUnmountEffect } from './use-unmount-effect.mjs';
|
|
4
5
|
|
|
5
6
|
function useForceUpdate() {
|
|
6
|
-
var
|
|
7
|
+
var isUnmountingRef = useRef(false);
|
|
7
8
|
var _a = __read(useState(0), 2), forcedRenderCount = _a[0], setForcedRenderCount = _a[1];
|
|
8
|
-
useUnmountEffect(function () { return (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
useUnmountEffect(function () { return (isUnmountingRef.current = true); });
|
|
10
|
+
var forceRender = useCallback(function () {
|
|
11
|
+
!isUnmountingRef.current && setForcedRenderCount(forcedRenderCount + 1);
|
|
12
|
+
}, [forcedRenderCount]);
|
|
13
|
+
/**
|
|
14
|
+
* Defer this to the end of the next animation frame in case there are multiple
|
|
15
|
+
* synchronous calls.
|
|
16
|
+
*/
|
|
17
|
+
var deferredForceRender = useCallback(function () { return sync.postRender(forceRender); }, [forceRender]);
|
|
18
|
+
return [deferredForceRender, forcedRenderCount];
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
export { useForceUpdate };
|
|
@@ -3310,12 +3310,14 @@ function useHTMLProps(props, visualState, isStatic) {
|
|
|
3310
3310
|
// The `any` isn't ideal but it is the type of createElement props argument
|
|
3311
3311
|
var htmlProps = {};
|
|
3312
3312
|
var style = useStyle(props, visualState, isStatic);
|
|
3313
|
-
if (Boolean(props.drag)) {
|
|
3313
|
+
if (Boolean(props.drag) && props.dragListener !== false) {
|
|
3314
3314
|
// Disable the ghost element when a user drags
|
|
3315
3315
|
htmlProps.draggable = false;
|
|
3316
3316
|
// Disable text selection
|
|
3317
|
-
style.userSelect =
|
|
3318
|
-
|
|
3317
|
+
style.userSelect =
|
|
3318
|
+
style.WebkitUserSelect =
|
|
3319
|
+
style.WebkitTouchCallout =
|
|
3320
|
+
"none";
|
|
3319
3321
|
// Disable scrolling on the draggable direction
|
|
3320
3322
|
style.touchAction =
|
|
3321
3323
|
props.drag === true
|
|
@@ -4191,7 +4193,7 @@ function useIntersectionObserver(shouldObserve, state, visualElement, _a) {
|
|
|
4191
4193
|
var callback = isIntersecting
|
|
4192
4194
|
? props.onViewportEnter
|
|
4193
4195
|
: props.onViewportLeave;
|
|
4194
|
-
callback === null || callback === void 0 ? void 0 : callback();
|
|
4196
|
+
callback === null || callback === void 0 ? void 0 : callback(entry);
|
|
4195
4197
|
};
|
|
4196
4198
|
return observeIntersection(visualElement.getInstance(), options, intersectionCallback);
|
|
4197
4199
|
}, [shouldObserve, root, rootMargin, amount]);
|
|
@@ -4220,7 +4222,7 @@ function useMissingIntersectionObserver(shouldObserve, state, visualElement) {
|
|
|
4220
4222
|
var _a;
|
|
4221
4223
|
state.hasEnteredView = true;
|
|
4222
4224
|
var onViewportEnter = visualElement.getProps().onViewportEnter;
|
|
4223
|
-
onViewportEnter === null || onViewportEnter === void 0 ? void 0 : onViewportEnter();
|
|
4225
|
+
onViewportEnter === null || onViewportEnter === void 0 ? void 0 : onViewportEnter(null);
|
|
4224
4226
|
(_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.InView, true);
|
|
4225
4227
|
});
|
|
4226
4228
|
}, [shouldObserve]);
|
|
@@ -6978,15 +6980,18 @@ function createDomMotionComponent(key) {
|
|
|
6978
6980
|
var m = createMotionProxy(createDomMotionConfig);
|
|
6979
6981
|
|
|
6980
6982
|
function useForceUpdate() {
|
|
6981
|
-
var
|
|
6983
|
+
var isUnmountingRef = React.useRef(false);
|
|
6982
6984
|
var _a = tslib.__read(React.useState(0), 2), forcedRenderCount = _a[0], setForcedRenderCount = _a[1];
|
|
6983
|
-
useUnmountEffect(function () { return (
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6985
|
+
useUnmountEffect(function () { return (isUnmountingRef.current = true); });
|
|
6986
|
+
var forceRender = React.useCallback(function () {
|
|
6987
|
+
!isUnmountingRef.current && setForcedRenderCount(forcedRenderCount + 1);
|
|
6988
|
+
}, [forcedRenderCount]);
|
|
6989
|
+
/**
|
|
6990
|
+
* Defer this to the end of the next animation frame in case there are multiple
|
|
6991
|
+
* synchronous calls.
|
|
6992
|
+
*/
|
|
6993
|
+
var deferredForceRender = React.useCallback(function () { return sync__default['default'].postRender(forceRender); }, [forceRender]);
|
|
6994
|
+
return [deferredForceRender, forcedRenderCount];
|
|
6990
6995
|
}
|
|
6991
6996
|
|
|
6992
6997
|
var presenceId = 0;
|
|
@@ -4541,12 +4541,14 @@
|
|
|
4541
4541
|
// The `any` isn't ideal but it is the type of createElement props argument
|
|
4542
4542
|
var htmlProps = {};
|
|
4543
4543
|
var style = useStyle(props, visualState, isStatic);
|
|
4544
|
-
if (Boolean(props.drag)) {
|
|
4544
|
+
if (Boolean(props.drag) && props.dragListener !== false) {
|
|
4545
4545
|
// Disable the ghost element when a user drags
|
|
4546
4546
|
htmlProps.draggable = false;
|
|
4547
4547
|
// Disable text selection
|
|
4548
|
-
style.userSelect =
|
|
4549
|
-
|
|
4548
|
+
style.userSelect =
|
|
4549
|
+
style.WebkitUserSelect =
|
|
4550
|
+
style.WebkitTouchCallout =
|
|
4551
|
+
"none";
|
|
4550
4552
|
// Disable scrolling on the draggable direction
|
|
4551
4553
|
style.touchAction =
|
|
4552
4554
|
props.drag === true
|
|
@@ -5422,7 +5424,7 @@
|
|
|
5422
5424
|
var callback = isIntersecting
|
|
5423
5425
|
? props.onViewportEnter
|
|
5424
5426
|
: props.onViewportLeave;
|
|
5425
|
-
callback === null || callback === void 0 ? void 0 : callback();
|
|
5427
|
+
callback === null || callback === void 0 ? void 0 : callback(entry);
|
|
5426
5428
|
};
|
|
5427
5429
|
return observeIntersection(visualElement.getInstance(), options, intersectionCallback);
|
|
5428
5430
|
}, [shouldObserve, root, rootMargin, amount]);
|
|
@@ -5451,7 +5453,7 @@
|
|
|
5451
5453
|
var _a;
|
|
5452
5454
|
state.hasEnteredView = true;
|
|
5453
5455
|
var onViewportEnter = visualElement.getProps().onViewportEnter;
|
|
5454
|
-
onViewportEnter === null || onViewportEnter === void 0 ? void 0 : onViewportEnter();
|
|
5456
|
+
onViewportEnter === null || onViewportEnter === void 0 ? void 0 : onViewportEnter(null);
|
|
5455
5457
|
(_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.InView, true);
|
|
5456
5458
|
});
|
|
5457
5459
|
}, [shouldObserve]);
|
|
@@ -8209,15 +8211,18 @@
|
|
|
8209
8211
|
var m = createMotionProxy(createDomMotionConfig);
|
|
8210
8212
|
|
|
8211
8213
|
function useForceUpdate() {
|
|
8212
|
-
var
|
|
8214
|
+
var isUnmountingRef = React.useRef(false);
|
|
8213
8215
|
var _a = __read(React.useState(0), 2), forcedRenderCount = _a[0], setForcedRenderCount = _a[1];
|
|
8214
|
-
useUnmountEffect(function () { return (
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8216
|
+
useUnmountEffect(function () { return (isUnmountingRef.current = true); });
|
|
8217
|
+
var forceRender = React.useCallback(function () {
|
|
8218
|
+
!isUnmountingRef.current && setForcedRenderCount(forcedRenderCount + 1);
|
|
8219
|
+
}, [forcedRenderCount]);
|
|
8220
|
+
/**
|
|
8221
|
+
* Defer this to the end of the next animation frame in case there are multiple
|
|
8222
|
+
* synchronous calls.
|
|
8223
|
+
*/
|
|
8224
|
+
var deferredForceRender = React.useCallback(function () { return sync.postRender(forceRender); }, [forceRender]);
|
|
8225
|
+
return [deferredForceRender, forcedRenderCount];
|
|
8221
8226
|
}
|
|
8222
8227
|
|
|
8223
8228
|
var presenceId = 0;
|