framer-motion 6.2.10 → 6.3.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 +19 -18
- 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/use-cycle.mjs +10 -12
- package/dist/framer-motion.dev.js +19 -18
- 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/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
|
@@ -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);
|
|
@@ -8142,16 +8145,14 @@ function useCycle() {
|
|
|
8142
8145
|
}
|
|
8143
8146
|
var index = React.useRef(0);
|
|
8144
8147
|
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
|
-
];
|
|
8148
|
+
var runCycle = React.useCallback(function (next) {
|
|
8149
|
+
index.current =
|
|
8150
|
+
typeof next !== "number"
|
|
8151
|
+
? popmotion.wrap(0, items.length, index.current + 1)
|
|
8152
|
+
: next;
|
|
8153
|
+
setItem(items[index.current]);
|
|
8154
|
+
}, tslib.__spreadArray([items.length], tslib.__read(items), false));
|
|
8155
|
+
return [item, runCycle];
|
|
8155
8156
|
}
|
|
8156
8157
|
|
|
8157
8158
|
/**
|
|
@@ -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 };
|
|
@@ -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);
|
|
@@ -9365,16 +9368,14 @@
|
|
|
9365
9368
|
}
|
|
9366
9369
|
var index = React.useRef(0);
|
|
9367
9370
|
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
|
-
];
|
|
9371
|
+
var runCycle = React.useCallback(function (next) {
|
|
9372
|
+
index.current =
|
|
9373
|
+
typeof next !== "number"
|
|
9374
|
+
? wrap(0, items.length, index.current + 1)
|
|
9375
|
+
: next;
|
|
9376
|
+
setItem(items[index.current]);
|
|
9377
|
+
}, __spreadArray([items.length], __read(items), false));
|
|
9378
|
+
return [item, runCycle];
|
|
9378
9379
|
}
|
|
9379
9380
|
|
|
9380
9381
|
/**
|