framer-motion 6.2.9 → 6.3.1
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 +22 -23
- package/dist/es/components/Reorder/Item.mjs +6 -6
- package/dist/es/motion/utils/valid-prop.mjs +1 -0
- package/dist/es/projection/node/create-projection-node.mjs +3 -2
- package/dist/es/render/utils/lifecycles.mjs +1 -0
- package/dist/es/utils/is-browser.mjs +1 -1
- package/dist/es/utils/use-cycle.mjs +10 -12
- package/dist/es/utils/use-reduced-motion.mjs +2 -1
- package/dist/es/value/scroll/use-viewport-scroll.mjs +0 -2
- package/dist/es/value/use-spring.mjs +1 -1
- package/dist/framer-motion.dev.js +22 -23
- package/dist/framer-motion.js +1 -1
- package/dist/projection.dev.js +4 -2
- 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/dist/size-webpack-dom-animation.js +1 -1
- package/dist/size-webpack-dom-max.js +1 -1
- package/dist/size-webpack-m.js +1 -1
- package/package.json +3 -3
- package/types/components/AnimatePresence/index.d.ts +1 -1
- package/types/components/LayoutGroup/index.d.ts +1 -1
- package/types/components/Reorder/Item.d.ts +8 -1
- package/types/motion/features/layout/types.d.ts +6 -0
- package/types/projection/node/types.d.ts +1 -1
- package/types/render/utils/lifecycles.d.ts +7 -0
package/dist/cjs/index.js
CHANGED
|
@@ -141,7 +141,7 @@ function useVisualElementContext() {
|
|
|
141
141
|
*/
|
|
142
142
|
var PresenceContext = React.createContext(null);
|
|
143
143
|
|
|
144
|
-
var isBrowser = typeof
|
|
144
|
+
var isBrowser = typeof document !== "undefined";
|
|
145
145
|
|
|
146
146
|
var useIsomorphicLayoutEffect = isBrowser ? React.useLayoutEffect : React.useEffect;
|
|
147
147
|
|
|
@@ -150,7 +150,7 @@ var prefersReducedMotion = { current: null };
|
|
|
150
150
|
var hasDetected = false;
|
|
151
151
|
function initPrefersReducedMotion() {
|
|
152
152
|
hasDetected = true;
|
|
153
|
-
if (
|
|
153
|
+
if (!isBrowser)
|
|
154
154
|
return;
|
|
155
155
|
if (window.matchMedia) {
|
|
156
156
|
var motionMediaQuery_1 = window.matchMedia("(prefers-reduced-motion)");
|
|
@@ -1998,7 +1998,7 @@ function createProjectionNode(_a) {
|
|
|
1998
1998
|
}
|
|
1999
1999
|
// TODO: Check here if an animation exists
|
|
2000
2000
|
var layoutTransition = (_c = (_b = _this.options.transition) !== null && _b !== void 0 ? _b : visualElement.getDefaultTransition()) !== null && _c !== void 0 ? _c : defaultLayoutTransition;
|
|
2001
|
-
var
|
|
2001
|
+
var _g = visualElement.getProps(), onLayoutAnimationStart = _g.onLayoutAnimationStart, onLayoutAnimationComplete = _g.onLayoutAnimationComplete;
|
|
2002
2002
|
/**
|
|
2003
2003
|
* The target layout of the element might stay the same,
|
|
2004
2004
|
* but its position relative to its parent has changed.
|
|
@@ -2021,7 +2021,7 @@ function createProjectionNode(_a) {
|
|
|
2021
2021
|
_this.resumingFrom.resumingFrom = undefined;
|
|
2022
2022
|
}
|
|
2023
2023
|
_this.setAnimationOrigin(delta, hasOnlyRelativeTargetChanged);
|
|
2024
|
-
var animationOptions = tslib.__assign(tslib.__assign({}, getValueTransition(layoutTransition, "layout")), { onComplete: onLayoutAnimationComplete });
|
|
2024
|
+
var animationOptions = tslib.__assign(tslib.__assign({}, getValueTransition(layoutTransition, "layout")), { onPlay: onLayoutAnimationStart, onComplete: onLayoutAnimationComplete });
|
|
2025
2025
|
if (visualElement.shouldReduceMotion) {
|
|
2026
2026
|
animationOptions.delay = 0;
|
|
2027
2027
|
animationOptions.type = false;
|
|
@@ -2554,6 +2554,7 @@ function createProjectionNode(_a) {
|
|
|
2554
2554
|
ProjectionNode.prototype.startAnimation = function (options) {
|
|
2555
2555
|
var _this = this;
|
|
2556
2556
|
var _a, _b;
|
|
2557
|
+
this.notifyListeners("animationStart");
|
|
2557
2558
|
(_a = this.currentAnimation) === null || _a === void 0 ? void 0 : _a.stop();
|
|
2558
2559
|
if (this.resumingFrom) {
|
|
2559
2560
|
(_b = this.resumingFrom.currentAnimation) === null || _b === void 0 ? void 0 : _b.stop();
|
|
@@ -3458,6 +3459,7 @@ var validMotionProps = new Set([
|
|
|
3458
3459
|
"layout",
|
|
3459
3460
|
"layoutId",
|
|
3460
3461
|
"layoutDependency",
|
|
3462
|
+
"onLayoutAnimationStart",
|
|
3461
3463
|
"onLayoutAnimationComplete",
|
|
3462
3464
|
"onLayoutMeasure",
|
|
3463
3465
|
"onBeforeLayoutMeasure",
|
|
@@ -5907,6 +5909,7 @@ var names = [
|
|
|
5907
5909
|
"AnimationComplete",
|
|
5908
5910
|
"LayoutAnimationComplete",
|
|
5909
5911
|
"AnimationStart",
|
|
5912
|
+
"LayoutAnimationStart",
|
|
5910
5913
|
"SetAxisTarget",
|
|
5911
5914
|
"Unmount",
|
|
5912
5915
|
];
|
|
@@ -7699,7 +7702,7 @@ function useDefaultMotionValue(value, defaultValue) {
|
|
|
7699
7702
|
return isMotionValue(value) ? value : useMotionValue(defaultValue);
|
|
7700
7703
|
}
|
|
7701
7704
|
function ReorderItem(_a, externalRef) {
|
|
7702
|
-
var children = _a.children, style = _a.style, value = _a.value, _b = _a.as, as = _b === void 0 ? "li" : _b, onDrag = _a.onDrag, props = tslib.__rest(_a, ["children", "style", "value", "as", "onDrag"]);
|
|
7705
|
+
var children = _a.children, style = _a.style, value = _a.value, _b = _a.as, as = _b === void 0 ? "li" : _b, onDrag = _a.onDrag, _c = _a.layout, layout = _c === void 0 ? true : _c, props = tslib.__rest(_a, ["children", "style", "value", "as", "onDrag", "layout"]);
|
|
7703
7706
|
var Component = useConstant(function () { return motion(as); });
|
|
7704
7707
|
var context = React.useContext(ReorderContext);
|
|
7705
7708
|
var point = {
|
|
@@ -7710,19 +7713,19 @@ function ReorderItem(_a, externalRef) {
|
|
|
7710
7713
|
var _b = tslib.__read(_a, 2), latestX = _b[0], latestY = _b[1];
|
|
7711
7714
|
return latestX || latestY ? 1 : "unset";
|
|
7712
7715
|
});
|
|
7713
|
-
var
|
|
7716
|
+
var measuredLayout = React.useRef(null);
|
|
7714
7717
|
heyListen.invariant(Boolean(context), "Reorder.Item must be a child of Reorder.Group");
|
|
7715
|
-
var
|
|
7718
|
+
var _d = context, axis = _d.axis, registerItem = _d.registerItem, updateOrder = _d.updateOrder;
|
|
7716
7719
|
React.useEffect(function () {
|
|
7717
|
-
registerItem(value,
|
|
7720
|
+
registerItem(value, measuredLayout.current);
|
|
7718
7721
|
}, [context]);
|
|
7719
|
-
return (React__namespace.createElement(Component, tslib.__assign({ drag: axis }, props, { dragSnapToOrigin: true, style: tslib.__assign(tslib.__assign({}, style), { x: point.x, y: point.y, zIndex: zIndex }), layout:
|
|
7722
|
+
return (React__namespace.createElement(Component, tslib.__assign({ drag: axis }, props, { dragSnapToOrigin: true, style: tslib.__assign(tslib.__assign({}, style), { x: point.x, y: point.y, zIndex: zIndex }), layout: layout, onDrag: function (event, gesturePoint) {
|
|
7720
7723
|
var velocity = gesturePoint.velocity;
|
|
7721
7724
|
velocity[axis] &&
|
|
7722
7725
|
updateOrder(value, point[axis].get(), velocity[axis]);
|
|
7723
7726
|
onDrag === null || onDrag === void 0 ? void 0 : onDrag(event, gesturePoint);
|
|
7724
7727
|
}, onLayoutMeasure: function (measured) {
|
|
7725
|
-
|
|
7728
|
+
measuredLayout.current = measured;
|
|
7726
7729
|
}, ref: externalRef }), children));
|
|
7727
7730
|
}
|
|
7728
7731
|
var Item = React.forwardRef(ReorderItem);
|
|
@@ -7824,7 +7827,7 @@ function useSpring(source, config) {
|
|
|
7824
7827
|
activeSpringAnimation.current = popmotion.animate(tslib.__assign(tslib.__assign({ from: value.get(), to: v, velocity: value.getVelocity() }, config), { onUpdate: set }));
|
|
7825
7828
|
return value.get();
|
|
7826
7829
|
});
|
|
7827
|
-
},
|
|
7830
|
+
}, [JSON.stringify(config)]);
|
|
7828
7831
|
useOnChange(source, function (v) { return value.set(parseFloat(v)); });
|
|
7829
7832
|
return value;
|
|
7830
7833
|
}
|
|
@@ -7938,8 +7941,6 @@ function getViewportScrollOffsets() {
|
|
|
7938
7941
|
var hasListeners = false;
|
|
7939
7942
|
function addEventListeners() {
|
|
7940
7943
|
hasListeners = true;
|
|
7941
|
-
if (typeof window === "undefined")
|
|
7942
|
-
return;
|
|
7943
7944
|
var updateScrollValues = createScrollUpdater(viewportScrollValues, getViewportScrollOffsets);
|
|
7944
7945
|
addDomEvent(window, "scroll", updateScrollValues, { passive: true });
|
|
7945
7946
|
addDomEvent(window, "resize", updateScrollValues);
|
|
@@ -8142,16 +8143,14 @@ function useCycle() {
|
|
|
8142
8143
|
}
|
|
8143
8144
|
var index = React.useRef(0);
|
|
8144
8145
|
var _a = tslib.__read(React.useState(items[index.current]), 2), item = _a[0], setItem = _a[1];
|
|
8145
|
-
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
},
|
|
8154
|
-
];
|
|
8146
|
+
var runCycle = React.useCallback(function (next) {
|
|
8147
|
+
index.current =
|
|
8148
|
+
typeof next !== "number"
|
|
8149
|
+
? popmotion.wrap(0, items.length, index.current + 1)
|
|
8150
|
+
: next;
|
|
8151
|
+
setItem(items[index.current]);
|
|
8152
|
+
}, tslib.__spreadArray([items.length], tslib.__read(items), false));
|
|
8153
|
+
return [item, runCycle];
|
|
8155
8154
|
}
|
|
8156
8155
|
|
|
8157
8156
|
/**
|
|
@@ -14,7 +14,7 @@ function useDefaultMotionValue(value, defaultValue) {
|
|
|
14
14
|
return isMotionValue(value) ? value : useMotionValue(defaultValue);
|
|
15
15
|
}
|
|
16
16
|
function ReorderItem(_a, externalRef) {
|
|
17
|
-
var children = _a.children, style = _a.style, value = _a.value, _b = _a.as, as = _b === void 0 ? "li" : _b, onDrag = _a.onDrag, props = __rest(_a, ["children", "style", "value", "as", "onDrag"]);
|
|
17
|
+
var children = _a.children, style = _a.style, value = _a.value, _b = _a.as, as = _b === void 0 ? "li" : _b, onDrag = _a.onDrag, _c = _a.layout, layout = _c === void 0 ? true : _c, props = __rest(_a, ["children", "style", "value", "as", "onDrag", "layout"]);
|
|
18
18
|
var Component = useConstant(function () { return motion(as); });
|
|
19
19
|
var context = useContext(ReorderContext);
|
|
20
20
|
var point = {
|
|
@@ -25,19 +25,19 @@ function ReorderItem(_a, externalRef) {
|
|
|
25
25
|
var _b = __read(_a, 2), latestX = _b[0], latestY = _b[1];
|
|
26
26
|
return latestX || latestY ? 1 : "unset";
|
|
27
27
|
});
|
|
28
|
-
var
|
|
28
|
+
var measuredLayout = useRef(null);
|
|
29
29
|
invariant(Boolean(context), "Reorder.Item must be a child of Reorder.Group");
|
|
30
|
-
var
|
|
30
|
+
var _d = context, axis = _d.axis, registerItem = _d.registerItem, updateOrder = _d.updateOrder;
|
|
31
31
|
useEffect(function () {
|
|
32
|
-
registerItem(value,
|
|
32
|
+
registerItem(value, measuredLayout.current);
|
|
33
33
|
}, [context]);
|
|
34
|
-
return (React.createElement(Component, __assign({ drag: axis }, props, { dragSnapToOrigin: true, style: __assign(__assign({}, style), { x: point.x, y: point.y, zIndex: zIndex }), layout:
|
|
34
|
+
return (React.createElement(Component, __assign({ drag: axis }, props, { dragSnapToOrigin: true, style: __assign(__assign({}, style), { x: point.x, y: point.y, zIndex: zIndex }), layout: layout, onDrag: function (event, gesturePoint) {
|
|
35
35
|
var velocity = gesturePoint.velocity;
|
|
36
36
|
velocity[axis] &&
|
|
37
37
|
updateOrder(value, point[axis].get(), velocity[axis]);
|
|
38
38
|
onDrag === null || onDrag === void 0 ? void 0 : onDrag(event, gesturePoint);
|
|
39
39
|
}, onLayoutMeasure: function (measured) {
|
|
40
|
-
|
|
40
|
+
measuredLayout.current = measured;
|
|
41
41
|
}, ref: externalRef }), children));
|
|
42
42
|
}
|
|
43
43
|
var Item = forwardRef(ReorderItem);
|
|
@@ -218,7 +218,7 @@ function createProjectionNode(_a) {
|
|
|
218
218
|
}
|
|
219
219
|
// TODO: Check here if an animation exists
|
|
220
220
|
var layoutTransition = (_c = (_b = _this.options.transition) !== null && _b !== void 0 ? _b : visualElement.getDefaultTransition()) !== null && _c !== void 0 ? _c : defaultLayoutTransition;
|
|
221
|
-
var
|
|
221
|
+
var _g = visualElement.getProps(), onLayoutAnimationStart = _g.onLayoutAnimationStart, onLayoutAnimationComplete = _g.onLayoutAnimationComplete;
|
|
222
222
|
/**
|
|
223
223
|
* The target layout of the element might stay the same,
|
|
224
224
|
* but its position relative to its parent has changed.
|
|
@@ -241,7 +241,7 @@ function createProjectionNode(_a) {
|
|
|
241
241
|
_this.resumingFrom.resumingFrom = undefined;
|
|
242
242
|
}
|
|
243
243
|
_this.setAnimationOrigin(delta, hasOnlyRelativeTargetChanged);
|
|
244
|
-
var animationOptions = __assign(__assign({}, getValueTransition(layoutTransition, "layout")), { onComplete: onLayoutAnimationComplete });
|
|
244
|
+
var animationOptions = __assign(__assign({}, getValueTransition(layoutTransition, "layout")), { onPlay: onLayoutAnimationStart, onComplete: onLayoutAnimationComplete });
|
|
245
245
|
if (visualElement.shouldReduceMotion) {
|
|
246
246
|
animationOptions.delay = 0;
|
|
247
247
|
animationOptions.type = false;
|
|
@@ -774,6 +774,7 @@ function createProjectionNode(_a) {
|
|
|
774
774
|
ProjectionNode.prototype.startAnimation = function (options) {
|
|
775
775
|
var _this = this;
|
|
776
776
|
var _a, _b;
|
|
777
|
+
this.notifyListeners("animationStart");
|
|
777
778
|
(_a = this.currentAnimation) === null || _a === void 0 ? void 0 : _a.stop();
|
|
778
779
|
if (this.resumingFrom) {
|
|
779
780
|
(_b = this.resumingFrom.currentAnimation) === null || _b === void 0 ? void 0 : _b.stop();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { __read } from 'tslib';
|
|
2
|
-
import { useRef, useState } from 'react';
|
|
1
|
+
import { __read, __spreadArray } from 'tslib';
|
|
3
2
|
import { wrap } from 'popmotion';
|
|
3
|
+
import { useRef, useState, useCallback } from 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Cycles through a series of visual properties. Can be used to toggle between or cycle through animations. It works similar to `useState` in React. It is provided an initial array of possible states, and returns an array of two arguments.
|
|
@@ -35,16 +35,14 @@ function useCycle() {
|
|
|
35
35
|
}
|
|
36
36
|
var index = useRef(0);
|
|
37
37
|
var _a = __read(useState(items[index.current]), 2), item = _a[0], setItem = _a[1];
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
];
|
|
38
|
+
var runCycle = useCallback(function (next) {
|
|
39
|
+
index.current =
|
|
40
|
+
typeof next !== "number"
|
|
41
|
+
? wrap(0, items.length, index.current + 1)
|
|
42
|
+
: next;
|
|
43
|
+
setItem(items[index.current]);
|
|
44
|
+
}, __spreadArray([items.length], __read(items), false));
|
|
45
|
+
return [item, runCycle];
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
export { useCycle };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { __read } from 'tslib';
|
|
2
2
|
import { useState, useContext } from 'react';
|
|
3
3
|
import { MotionConfigContext } from '../context/MotionConfigContext.mjs';
|
|
4
|
+
import { isBrowser } from './is-browser.mjs';
|
|
4
5
|
|
|
5
6
|
// Does this device prefer reduced motion? Returns `null` server-side.
|
|
6
7
|
var prefersReducedMotion = { current: null };
|
|
7
8
|
var hasDetected = false;
|
|
8
9
|
function initPrefersReducedMotion() {
|
|
9
10
|
hasDetected = true;
|
|
10
|
-
if (
|
|
11
|
+
if (!isBrowser)
|
|
11
12
|
return;
|
|
12
13
|
if (window.matchMedia) {
|
|
13
14
|
var motionMediaQuery_1 = window.matchMedia("(prefers-reduced-motion)");
|
|
@@ -14,8 +14,6 @@ function getViewportScrollOffsets() {
|
|
|
14
14
|
var hasListeners = false;
|
|
15
15
|
function addEventListeners() {
|
|
16
16
|
hasListeners = true;
|
|
17
|
-
if (typeof window === "undefined")
|
|
18
|
-
return;
|
|
19
17
|
var updateScrollValues = createScrollUpdater(viewportScrollValues, getViewportScrollOffsets);
|
|
20
18
|
addDomEvent(window, "scroll", updateScrollValues, { passive: true });
|
|
21
19
|
addDomEvent(window, "resize", updateScrollValues);
|
|
@@ -44,7 +44,7 @@ function useSpring(source, config) {
|
|
|
44
44
|
activeSpringAnimation.current = animate(__assign(__assign({ from: value.get(), to: v, velocity: value.getVelocity() }, config), { onUpdate: set }));
|
|
45
45
|
return value.get();
|
|
46
46
|
});
|
|
47
|
-
},
|
|
47
|
+
}, [JSON.stringify(config)]);
|
|
48
48
|
useOnChange(source, function (v) { return value.set(parseFloat(v)); });
|
|
49
49
|
return value;
|
|
50
50
|
}
|
|
@@ -234,7 +234,7 @@
|
|
|
234
234
|
*/
|
|
235
235
|
var PresenceContext = React.createContext(null);
|
|
236
236
|
|
|
237
|
-
var isBrowser = typeof
|
|
237
|
+
var isBrowser = typeof document !== "undefined";
|
|
238
238
|
|
|
239
239
|
var useIsomorphicLayoutEffect = isBrowser ? React.useLayoutEffect : React.useEffect;
|
|
240
240
|
|
|
@@ -243,7 +243,7 @@
|
|
|
243
243
|
var hasDetected = false;
|
|
244
244
|
function initPrefersReducedMotion() {
|
|
245
245
|
hasDetected = true;
|
|
246
|
-
if (
|
|
246
|
+
if (!isBrowser)
|
|
247
247
|
return;
|
|
248
248
|
if (window.matchMedia) {
|
|
249
249
|
var motionMediaQuery_1 = window.matchMedia("(prefers-reduced-motion)");
|
|
@@ -3223,7 +3223,7 @@
|
|
|
3223
3223
|
}
|
|
3224
3224
|
// TODO: Check here if an animation exists
|
|
3225
3225
|
var layoutTransition = (_c = (_b = _this.options.transition) !== null && _b !== void 0 ? _b : visualElement.getDefaultTransition()) !== null && _c !== void 0 ? _c : defaultLayoutTransition;
|
|
3226
|
-
var
|
|
3226
|
+
var _g = visualElement.getProps(), onLayoutAnimationStart = _g.onLayoutAnimationStart, onLayoutAnimationComplete = _g.onLayoutAnimationComplete;
|
|
3227
3227
|
/**
|
|
3228
3228
|
* The target layout of the element might stay the same,
|
|
3229
3229
|
* but its position relative to its parent has changed.
|
|
@@ -3246,7 +3246,7 @@
|
|
|
3246
3246
|
_this.resumingFrom.resumingFrom = undefined;
|
|
3247
3247
|
}
|
|
3248
3248
|
_this.setAnimationOrigin(delta, hasOnlyRelativeTargetChanged);
|
|
3249
|
-
var animationOptions = __assign(__assign({}, getValueTransition(layoutTransition, "layout")), { onComplete: onLayoutAnimationComplete });
|
|
3249
|
+
var animationOptions = __assign(__assign({}, getValueTransition(layoutTransition, "layout")), { onPlay: onLayoutAnimationStart, onComplete: onLayoutAnimationComplete });
|
|
3250
3250
|
if (visualElement.shouldReduceMotion) {
|
|
3251
3251
|
animationOptions.delay = 0;
|
|
3252
3252
|
animationOptions.type = false;
|
|
@@ -3779,6 +3779,7 @@
|
|
|
3779
3779
|
ProjectionNode.prototype.startAnimation = function (options) {
|
|
3780
3780
|
var _this = this;
|
|
3781
3781
|
var _a, _b;
|
|
3782
|
+
this.notifyListeners("animationStart");
|
|
3782
3783
|
(_a = this.currentAnimation) === null || _a === void 0 ? void 0 : _a.stop();
|
|
3783
3784
|
if (this.resumingFrom) {
|
|
3784
3785
|
(_b = this.resumingFrom.currentAnimation) === null || _b === void 0 ? void 0 : _b.stop();
|
|
@@ -4683,6 +4684,7 @@
|
|
|
4683
4684
|
"layout",
|
|
4684
4685
|
"layoutId",
|
|
4685
4686
|
"layoutDependency",
|
|
4687
|
+
"onLayoutAnimationStart",
|
|
4686
4688
|
"onLayoutAnimationComplete",
|
|
4687
4689
|
"onLayoutMeasure",
|
|
4688
4690
|
"onBeforeLayoutMeasure",
|
|
@@ -7132,6 +7134,7 @@
|
|
|
7132
7134
|
"AnimationComplete",
|
|
7133
7135
|
"LayoutAnimationComplete",
|
|
7134
7136
|
"AnimationStart",
|
|
7137
|
+
"LayoutAnimationStart",
|
|
7135
7138
|
"SetAxisTarget",
|
|
7136
7139
|
"Unmount",
|
|
7137
7140
|
];
|
|
@@ -8922,7 +8925,7 @@
|
|
|
8922
8925
|
return isMotionValue(value) ? value : useMotionValue(defaultValue);
|
|
8923
8926
|
}
|
|
8924
8927
|
function ReorderItem(_a, externalRef) {
|
|
8925
|
-
var children = _a.children, style = _a.style, value = _a.value, _b = _a.as, as = _b === void 0 ? "li" : _b, onDrag = _a.onDrag, props = __rest(_a, ["children", "style", "value", "as", "onDrag"]);
|
|
8928
|
+
var children = _a.children, style = _a.style, value = _a.value, _b = _a.as, as = _b === void 0 ? "li" : _b, onDrag = _a.onDrag, _c = _a.layout, layout = _c === void 0 ? true : _c, props = __rest(_a, ["children", "style", "value", "as", "onDrag", "layout"]);
|
|
8926
8929
|
var Component = useConstant(function () { return motion(as); });
|
|
8927
8930
|
var context = React.useContext(ReorderContext);
|
|
8928
8931
|
var point = {
|
|
@@ -8933,19 +8936,19 @@
|
|
|
8933
8936
|
var _b = __read(_a, 2), latestX = _b[0], latestY = _b[1];
|
|
8934
8937
|
return latestX || latestY ? 1 : "unset";
|
|
8935
8938
|
});
|
|
8936
|
-
var
|
|
8939
|
+
var measuredLayout = React.useRef(null);
|
|
8937
8940
|
invariant(Boolean(context), "Reorder.Item must be a child of Reorder.Group");
|
|
8938
|
-
var
|
|
8941
|
+
var _d = context, axis = _d.axis, registerItem = _d.registerItem, updateOrder = _d.updateOrder;
|
|
8939
8942
|
React.useEffect(function () {
|
|
8940
|
-
registerItem(value,
|
|
8943
|
+
registerItem(value, measuredLayout.current);
|
|
8941
8944
|
}, [context]);
|
|
8942
|
-
return (React__namespace.createElement(Component, __assign({ drag: axis }, props, { dragSnapToOrigin: true, style: __assign(__assign({}, style), { x: point.x, y: point.y, zIndex: zIndex }), layout:
|
|
8945
|
+
return (React__namespace.createElement(Component, __assign({ drag: axis }, props, { dragSnapToOrigin: true, style: __assign(__assign({}, style), { x: point.x, y: point.y, zIndex: zIndex }), layout: layout, onDrag: function (event, gesturePoint) {
|
|
8943
8946
|
var velocity = gesturePoint.velocity;
|
|
8944
8947
|
velocity[axis] &&
|
|
8945
8948
|
updateOrder(value, point[axis].get(), velocity[axis]);
|
|
8946
8949
|
onDrag === null || onDrag === void 0 ? void 0 : onDrag(event, gesturePoint);
|
|
8947
8950
|
}, onLayoutMeasure: function (measured) {
|
|
8948
|
-
|
|
8951
|
+
measuredLayout.current = measured;
|
|
8949
8952
|
}, ref: externalRef }), children));
|
|
8950
8953
|
}
|
|
8951
8954
|
var Item = React.forwardRef(ReorderItem);
|
|
@@ -9047,7 +9050,7 @@
|
|
|
9047
9050
|
activeSpringAnimation.current = animate$1(__assign(__assign({ from: value.get(), to: v, velocity: value.getVelocity() }, config), { onUpdate: set }));
|
|
9048
9051
|
return value.get();
|
|
9049
9052
|
});
|
|
9050
|
-
},
|
|
9053
|
+
}, [JSON.stringify(config)]);
|
|
9051
9054
|
useOnChange(source, function (v) { return value.set(parseFloat(v)); });
|
|
9052
9055
|
return value;
|
|
9053
9056
|
}
|
|
@@ -9161,8 +9164,6 @@
|
|
|
9161
9164
|
var hasListeners = false;
|
|
9162
9165
|
function addEventListeners() {
|
|
9163
9166
|
hasListeners = true;
|
|
9164
|
-
if (typeof window === "undefined")
|
|
9165
|
-
return;
|
|
9166
9167
|
var updateScrollValues = createScrollUpdater(viewportScrollValues, getViewportScrollOffsets);
|
|
9167
9168
|
addDomEvent(window, "scroll", updateScrollValues, { passive: true });
|
|
9168
9169
|
addDomEvent(window, "resize", updateScrollValues);
|
|
@@ -9365,16 +9366,14 @@
|
|
|
9365
9366
|
}
|
|
9366
9367
|
var index = React.useRef(0);
|
|
9367
9368
|
var _a = __read(React.useState(items[index.current]), 2), item = _a[0], setItem = _a[1];
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9373
|
-
|
|
9374
|
-
|
|
9375
|
-
|
|
9376
|
-
},
|
|
9377
|
-
];
|
|
9369
|
+
var runCycle = React.useCallback(function (next) {
|
|
9370
|
+
index.current =
|
|
9371
|
+
typeof next !== "number"
|
|
9372
|
+
? wrap(0, items.length, index.current + 1)
|
|
9373
|
+
: next;
|
|
9374
|
+
setItem(items[index.current]);
|
|
9375
|
+
}, __spreadArray([items.length], __read(items), false));
|
|
9376
|
+
return [item, runCycle];
|
|
9378
9377
|
}
|
|
9379
9378
|
|
|
9380
9379
|
/**
|