motion 11.15.0 → 11.16.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/README.md +3 -19
- package/dist/cjs/index.js +1677 -1645
- package/dist/cjs/mini.js +215 -185
- package/dist/cjs/react-client.js +3651 -3638
- package/dist/cjs/react-mini.js +215 -185
- package/dist/es/framer-motion/dist/es/animation/animate/index.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animate/resolve-subjects.mjs +1 -0
- package/dist/es/framer-motion/dist/es/animation/animate/single-value.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +7 -7
- package/dist/es/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +8 -8
- package/dist/es/framer-motion/dist/es/animation/animators/utils/can-animate.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +26 -89
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +3 -3
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/index.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/generators/spring/find.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/generators/spring/index.mjs +9 -6
- package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +7 -6
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +4 -3
- package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +8 -8
- package/dist/es/framer-motion/dist/es/easing/utils/map.mjs +4 -4
- package/dist/es/framer-motion/dist/es/events/event-info.mjs +1 -0
- package/dist/es/framer-motion/dist/es/gestures/drag/utils/constraints.mjs +2 -1
- package/dist/es/framer-motion/dist/es/gestures/hover.mjs +1 -0
- package/dist/es/framer-motion/dist/es/gestures/pan/PanSession.mjs +5 -4
- package/dist/es/framer-motion/dist/es/gestures/press.mjs +1 -0
- package/dist/es/framer-motion/dist/es/projection/animation/mix-values.mjs +3 -3
- package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +15 -15
- package/dist/es/framer-motion/dist/es/render/dom/resize/handle-element.mjs +1 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/index.mjs +3 -3
- package/dist/es/framer-motion/dist/es/render/dom/scroll/info.mjs +2 -1
- package/dist/es/framer-motion/dist/es/render/dom/viewport/index.mjs +1 -0
- package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/delay.mjs +2 -1
- package/dist/es/framer-motion/dist/es/utils/interpolate.mjs +3 -3
- package/dist/es/framer-motion/dist/es/utils/offsets/fill.mjs +2 -1
- package/dist/es/framer-motion/dist/es/value/index.mjs +2 -2
- package/dist/es/framer-motion/dist/es/value/use-spring.mjs +3 -3
- package/dist/es/motion/lib/index.mjs +8 -8
- package/dist/es/motion/lib/react.mjs +8 -8
- package/dist/es/{framer-motion/dist/es/animation/GroupPlaybackControls.mjs → motion-dom/dist/es/animation/controls/BaseGroup.mjs} +6 -5
- package/dist/es/motion-dom/dist/es/animation/controls/Group.mjs +13 -0
- package/dist/es/{framer-motion/dist/es/easing → motion-dom/dist/es/animation/generators}/utils/create-generator-easing.mjs +6 -3
- package/dist/es/motion-dom/dist/es/animation/waapi/NativeAnimationControls.mjs +85 -0
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi → motion-dom/dist/es/animation/waapi/utils}/easing.mjs +3 -3
- package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation}/waapi/utils/linear.mjs +2 -1
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/supports-linear-easing.mjs → motion-dom/dist/es/utils/supports/linear-easing.mjs} +1 -1
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/memo-supports.mjs → motion-dom/dist/es/utils/supports/memo.mjs} +3 -2
- package/dist/es/motion-dom/dist/es/utils/supports/scroll-timeline.mjs +6 -0
- package/dist/motion.dev.js +1677 -1645
- package/dist/motion.js +1 -1
- package/package.json +3 -3
- package/dist/es/framer-motion/dist/es/render/dom/scroll/supports.mjs +0 -5
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/utils/calc-duration.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/utils/is-generator.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/utils/get-value-transition.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation}/waapi/utils/attach-timeline.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/easing → motion-dom/dist/es}/utils/is-bezier-definition.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/supports-flags.mjs → motion-dom/dist/es/utils/supports/flags.mjs} +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/memo.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/progress.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/time-conversion.mjs +0 -0
package/dist/cjs/react-mini.js
CHANGED
|
@@ -23,6 +23,17 @@ function useUnmountEffect(callback) {
|
|
|
23
23
|
return react.useEffect(() => () => callback(), []);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
const noop = (any) => any;
|
|
27
|
+
|
|
28
|
+
let invariant = noop;
|
|
29
|
+
if (process.env.NODE_ENV !== "production") {
|
|
30
|
+
invariant = (check, message) => {
|
|
31
|
+
if (!check) {
|
|
32
|
+
throw new Error(message);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
26
37
|
function memo(callback) {
|
|
27
38
|
let result;
|
|
28
39
|
return () => {
|
|
@@ -32,16 +43,43 @@ function memo(callback) {
|
|
|
32
43
|
};
|
|
33
44
|
}
|
|
34
45
|
|
|
46
|
+
/*
|
|
47
|
+
Progress within given range
|
|
48
|
+
|
|
49
|
+
Given a lower limit and an upper limit, we return the progress
|
|
50
|
+
(expressed as a number 0-1) represented by the given value, and
|
|
51
|
+
limit that progress to within 0-1.
|
|
52
|
+
|
|
53
|
+
@param [number]: Lower limit
|
|
54
|
+
@param [number]: Upper limit
|
|
55
|
+
@param [number]: Value to find progress within given range
|
|
56
|
+
@return [number]: Progress of value within range as expressed 0-1
|
|
57
|
+
*/
|
|
58
|
+
const progress = (from, to, value) => {
|
|
59
|
+
const toFromDifference = to - from;
|
|
60
|
+
return toFromDifference === 0 ? 1 : (value - from) / toFromDifference;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Converts seconds to milliseconds
|
|
65
|
+
*
|
|
66
|
+
* @param seconds - Time in seconds.
|
|
67
|
+
* @return milliseconds - Converted time in milliseconds.
|
|
68
|
+
*/
|
|
69
|
+
const secondsToMilliseconds = (seconds) => seconds * 1000;
|
|
70
|
+
const millisecondsToSeconds = (milliseconds) => milliseconds / 1000;
|
|
71
|
+
|
|
35
72
|
const supportsScrollTimeline = memo(() => window.ScrollTimeline !== undefined);
|
|
36
73
|
|
|
37
|
-
class
|
|
74
|
+
class BaseGroupPlaybackControls {
|
|
38
75
|
constructor(animations) {
|
|
39
76
|
// Bound to accomodate common `return animation.stop` pattern
|
|
40
77
|
this.stop = () => this.runAll("stop");
|
|
41
78
|
this.animations = animations.filter(Boolean);
|
|
42
79
|
}
|
|
43
|
-
|
|
44
|
-
|
|
80
|
+
get finished() {
|
|
81
|
+
// Support for new finished Promise and legacy thennable API
|
|
82
|
+
return Promise.all(this.animations.map((animation) => "finished" in animation ? animation.finished : animation));
|
|
45
83
|
}
|
|
46
84
|
/**
|
|
47
85
|
* TODO: Filter out cancelled or stopped animations before returning
|
|
@@ -112,46 +150,15 @@ class GroupPlaybackControls {
|
|
|
112
150
|
}
|
|
113
151
|
}
|
|
114
152
|
|
|
115
|
-
function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
116
|
-
var _a;
|
|
117
|
-
if (elementOrSelector instanceof Element) {
|
|
118
|
-
return [elementOrSelector];
|
|
119
|
-
}
|
|
120
|
-
else if (typeof elementOrSelector === "string") {
|
|
121
|
-
let root = document;
|
|
122
|
-
if (scope) {
|
|
123
|
-
// TODO: Refactor to utils package
|
|
124
|
-
// invariant(
|
|
125
|
-
// Boolean(scope.current),
|
|
126
|
-
// "Scope provided, but no element detected."
|
|
127
|
-
// )
|
|
128
|
-
root = scope.current;
|
|
129
|
-
}
|
|
130
|
-
const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
|
|
131
|
-
return elements ? Array.from(elements) : [];
|
|
132
|
-
}
|
|
133
|
-
return Array.from(elementOrSelector);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const noop = (any) => any;
|
|
137
|
-
|
|
138
|
-
let invariant = noop;
|
|
139
|
-
if (process.env.NODE_ENV !== "production") {
|
|
140
|
-
invariant = (check, message) => {
|
|
141
|
-
if (!check) {
|
|
142
|
-
throw new Error(message);
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
153
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* @param seconds - Time in seconds.
|
|
151
|
-
* @return milliseconds - Converted time in milliseconds.
|
|
154
|
+
* TODO: This is a temporary class to support the legacy
|
|
155
|
+
* thennable API
|
|
152
156
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
157
|
+
class GroupPlaybackControls extends BaseGroupPlaybackControls {
|
|
158
|
+
then(onResolve, onReject) {
|
|
159
|
+
return Promise.all(this.animations).then(onResolve).catch(onReject);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
155
162
|
|
|
156
163
|
function getValueTransition(transition, key) {
|
|
157
164
|
return transition
|
|
@@ -161,35 +168,126 @@ function getValueTransition(transition, key) {
|
|
|
161
168
|
: undefined;
|
|
162
169
|
}
|
|
163
170
|
|
|
164
|
-
|
|
171
|
+
/**
|
|
172
|
+
* Implement a practical max duration for keyframe generation
|
|
173
|
+
* to prevent infinite loops
|
|
174
|
+
*/
|
|
175
|
+
const maxGeneratorDuration = 20000;
|
|
176
|
+
function calcGeneratorDuration(generator) {
|
|
177
|
+
let duration = 0;
|
|
178
|
+
const timeStep = 50;
|
|
179
|
+
let state = generator.next(duration);
|
|
180
|
+
while (!state.done && duration < maxGeneratorDuration) {
|
|
181
|
+
duration += timeStep;
|
|
182
|
+
state = generator.next(duration);
|
|
183
|
+
}
|
|
184
|
+
return duration >= maxGeneratorDuration ? Infinity : duration;
|
|
185
|
+
}
|
|
165
186
|
|
|
166
|
-
|
|
167
|
-
|
|
187
|
+
/**
|
|
188
|
+
* Create a progress => progress easing function from a generator.
|
|
189
|
+
*/
|
|
190
|
+
function createGeneratorEasing(options, scale = 100, createGenerator) {
|
|
191
|
+
const generator = createGenerator({ ...options, keyframes: [0, scale] });
|
|
192
|
+
const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
|
|
193
|
+
return {
|
|
194
|
+
type: "keyframes",
|
|
195
|
+
ease: (progress) => {
|
|
196
|
+
return generator.next(duration * progress).value / scale;
|
|
197
|
+
},
|
|
198
|
+
duration: millisecondsToSeconds(duration),
|
|
199
|
+
};
|
|
200
|
+
}
|
|
168
201
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
202
|
+
function isGenerator(type) {
|
|
203
|
+
return typeof type === "function";
|
|
204
|
+
}
|
|
172
205
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
*/
|
|
178
|
-
const progress = (from, to, value) => {
|
|
179
|
-
const toFromDifference = to - from;
|
|
180
|
-
return toFromDifference === 0 ? 1 : (value - from) / toFromDifference;
|
|
181
|
-
};
|
|
206
|
+
function attachTimeline(animation, timeline) {
|
|
207
|
+
animation.timeline = timeline;
|
|
208
|
+
animation.onfinish = null;
|
|
209
|
+
}
|
|
182
210
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
let points = "";
|
|
187
|
-
const numPoints = Math.max(Math.round(duration / resolution), 2);
|
|
188
|
-
for (let i = 0; i < numPoints; i++) {
|
|
189
|
-
points += easing(progress(0, numPoints - 1, i)) + ", ";
|
|
211
|
+
class NativeAnimationControls {
|
|
212
|
+
constructor(animation) {
|
|
213
|
+
this.animation = animation;
|
|
190
214
|
}
|
|
191
|
-
|
|
192
|
-
|
|
215
|
+
get duration() {
|
|
216
|
+
var _a, _b, _c;
|
|
217
|
+
const durationInMs = ((_b = (_a = this.animation) === null || _a === void 0 ? void 0 : _a.effect) === null || _b === void 0 ? void 0 : _b.getComputedTiming().duration) ||
|
|
218
|
+
((_c = this.options) === null || _c === void 0 ? void 0 : _c.duration) ||
|
|
219
|
+
300;
|
|
220
|
+
return millisecondsToSeconds(Number(durationInMs));
|
|
221
|
+
}
|
|
222
|
+
get time() {
|
|
223
|
+
var _a;
|
|
224
|
+
if (this.animation) {
|
|
225
|
+
return millisecondsToSeconds(((_a = this.animation) === null || _a === void 0 ? void 0 : _a.currentTime) || 0);
|
|
226
|
+
}
|
|
227
|
+
return 0;
|
|
228
|
+
}
|
|
229
|
+
set time(newTime) {
|
|
230
|
+
if (this.animation) {
|
|
231
|
+
this.animation.currentTime = secondsToMilliseconds(newTime);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
get speed() {
|
|
235
|
+
return this.animation ? this.animation.playbackRate : 1;
|
|
236
|
+
}
|
|
237
|
+
set speed(newSpeed) {
|
|
238
|
+
if (this.animation) {
|
|
239
|
+
this.animation.playbackRate = newSpeed;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
get state() {
|
|
243
|
+
return this.animation ? this.animation.playState : "finished";
|
|
244
|
+
}
|
|
245
|
+
get startTime() {
|
|
246
|
+
return this.animation ? this.animation.startTime : null;
|
|
247
|
+
}
|
|
248
|
+
get finished() {
|
|
249
|
+
return this.animation ? this.animation.finished : Promise.resolve();
|
|
250
|
+
}
|
|
251
|
+
play() {
|
|
252
|
+
this.animation && this.animation.play();
|
|
253
|
+
}
|
|
254
|
+
pause() {
|
|
255
|
+
this.animation && this.animation.pause();
|
|
256
|
+
}
|
|
257
|
+
stop() {
|
|
258
|
+
if (!this.animation ||
|
|
259
|
+
this.state === "idle" ||
|
|
260
|
+
this.state === "finished") {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (this.animation.commitStyles) {
|
|
264
|
+
this.animation.commitStyles();
|
|
265
|
+
}
|
|
266
|
+
this.cancel();
|
|
267
|
+
}
|
|
268
|
+
flatten() {
|
|
269
|
+
var _a;
|
|
270
|
+
if (!this.animation)
|
|
271
|
+
return;
|
|
272
|
+
(_a = this.animation.effect) === null || _a === void 0 ? void 0 : _a.updateTiming({ easing: "linear" });
|
|
273
|
+
}
|
|
274
|
+
attachTimeline(timeline) {
|
|
275
|
+
if (this.animation)
|
|
276
|
+
attachTimeline(this.animation, timeline);
|
|
277
|
+
return noop;
|
|
278
|
+
}
|
|
279
|
+
complete() {
|
|
280
|
+
this.animation && this.animation.finish();
|
|
281
|
+
}
|
|
282
|
+
cancel() {
|
|
283
|
+
try {
|
|
284
|
+
this.animation && this.animation.cancel();
|
|
285
|
+
}
|
|
286
|
+
catch (e) { }
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0] === "number";
|
|
193
291
|
|
|
194
292
|
/**
|
|
195
293
|
* Add the ability for test suites to manually set support flags
|
|
@@ -216,6 +314,17 @@ const supportsLinearEasing = /*@__PURE__*/ memoSupports(() => {
|
|
|
216
314
|
return true;
|
|
217
315
|
}, "linearEasing");
|
|
218
316
|
|
|
317
|
+
const generateLinearEasing = (easing, duration, // as milliseconds
|
|
318
|
+
resolution = 10 // as milliseconds
|
|
319
|
+
) => {
|
|
320
|
+
let points = "";
|
|
321
|
+
const numPoints = Math.max(Math.round(duration / resolution), 2);
|
|
322
|
+
for (let i = 0; i < numPoints; i++) {
|
|
323
|
+
points += easing(progress(0, numPoints - 1, i)) + ", ";
|
|
324
|
+
}
|
|
325
|
+
return `linear(${points.substring(0, points.length - 2)})`;
|
|
326
|
+
};
|
|
327
|
+
|
|
219
328
|
const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
|
|
220
329
|
const supportedWaapiEasing = {
|
|
221
330
|
linear: "linear",
|
|
@@ -247,6 +356,27 @@ function mapEasingToNativeEasing(easing, duration) {
|
|
|
247
356
|
}
|
|
248
357
|
}
|
|
249
358
|
|
|
359
|
+
function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
360
|
+
var _a;
|
|
361
|
+
if (elementOrSelector instanceof Element) {
|
|
362
|
+
return [elementOrSelector];
|
|
363
|
+
}
|
|
364
|
+
else if (typeof elementOrSelector === "string") {
|
|
365
|
+
let root = document;
|
|
366
|
+
if (scope) {
|
|
367
|
+
// TODO: Refactor to utils package
|
|
368
|
+
// invariant(
|
|
369
|
+
// Boolean(scope.current),
|
|
370
|
+
// "Scope provided, but no element detected."
|
|
371
|
+
// )
|
|
372
|
+
root = scope.current;
|
|
373
|
+
}
|
|
374
|
+
const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
|
|
375
|
+
return elements ? Array.from(elements) : [];
|
|
376
|
+
}
|
|
377
|
+
return Array.from(elementOrSelector);
|
|
378
|
+
}
|
|
379
|
+
|
|
250
380
|
function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}) {
|
|
251
381
|
const keyframeOptions = { [valueName]: keyframes };
|
|
252
382
|
if (times)
|
|
@@ -267,35 +397,6 @@ function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duratio
|
|
|
267
397
|
});
|
|
268
398
|
}
|
|
269
399
|
|
|
270
|
-
/**
|
|
271
|
-
* Implement a practical max duration for keyframe generation
|
|
272
|
-
* to prevent infinite loops
|
|
273
|
-
*/
|
|
274
|
-
const maxGeneratorDuration = 20000;
|
|
275
|
-
function calcGeneratorDuration(generator) {
|
|
276
|
-
let duration = 0;
|
|
277
|
-
const timeStep = 50;
|
|
278
|
-
let state = generator.next(duration);
|
|
279
|
-
while (!state.done && duration < maxGeneratorDuration) {
|
|
280
|
-
duration += timeStep;
|
|
281
|
-
state = generator.next(duration);
|
|
282
|
-
}
|
|
283
|
-
return duration >= maxGeneratorDuration ? Infinity : duration;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Create a progress => progress easing function from a generator.
|
|
288
|
-
*/
|
|
289
|
-
function createGeneratorEasing(options, scale = 100, createGenerator) {
|
|
290
|
-
const generator = createGenerator({ ...options, keyframes: [0, scale] });
|
|
291
|
-
const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
|
|
292
|
-
return {
|
|
293
|
-
type: "keyframes",
|
|
294
|
-
ease: (progress) => generator.next(duration * progress).value / scale,
|
|
295
|
-
duration: millisecondsToSeconds(duration),
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
|
|
299
400
|
const createUnitType = (unit) => ({
|
|
300
401
|
test: (v) => typeof v === "string" && v.endsWith(unit) && v.split(" ").length === 1,
|
|
301
402
|
parse: parseFloat,
|
|
@@ -341,15 +442,6 @@ const browserNumberValueTypes = {
|
|
|
341
442
|
backgroundPositionY: px,
|
|
342
443
|
};
|
|
343
444
|
|
|
344
|
-
function isGenerator(type) {
|
|
345
|
-
return typeof type === "function";
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function attachTimeline(animation, timeline) {
|
|
349
|
-
animation.timeline = timeline;
|
|
350
|
-
animation.onfinish = null;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
445
|
const isNotNull = (value) => value !== null;
|
|
354
446
|
function getFinalKeyframe(keyframes, { repeat, repeatType = "loop" }, finalKeyframe) {
|
|
355
447
|
const resolvedKeyframes = keyframes.filter(isNotNull);
|
|
@@ -401,12 +493,9 @@ function getElementAnimationState(element) {
|
|
|
401
493
|
state.set(element, animationState);
|
|
402
494
|
return state.get(element);
|
|
403
495
|
}
|
|
404
|
-
class NativeAnimation {
|
|
496
|
+
class NativeAnimation extends NativeAnimationControls {
|
|
405
497
|
constructor(element, valueName, valueKeyframes, options) {
|
|
406
498
|
const isCSSVar = valueName.startsWith("--");
|
|
407
|
-
this.setValue = isCSSVar ? setCSSVar : setStyle;
|
|
408
|
-
this.options = options;
|
|
409
|
-
this.updateFinishedPromise();
|
|
410
499
|
invariant(typeof options.type !== "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "framer-motion"?`);
|
|
411
500
|
const existingAnimation = getElementAnimationState(element).get(valueName);
|
|
412
501
|
existingAnimation && existingAnimation.stop();
|
|
@@ -431,92 +520,32 @@ class NativeAnimation {
|
|
|
431
520
|
else {
|
|
432
521
|
options.ease = options.ease || defaultEasing;
|
|
433
522
|
}
|
|
434
|
-
this.removeAnimation = () => { var _a; return (_a = state.get(element)) === null || _a === void 0 ? void 0 : _a.delete(valueName); };
|
|
435
523
|
const onFinish = () => {
|
|
436
|
-
this.setValue(element, valueName, getFinalKeyframe(valueKeyframes,
|
|
524
|
+
this.setValue(element, valueName, getFinalKeyframe(valueKeyframes, options));
|
|
437
525
|
this.cancel();
|
|
438
526
|
this.resolveFinishedPromise();
|
|
439
527
|
};
|
|
528
|
+
const init = () => {
|
|
529
|
+
this.setValue = isCSSVar ? setCSSVar : setStyle;
|
|
530
|
+
this.options = options;
|
|
531
|
+
this.updateFinishedPromise();
|
|
532
|
+
this.removeAnimation = () => { var _a; return (_a = state.get(element)) === null || _a === void 0 ? void 0 : _a.delete(valueName); };
|
|
533
|
+
};
|
|
440
534
|
if (!supportsWaapi()) {
|
|
535
|
+
super();
|
|
536
|
+
init();
|
|
441
537
|
onFinish();
|
|
442
538
|
}
|
|
443
539
|
else {
|
|
444
|
-
|
|
540
|
+
super(startWaapiAnimation(element, valueName, valueKeyframes, options));
|
|
541
|
+
init();
|
|
445
542
|
if (options.autoplay === false) {
|
|
446
543
|
this.animation.pause();
|
|
447
544
|
}
|
|
448
545
|
this.animation.onfinish = onFinish;
|
|
449
|
-
if (this.pendingTimeline) {
|
|
450
|
-
attachTimeline(this.animation, this.pendingTimeline);
|
|
451
|
-
}
|
|
452
546
|
getElementAnimationState(element).set(valueName, this);
|
|
453
547
|
}
|
|
454
548
|
}
|
|
455
|
-
get duration() {
|
|
456
|
-
return millisecondsToSeconds(this.options.duration || 300);
|
|
457
|
-
}
|
|
458
|
-
get time() {
|
|
459
|
-
var _a;
|
|
460
|
-
if (this.animation) {
|
|
461
|
-
return millisecondsToSeconds(((_a = this.animation) === null || _a === void 0 ? void 0 : _a.currentTime) || 0);
|
|
462
|
-
}
|
|
463
|
-
return 0;
|
|
464
|
-
}
|
|
465
|
-
set time(newTime) {
|
|
466
|
-
if (this.animation) {
|
|
467
|
-
this.animation.currentTime = secondsToMilliseconds(newTime);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
get speed() {
|
|
471
|
-
return this.animation ? this.animation.playbackRate : 1;
|
|
472
|
-
}
|
|
473
|
-
set speed(newSpeed) {
|
|
474
|
-
if (this.animation) {
|
|
475
|
-
this.animation.playbackRate = newSpeed;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
get state() {
|
|
479
|
-
return this.animation ? this.animation.playState : "finished";
|
|
480
|
-
}
|
|
481
|
-
get startTime() {
|
|
482
|
-
return this.animation ? this.animation.startTime : null;
|
|
483
|
-
}
|
|
484
|
-
flatten() {
|
|
485
|
-
var _a;
|
|
486
|
-
if (!this.animation)
|
|
487
|
-
return;
|
|
488
|
-
(_a = this.animation.effect) === null || _a === void 0 ? void 0 : _a.updateTiming({ easing: "linear" });
|
|
489
|
-
}
|
|
490
|
-
play() {
|
|
491
|
-
if (this.state === "finished") {
|
|
492
|
-
this.updateFinishedPromise();
|
|
493
|
-
}
|
|
494
|
-
this.animation && this.animation.play();
|
|
495
|
-
}
|
|
496
|
-
pause() {
|
|
497
|
-
this.animation && this.animation.pause();
|
|
498
|
-
}
|
|
499
|
-
stop() {
|
|
500
|
-
if (!this.animation ||
|
|
501
|
-
this.state === "idle" ||
|
|
502
|
-
this.state === "finished") {
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
if (this.animation.commitStyles) {
|
|
506
|
-
this.animation.commitStyles();
|
|
507
|
-
}
|
|
508
|
-
this.cancel();
|
|
509
|
-
}
|
|
510
|
-
complete() {
|
|
511
|
-
this.animation && this.animation.finish();
|
|
512
|
-
}
|
|
513
|
-
cancel() {
|
|
514
|
-
this.removeAnimation();
|
|
515
|
-
try {
|
|
516
|
-
this.animation && this.animation.cancel();
|
|
517
|
-
}
|
|
518
|
-
catch (e) { }
|
|
519
|
-
}
|
|
520
549
|
/**
|
|
521
550
|
* Allows the returned animation to be awaited or promise-chained. Currently
|
|
522
551
|
* resolves when the animation finishes at all but in a future update could/should
|
|
@@ -530,14 +559,15 @@ class NativeAnimation {
|
|
|
530
559
|
this.resolveFinishedPromise = resolve;
|
|
531
560
|
});
|
|
532
561
|
}
|
|
533
|
-
|
|
534
|
-
if (
|
|
535
|
-
this.
|
|
536
|
-
}
|
|
537
|
-
else {
|
|
538
|
-
attachTimeline(this.animation, timeline);
|
|
562
|
+
play() {
|
|
563
|
+
if (this.state === "finished") {
|
|
564
|
+
this.updateFinishedPromise();
|
|
539
565
|
}
|
|
540
|
-
|
|
566
|
+
super.play();
|
|
567
|
+
}
|
|
568
|
+
cancel() {
|
|
569
|
+
this.removeAnimation();
|
|
570
|
+
super.cancel();
|
|
541
571
|
}
|
|
542
572
|
}
|
|
543
573
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { GroupPlaybackControls } from '
|
|
1
|
+
import { GroupPlaybackControls } from '../../../../../motion-dom/dist/es/animation/controls/Group.mjs';
|
|
2
|
+
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
3
|
import { animateSequence } from './sequence.mjs';
|
|
3
4
|
import { animateSubject } from './subject.mjs';
|
|
4
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { animateMotionValue } from '../interfaces/motion-value.mjs';
|
|
2
1
|
import { motionValue } from '../../value/index.mjs';
|
|
3
2
|
import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
|
|
3
|
+
import { animateMotionValue } from '../interfaces/motion-value.mjs';
|
|
4
4
|
|
|
5
5
|
function animateSingleValue(value, keyframes, options) {
|
|
6
6
|
const motionValue$1 = isMotionValue(value) ? value : motionValue(value);
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
+
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
3
|
+
import { millisecondsToSeconds, secondsToMilliseconds } from '../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
4
|
+
import { isGenerator } from '../../../../../motion-dom/dist/es/animation/generators/utils/is-generator.mjs';
|
|
5
|
+
import { attachTimeline } from '../../../../../motion-dom/dist/es/animation/waapi/utils/attach-timeline.mjs';
|
|
6
|
+
import { isWaapiSupportedEasing } from '../../../../../motion-dom/dist/es/animation/waapi/utils/easing.mjs';
|
|
7
|
+
import { supportsLinearEasing } from '../../../../../motion-dom/dist/es/utils/supports/linear-easing.mjs';
|
|
1
8
|
import { anticipate } from '../../easing/anticipate.mjs';
|
|
2
9
|
import { backInOut } from '../../easing/back.mjs';
|
|
3
10
|
import { circInOut } from '../../easing/circ.mjs';
|
|
4
11
|
import { DOMKeyframesResolver } from '../../render/dom/DOMKeyframesResolver.mjs';
|
|
5
|
-
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
6
|
-
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
7
|
-
import { millisecondsToSeconds, secondsToMilliseconds } from '../../utils/time-conversion.mjs';
|
|
8
|
-
import { isGenerator } from '../generators/utils/is-generator.mjs';
|
|
9
12
|
import { BaseAnimation } from './BaseAnimation.mjs';
|
|
10
13
|
import { MainThreadAnimation } from './MainThreadAnimation.mjs';
|
|
11
14
|
import { acceleratedValues } from './utils/accelerated-values.mjs';
|
|
12
15
|
import { startWaapiAnimation } from './waapi/index.mjs';
|
|
13
|
-
import { isWaapiSupportedEasing } from './waapi/easing.mjs';
|
|
14
|
-
import { attachTimeline } from './waapi/utils/attach-timeline.mjs';
|
|
15
16
|
import { getFinalKeyframe } from './waapi/utils/get-final-keyframe.mjs';
|
|
16
|
-
import { supportsLinearEasing } from './waapi/utils/supports-linear-easing.mjs';
|
|
17
17
|
import { supportsWaapi } from './waapi/utils/supports-waapi.mjs';
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { millisecondsToSeconds, secondsToMilliseconds } from '../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
3
|
+
import { calcGeneratorDuration } from '../../../../../motion-dom/dist/es/animation/generators/utils/calc-duration.mjs';
|
|
4
|
+
import { isGenerator } from '../../../../../motion-dom/dist/es/animation/generators/utils/is-generator.mjs';
|
|
1
5
|
import { KeyframeResolver } from '../../render/utils/KeyframesResolver.mjs';
|
|
2
|
-
import {
|
|
6
|
+
import { clamp } from '../../utils/clamp.mjs';
|
|
7
|
+
import { mix } from '../../utils/mix/index.mjs';
|
|
8
|
+
import { pipe } from '../../utils/pipe.mjs';
|
|
3
9
|
import { inertia } from '../generators/inertia.mjs';
|
|
4
10
|
import { keyframes } from '../generators/keyframes.mjs';
|
|
11
|
+
import { spring } from '../generators/spring/index.mjs';
|
|
5
12
|
import { BaseAnimation } from './BaseAnimation.mjs';
|
|
6
|
-
import { pipe } from '../../utils/pipe.mjs';
|
|
7
|
-
import { mix } from '../../utils/mix/index.mjs';
|
|
8
|
-
import { calcGeneratorDuration } from '../generators/utils/calc-duration.mjs';
|
|
9
|
-
import { millisecondsToSeconds, secondsToMilliseconds } from '../../utils/time-conversion.mjs';
|
|
10
|
-
import { clamp } from '../../utils/clamp.mjs';
|
|
11
|
-
import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
12
13
|
import { frameloopDriver } from './drivers/driver-frameloop.mjs';
|
|
13
14
|
import { getFinalKeyframe } from './waapi/utils/get-final-keyframe.mjs';
|
|
14
|
-
import { isGenerator } from '../generators/utils/is-generator.mjs';
|
|
15
15
|
|
|
16
16
|
const generators = {
|
|
17
17
|
decay: inertia,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { warning } from '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
-
import { isGenerator } from '
|
|
2
|
+
import { isGenerator } from '../../../../../../motion-dom/dist/es/animation/generators/utils/is-generator.mjs';
|
|
3
3
|
import { isAnimatable } from '../../utils/is-animatable.mjs';
|
|
4
4
|
|
|
5
5
|
function hasKeyframesChanged(keyframes) {
|