framer-motion 10.3.4 → 10.4.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/dom-entry.js +1 -1
- package/dist/cjs/index.js +135 -1958
- package/dist/cjs/{wrap-196fd3c5.js → wrap-58c66ad3.js} +3790 -1847
- package/dist/dom-entry.d.ts +43 -34
- package/dist/es/animation/animate.mjs +38 -34
- package/dist/es/animation/{create-instant-animation.mjs → animators/instant.mjs} +5 -2
- package/dist/es/animation/{js → animators/js}/driver-frameloop.mjs +2 -2
- package/dist/es/animation/{js → animators/js}/index.mjs +10 -9
- package/dist/es/animation/{waapi → animators/waapi}/create-accelerated-animation.mjs +22 -3
- package/dist/es/animation/hooks/animation-controls.mjs +4 -1
- package/dist/es/animation/hooks/use-animated-state.mjs +1 -1
- package/dist/es/animation/{index.mjs → interfaces/motion-value.mjs} +12 -12
- package/dist/es/animation/interfaces/single-value.mjs +11 -0
- package/dist/es/animation/interfaces/visual-element-target.mjs +66 -0
- package/dist/es/animation/interfaces/visual-element-variant.mjs +63 -0
- package/dist/es/animation/interfaces/visual-element.mjs +24 -0
- package/dist/es/animation/optimized-appear/start.mjs +1 -1
- package/dist/es/animation/utils/create-visual-element.mjs +32 -0
- package/dist/es/animation/utils/is-dom-keyframes.mjs +5 -0
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +2 -2
- package/dist/es/index.mjs +2 -2
- package/dist/es/projection/node/create-projection-node.mjs +5 -4
- package/dist/es/render/VisualElement.mjs +3 -0
- package/dist/es/render/dom/utils/is-svg-element.mjs +5 -0
- package/dist/es/render/store.mjs +3 -0
- package/dist/es/render/utils/animation-state.mjs +1 -1
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/utils/interpolate.mjs +6 -0
- package/dist/es/value/index.mjs +1 -1
- package/dist/es/value/use-spring.mjs +1 -1
- package/dist/framer-motion.dev.js +4948 -4872
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +57 -51
- package/dist/projection.dev.js +4982 -5008
- package/dist/three-entry.d.ts +6 -10
- package/package.json +5 -5
- package/dist/es/render/utils/animation.mjs +0 -145
- /package/dist/es/animation/{waapi → animators/waapi}/easing.mjs +0 -0
- /package/dist/es/animation/{waapi → animators/waapi}/index.mjs +0 -0
- /package/dist/es/animation/{waapi → animators/waapi}/supports.mjs +0 -0
- /package/dist/es/animation/{waapi → animators/waapi}/utils/get-final-keyframe.mjs +0 -0
package/dist/three-entry.d.ts
CHANGED
|
@@ -862,10 +862,7 @@ interface AnimationPlaybackControls {
|
|
|
862
862
|
pause: () => void;
|
|
863
863
|
then: (onResolve: VoidFunction, onReject?: VoidFunction) => Promise<void>;
|
|
864
864
|
}
|
|
865
|
-
|
|
866
|
-
* @public
|
|
867
|
-
*/
|
|
868
|
-
declare type ControlsAnimationDefinition = string | string[] | TargetAndTransition | TargetResolver;
|
|
865
|
+
declare type AnimationDefinition = VariantLabels | TargetAndTransition | TargetResolver;
|
|
869
866
|
/**
|
|
870
867
|
* @public
|
|
871
868
|
*/
|
|
@@ -889,7 +886,7 @@ interface AnimationControls {
|
|
|
889
886
|
*
|
|
890
887
|
* @public
|
|
891
888
|
*/
|
|
892
|
-
start(definition:
|
|
889
|
+
start(definition: AnimationDefinition, transitionOverride?: Transition): Promise<any>;
|
|
893
890
|
/**
|
|
894
891
|
* Instantly set to a set of properties or a variant.
|
|
895
892
|
*
|
|
@@ -910,7 +907,7 @@ interface AnimationControls {
|
|
|
910
907
|
*
|
|
911
908
|
* @public
|
|
912
909
|
*/
|
|
913
|
-
set(definition:
|
|
910
|
+
set(definition: AnimationDefinition): void;
|
|
914
911
|
/**
|
|
915
912
|
* Stops animations on all linked components.
|
|
916
913
|
*
|
|
@@ -1451,8 +1448,7 @@ interface FeatureBundle extends FeaturePackages {
|
|
|
1451
1448
|
|
|
1452
1449
|
declare type AnimationType = "animate" | "whileHover" | "whileTap" | "whileDrag" | "whileFocus" | "whileInView" | "exit";
|
|
1453
1450
|
|
|
1454
|
-
declare type
|
|
1455
|
-
declare type AnimationOptions = {
|
|
1451
|
+
declare type VisualElementAnimationOptions = {
|
|
1456
1452
|
delay?: number;
|
|
1457
1453
|
transitionOverride?: Transition;
|
|
1458
1454
|
custom?: any;
|
|
@@ -1460,8 +1456,8 @@ declare type AnimationOptions = {
|
|
|
1460
1456
|
};
|
|
1461
1457
|
|
|
1462
1458
|
interface AnimationState {
|
|
1463
|
-
animateChanges: (options?:
|
|
1464
|
-
setActive: (type: AnimationType, isActive: boolean, options?:
|
|
1459
|
+
animateChanges: (options?: VisualElementAnimationOptions, type?: AnimationType) => Promise<any>;
|
|
1460
|
+
setActive: (type: AnimationType, isActive: boolean, options?: VisualElementAnimationOptions) => Promise<any>;
|
|
1465
1461
|
setAnimateFunction: (fn: any) => void;
|
|
1466
1462
|
getState: () => {
|
|
1467
1463
|
[key: string]: AnimationTypeState;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "framer-motion",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.4.0",
|
|
4
4
|
"description": "A simple and powerful React and JavaScript animation library",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/es/index.mjs",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
"path": "./dist/size-rollup-dom-animation.js",
|
|
96
|
-
"maxSize": "14.
|
|
96
|
+
"maxSize": "14.74 kB"
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
"path": "./dist/size-rollup-dom-max.js",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
},
|
|
102
102
|
{
|
|
103
103
|
"path": "./dist/size-rollup-animate.js",
|
|
104
|
-
"maxSize": "
|
|
104
|
+
"maxSize": "15 kB"
|
|
105
105
|
},
|
|
106
106
|
{
|
|
107
107
|
"path": "./dist/size-webpack-m.js",
|
|
@@ -109,12 +109,12 @@
|
|
|
109
109
|
},
|
|
110
110
|
{
|
|
111
111
|
"path": "./dist/size-webpack-dom-animation.js",
|
|
112
|
-
"maxSize": "18.
|
|
112
|
+
"maxSize": "18.78 kB"
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
"path": "./dist/size-webpack-dom-max.js",
|
|
116
116
|
"maxSize": "30.8 kB"
|
|
117
117
|
}
|
|
118
118
|
],
|
|
119
|
-
"gitHead": "
|
|
119
|
+
"gitHead": "3a3c4d1daa52b0ad724591e743fdebcad8f5aaf3"
|
|
120
120
|
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { setTarget } from './setters.mjs';
|
|
2
|
-
import { resolveVariant } from './resolve-dynamic-variants.mjs';
|
|
3
|
-
import { transformProps } from '../html/utils/transform.mjs';
|
|
4
|
-
import { isWillChangeMotionValue } from '../../value/use-will-change/is.mjs';
|
|
5
|
-
import { optimizedAppearDataAttribute } from '../../animation/optimized-appear/data-id.mjs';
|
|
6
|
-
import { createMotionValueAnimation } from '../../animation/index.mjs';
|
|
7
|
-
import { sync } from '../../frameloop/index.mjs';
|
|
8
|
-
|
|
9
|
-
function animateVisualElement(visualElement, definition, options = {}) {
|
|
10
|
-
visualElement.notify("AnimationStart", definition);
|
|
11
|
-
let animation;
|
|
12
|
-
if (Array.isArray(definition)) {
|
|
13
|
-
const animations = definition.map((variant) => animateVariant(visualElement, variant, options));
|
|
14
|
-
animation = Promise.all(animations);
|
|
15
|
-
}
|
|
16
|
-
else if (typeof definition === "string") {
|
|
17
|
-
animation = animateVariant(visualElement, definition, options);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
const resolvedDefinition = typeof definition === "function"
|
|
21
|
-
? resolveVariant(visualElement, definition, options.custom)
|
|
22
|
-
: definition;
|
|
23
|
-
animation = animateTarget(visualElement, resolvedDefinition, options);
|
|
24
|
-
}
|
|
25
|
-
return animation.then(() => visualElement.notify("AnimationComplete", definition));
|
|
26
|
-
}
|
|
27
|
-
function animateVariant(visualElement, variant, options = {}) {
|
|
28
|
-
const resolved = resolveVariant(visualElement, variant, options.custom);
|
|
29
|
-
let { transition = visualElement.getDefaultTransition() || {} } = resolved || {};
|
|
30
|
-
if (options.transitionOverride) {
|
|
31
|
-
transition = options.transitionOverride;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* If we have a variant, create a callback that runs it as an animation.
|
|
35
|
-
* Otherwise, we resolve a Promise immediately for a composable no-op.
|
|
36
|
-
*/
|
|
37
|
-
const getAnimation = resolved
|
|
38
|
-
? () => animateTarget(visualElement, resolved, options)
|
|
39
|
-
: () => Promise.resolve();
|
|
40
|
-
/**
|
|
41
|
-
* If we have children, create a callback that runs all their animations.
|
|
42
|
-
* Otherwise, we resolve a Promise immediately for a composable no-op.
|
|
43
|
-
*/
|
|
44
|
-
const getChildAnimations = visualElement.variantChildren && visualElement.variantChildren.size
|
|
45
|
-
? (forwardDelay = 0) => {
|
|
46
|
-
const { delayChildren = 0, staggerChildren, staggerDirection, } = transition;
|
|
47
|
-
return animateChildren(visualElement, variant, delayChildren + forwardDelay, staggerChildren, staggerDirection, options);
|
|
48
|
-
}
|
|
49
|
-
: () => Promise.resolve();
|
|
50
|
-
/**
|
|
51
|
-
* If the transition explicitly defines a "when" option, we need to resolve either
|
|
52
|
-
* this animation or all children animations before playing the other.
|
|
53
|
-
*/
|
|
54
|
-
const { when } = transition;
|
|
55
|
-
if (when) {
|
|
56
|
-
const [first, last] = when === "beforeChildren"
|
|
57
|
-
? [getAnimation, getChildAnimations]
|
|
58
|
-
: [getChildAnimations, getAnimation];
|
|
59
|
-
return first().then(last);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
return Promise.all([getAnimation(), getChildAnimations(options.delay)]);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* @internal
|
|
67
|
-
*/
|
|
68
|
-
function animateTarget(visualElement, definition, { delay = 0, transitionOverride, type } = {}) {
|
|
69
|
-
let { transition = visualElement.getDefaultTransition(), transitionEnd, ...target } = visualElement.makeTargetAnimatable(definition);
|
|
70
|
-
const willChange = visualElement.getValue("willChange");
|
|
71
|
-
if (transitionOverride)
|
|
72
|
-
transition = transitionOverride;
|
|
73
|
-
const animations = [];
|
|
74
|
-
const animationTypeState = type &&
|
|
75
|
-
visualElement.animationState &&
|
|
76
|
-
visualElement.animationState.getState()[type];
|
|
77
|
-
for (const key in target) {
|
|
78
|
-
const value = visualElement.getValue(key);
|
|
79
|
-
const valueTarget = target[key];
|
|
80
|
-
if (!value ||
|
|
81
|
-
valueTarget === undefined ||
|
|
82
|
-
(animationTypeState &&
|
|
83
|
-
shouldBlockAnimation(animationTypeState, key))) {
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
const valueTransition = { delay, elapsed: 0, ...transition };
|
|
87
|
-
/**
|
|
88
|
-
* If this is the first time a value is being animated, check
|
|
89
|
-
* to see if we're handling off from an existing animation.
|
|
90
|
-
*/
|
|
91
|
-
if (window.HandoffAppearAnimations && !value.hasAnimated) {
|
|
92
|
-
const appearId = visualElement.getProps()[optimizedAppearDataAttribute];
|
|
93
|
-
if (appearId) {
|
|
94
|
-
valueTransition.elapsed = window.HandoffAppearAnimations(appearId, key, value, sync);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
let animation = value.start(createMotionValueAnimation(key, value, valueTarget, visualElement.shouldReduceMotion && transformProps.has(key)
|
|
98
|
-
? { type: false }
|
|
99
|
-
: valueTransition));
|
|
100
|
-
if (isWillChangeMotionValue(willChange)) {
|
|
101
|
-
willChange.add(key);
|
|
102
|
-
animation = animation.then(() => willChange.remove(key));
|
|
103
|
-
}
|
|
104
|
-
animations.push(animation);
|
|
105
|
-
}
|
|
106
|
-
return Promise.all(animations).then(() => {
|
|
107
|
-
transitionEnd && setTarget(visualElement, transitionEnd);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
function animateChildren(visualElement, variant, delayChildren = 0, staggerChildren = 0, staggerDirection = 1, options) {
|
|
111
|
-
const animations = [];
|
|
112
|
-
const maxStaggerDuration = (visualElement.variantChildren.size - 1) * staggerChildren;
|
|
113
|
-
const generateStaggerDuration = staggerDirection === 1
|
|
114
|
-
? (i = 0) => i * staggerChildren
|
|
115
|
-
: (i = 0) => maxStaggerDuration - i * staggerChildren;
|
|
116
|
-
Array.from(visualElement.variantChildren)
|
|
117
|
-
.sort(sortByTreeOrder)
|
|
118
|
-
.forEach((child, i) => {
|
|
119
|
-
child.notify("AnimationStart", variant);
|
|
120
|
-
animations.push(animateVariant(child, variant, {
|
|
121
|
-
...options,
|
|
122
|
-
delay: delayChildren + generateStaggerDuration(i),
|
|
123
|
-
}).then(() => child.notify("AnimationComplete", variant)));
|
|
124
|
-
});
|
|
125
|
-
return Promise.all(animations);
|
|
126
|
-
}
|
|
127
|
-
function stopAnimation(visualElement) {
|
|
128
|
-
visualElement.values.forEach((value) => value.stop());
|
|
129
|
-
}
|
|
130
|
-
function sortByTreeOrder(a, b) {
|
|
131
|
-
return a.sortNodePosition(b);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Decide whether we should block this animation. Previously, we achieved this
|
|
135
|
-
* just by checking whether the key was listed in protectedKeys, but this
|
|
136
|
-
* posed problems if an animation was triggered by afterChildren and protectedKeys
|
|
137
|
-
* had been set to true in the meantime.
|
|
138
|
-
*/
|
|
139
|
-
function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
|
|
140
|
-
const shouldBlock = protectedKeys.hasOwnProperty(key) && needsAnimating[key] !== true;
|
|
141
|
-
needsAnimating[key] = false;
|
|
142
|
-
return shouldBlock;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export { animateVisualElement, sortByTreeOrder, stopAnimation };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|