@wix/motion 2.1.6 → 2.1.7
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 +129 -123
- package/dist/cjs/motion.js +1 -1
- package/dist/cjs/motion.js.map +1 -1
- package/dist/es/motion.js +212 -206
- package/dist/es/motion.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/AnimationGroup.d.ts +2 -0
- package/dist/types/AnimationGroup.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/es/motion.js
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
class
|
|
1
|
+
class O {
|
|
2
2
|
animations;
|
|
3
3
|
options;
|
|
4
4
|
ready;
|
|
5
5
|
isCSS;
|
|
6
6
|
longestAnimation;
|
|
7
|
-
constructor(
|
|
8
|
-
this.animations =
|
|
7
|
+
constructor(t, n) {
|
|
8
|
+
this.animations = t, this.options = n, this.ready = n?.measured || Promise.resolve(), this.isCSS = t[0] instanceof CSSAnimation, this.longestAnimation = this._getAnimationWithLongestEndTime();
|
|
9
9
|
}
|
|
10
10
|
_getAnimationWithLongestEndTime() {
|
|
11
|
-
return this.animations.reduce((
|
|
12
|
-
const i =
|
|
13
|
-
return i > s ?
|
|
11
|
+
return this.animations.reduce((t, n) => {
|
|
12
|
+
const i = t.effect?.getComputedTiming().endTime ?? 0, s = n.effect?.getComputedTiming().endTime ?? 0;
|
|
13
|
+
return i > s ? t : n;
|
|
14
14
|
}, this.animations[0]);
|
|
15
15
|
}
|
|
16
16
|
getProgress() {
|
|
17
17
|
return this.longestAnimation?.effect?.getComputedTiming().progress || 0;
|
|
18
18
|
}
|
|
19
|
-
async play(
|
|
19
|
+
async play(t) {
|
|
20
20
|
await this.ready;
|
|
21
21
|
for (const n of this.animations)
|
|
22
22
|
n.play();
|
|
23
|
-
await Promise.all(this.animations.map((n) => n.ready)),
|
|
23
|
+
await Promise.all(this.animations.map((n) => n.ready)), t && t();
|
|
24
24
|
}
|
|
25
25
|
pause() {
|
|
26
|
-
for (const
|
|
27
|
-
|
|
26
|
+
for (const t of this.animations)
|
|
27
|
+
t.pause();
|
|
28
28
|
}
|
|
29
|
-
async reverse(
|
|
29
|
+
async reverse(t) {
|
|
30
30
|
await this.ready;
|
|
31
31
|
for (const n of this.animations)
|
|
32
32
|
n.reverse();
|
|
33
|
-
await Promise.all(this.animations.map((n) => n.ready)),
|
|
33
|
+
await Promise.all(this.animations.map((n) => n.ready)), t && t();
|
|
34
34
|
}
|
|
35
|
-
progress(
|
|
35
|
+
progress(t) {
|
|
36
36
|
for (const n of this.animations) {
|
|
37
37
|
const { delay: i, duration: s, iterations: r } = n.effect.getTiming(), c = (Number.isFinite(s) ? s : 0) * (Number.isFinite(r) ? r : 1);
|
|
38
|
-
n.currentTime = ((i || 0) + c) *
|
|
38
|
+
n.currentTime = ((i || 0) + c) * t;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
cancel() {
|
|
42
|
-
for (const
|
|
43
|
-
|
|
42
|
+
for (const t of this.animations)
|
|
43
|
+
t.cancel();
|
|
44
44
|
}
|
|
45
|
-
setPlaybackRate(
|
|
45
|
+
setPlaybackRate(t) {
|
|
46
46
|
for (const n of this.animations)
|
|
47
|
-
n.playbackRate =
|
|
47
|
+
n.playbackRate = t;
|
|
48
48
|
}
|
|
49
|
-
async onFinish(
|
|
49
|
+
async onFinish(t) {
|
|
50
50
|
try {
|
|
51
51
|
await Promise.all(this.animations.map((i) => i.finished));
|
|
52
52
|
const n = this.animations[0];
|
|
53
53
|
if (n && !this.isCSS) {
|
|
54
54
|
const i = n.effect?.target;
|
|
55
55
|
if (i) {
|
|
56
|
-
const s = new
|
|
57
|
-
i.dispatchEvent(
|
|
56
|
+
const s = this.options?.effectId || n.id, r = new CustomEvent("animationend", { detail: { effectId: s } });
|
|
57
|
+
i.dispatchEvent(r);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
t();
|
|
61
61
|
} catch (n) {
|
|
62
62
|
console.warn("animation was interrupted - aborting onFinish callback - ", n);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
async onAbort(
|
|
65
|
+
async onAbort(t) {
|
|
66
66
|
try {
|
|
67
67
|
await Promise.all(this.animations.map((n) => n.finished));
|
|
68
68
|
} catch (n) {
|
|
@@ -75,19 +75,25 @@ class I {
|
|
|
75
75
|
s.dispatchEvent(r);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
t();
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
get finished() {
|
|
83
|
-
return Promise.all(this.animations.map((
|
|
83
|
+
return Promise.all(this.animations.map((t) => t.finished));
|
|
84
84
|
}
|
|
85
85
|
get playState() {
|
|
86
|
-
return this.animations[0]?.playState;
|
|
86
|
+
return this.animations.some((t) => t.playState === "running") ? "running" : this.animations[0]?.playState;
|
|
87
|
+
}
|
|
88
|
+
hasAnimationName(t) {
|
|
89
|
+
return this.animations.some((n) => n.animationName === t);
|
|
90
|
+
}
|
|
91
|
+
hasAnimationId(t) {
|
|
92
|
+
return this.animations.some((n) => n.id === t);
|
|
87
93
|
}
|
|
88
94
|
getTimingOptions() {
|
|
89
|
-
return this.animations.map((
|
|
90
|
-
const n =
|
|
95
|
+
return this.animations.map((t) => {
|
|
96
|
+
const n = t.effect?.getTiming(), i = n?.delay ?? 0, s = Number(n?.duration) || 0, r = n?.iterations ?? 1;
|
|
91
97
|
return {
|
|
92
98
|
delay: i,
|
|
93
99
|
duration: s,
|
|
@@ -96,7 +102,7 @@ class I {
|
|
|
96
102
|
});
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
|
-
const G = (
|
|
105
|
+
const G = (e) => e, V = (e) => 1 - Math.cos(e * Math.PI / 2), B = (e) => Math.sin(e * Math.PI / 2), K = (e) => -(Math.cos(Math.PI * e) - 1) / 2, X = (e) => e ** 2, J = (e) => 1 - (1 - e) ** 2, U = (e) => e < 0.5 ? 2 * e ** 2 : 1 - (-2 * e + 2) ** 2 / 2, Y = (e) => e ** 3, Q = (e) => 1 - (1 - e) ** 3, Z = (e) => e < 0.5 ? 4 * e ** 3 : 1 - (-2 * e + 2) ** 3 / 2, tt = (e) => e ** 4, et = (e) => 1 - (1 - e) ** 4, nt = (e) => e < 0.5 ? 8 * e ** 4 : 1 - (-2 * e + 2) ** 4 / 2, it = (e) => e ** 5, st = (e) => 1 - (1 - e) ** 5, rt = (e) => e < 0.5 ? 16 * e ** 5 : 1 - (-2 * e + 2) ** 5 / 2, ot = (e) => e === 0 ? 0 : 2 ** (10 * e - 10), at = (e) => e === 1 ? 1 : 1 - 2 ** (-10 * e), ct = (e) => e === 0 ? 0 : e === 1 ? 1 : e < 0.5 ? 2 ** (20 * e - 10) / 2 : (2 - 2 ** (-20 * e + 10)) / 2, ut = (e) => 1 - Math.sqrt(1 - e ** 2), ft = (e) => Math.sqrt(1 - (e - 1) ** 2), mt = (e) => e < 0.5 ? (1 - Math.sqrt(1 - 4 * e ** 2)) / 2 : (Math.sqrt(-(2 * e - 3) * (2 * e - 1)) + 1) / 2, lt = (e) => 2.70158 * e ** 3 - 1.70158 * e ** 2, ht = (e) => 1 + 2.70158 * (e - 1) ** 3 + 1.70158 * (e - 1) ** 2, dt = (e, t = 1.70158 * 1.525) => e < 0.5 ? (2 * e) ** 2 * ((t + 1) * 2 * e - t) / 2 : ((2 * e - 2) ** 2 * ((t + 1) * (e * 2 - 2) + t) + 2) / 2, C = {
|
|
100
106
|
linear: G,
|
|
101
107
|
sineIn: V,
|
|
102
108
|
sineOut: B,
|
|
@@ -153,14 +159,14 @@ const G = (t) => t, V = (t) => 1 - Math.cos(t * Math.PI / 2), B = (t) => Math.si
|
|
|
153
159
|
backOut: "cubic-bezier(0.175, 0.885, 0.32, 1.275)",
|
|
154
160
|
backInOut: "cubic-bezier(0.68, -0.55, 0.265, 1.55)"
|
|
155
161
|
};
|
|
156
|
-
function pt(
|
|
157
|
-
return
|
|
162
|
+
function pt(e) {
|
|
163
|
+
return e === "percentage" ? "%" : e || "px";
|
|
158
164
|
}
|
|
159
|
-
function gt(
|
|
160
|
-
return
|
|
165
|
+
function gt(e) {
|
|
166
|
+
return e ? z[e] || e : z.linear;
|
|
161
167
|
}
|
|
162
|
-
function yt(
|
|
163
|
-
const s = 3 *
|
|
168
|
+
function yt(e, t, n, i) {
|
|
169
|
+
const s = 3 * e, r = 3 * (n - e) - s, c = 1 - s - r, a = 3 * t, m = 3 * (i - t) - a, l = 1 - a - m, o = (h) => ((c * h + r) * h + s) * h, u = (h) => ((l * h + m) * h + a) * h, f = (h) => (3 * c * h + 2 * r) * h + s;
|
|
164
170
|
function p(h) {
|
|
165
171
|
let d = h;
|
|
166
172
|
for (let y = 0; y < 8; y++) {
|
|
@@ -180,19 +186,19 @@ function yt(t, e, n, i) {
|
|
|
180
186
|
}
|
|
181
187
|
return (h) => h <= 0 ? 0 : h >= 1 ? 1 : u(p(h));
|
|
182
188
|
}
|
|
183
|
-
function bt(
|
|
184
|
-
const
|
|
189
|
+
function bt(e) {
|
|
190
|
+
const t = e.match(
|
|
185
191
|
/^cubic-bezier\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)$/
|
|
186
192
|
);
|
|
187
|
-
if (!
|
|
188
|
-
const n = parseFloat(
|
|
193
|
+
if (!t) return;
|
|
194
|
+
const n = parseFloat(t[1]), i = parseFloat(t[2]), s = parseFloat(t[3]), r = parseFloat(t[4]);
|
|
189
195
|
if (![n, i, s, r].some(isNaN))
|
|
190
196
|
return yt(n, i, s, r);
|
|
191
197
|
}
|
|
192
|
-
function vt(
|
|
193
|
-
const
|
|
194
|
-
if (!
|
|
195
|
-
const n =
|
|
198
|
+
function vt(e) {
|
|
199
|
+
const t = e.match(/^linear\((.+)\)$/);
|
|
200
|
+
if (!t) return;
|
|
201
|
+
const n = t[1].split(",").map((c) => c.trim()).filter(Boolean);
|
|
196
202
|
if (n.length === 0) return;
|
|
197
203
|
const i = [];
|
|
198
204
|
for (const c of n) {
|
|
@@ -237,24 +243,24 @@ function vt(t) {
|
|
|
237
243
|
return u.pos === o.pos ? u.output : o.output + (u.output - o.output) * (c - o.pos) / (u.pos - o.pos);
|
|
238
244
|
};
|
|
239
245
|
}
|
|
240
|
-
function D(
|
|
241
|
-
if (!
|
|
242
|
-
const
|
|
243
|
-
return
|
|
246
|
+
function D(e) {
|
|
247
|
+
if (!e) return;
|
|
248
|
+
const t = C[e];
|
|
249
|
+
return t || (bt(e) ?? vt(e) ?? C.linear);
|
|
244
250
|
}
|
|
245
|
-
class Et extends
|
|
251
|
+
class Et extends O {
|
|
246
252
|
animationGroups;
|
|
247
253
|
delay;
|
|
248
254
|
offset;
|
|
249
255
|
offsetEasing;
|
|
250
256
|
timingOptions;
|
|
251
|
-
constructor(
|
|
252
|
-
const i =
|
|
253
|
-
super(i), this.animationGroups =
|
|
257
|
+
constructor(t, n = {}) {
|
|
258
|
+
const i = t.flatMap((s) => [...s.animations]);
|
|
259
|
+
super(i), this.animationGroups = t, this.delay = n.delay ?? 0, this.offset = n.offset ?? 0, this.offsetEasing = typeof n.offsetEasing == "function" ? n.offsetEasing : D(n.offsetEasing) ?? G, this.timingOptions = this.animationGroups.map((s) => s.getTimingOptions().map(({ delay: r, duration: c, iterations: a }) => ({
|
|
254
260
|
delay: r,
|
|
255
261
|
duration: Number.isFinite(c) ? c : 0,
|
|
256
262
|
iterations: Number.isFinite(a) ? a : 1
|
|
257
|
-
}))), this.applyOffsets(), this.ready = Promise.all(
|
|
263
|
+
}))), this.applyOffsets(), this.ready = Promise.all(t.map((s) => s.ready)).then(() => {
|
|
258
264
|
});
|
|
259
265
|
}
|
|
260
266
|
/**
|
|
@@ -263,27 +269,27 @@ class Et extends I {
|
|
|
263
269
|
* where i is the group index and last is the index of the final group.
|
|
264
270
|
*/
|
|
265
271
|
calculateOffsets() {
|
|
266
|
-
const
|
|
267
|
-
if (
|
|
268
|
-
const n =
|
|
272
|
+
const t = this.animationGroups.length;
|
|
273
|
+
if (t <= 1) return [0];
|
|
274
|
+
const n = t - 1;
|
|
269
275
|
return Array.from(
|
|
270
|
-
{ length:
|
|
276
|
+
{ length: t },
|
|
271
277
|
(i, s) => this.offsetEasing(s / n) * n * this.offset | 0
|
|
272
278
|
);
|
|
273
279
|
}
|
|
274
280
|
applyOffsets() {
|
|
275
281
|
if (this.animationGroups.length === 0 || this.animations.length === 0) return;
|
|
276
|
-
const
|
|
282
|
+
const t = this.calculateOffsets(), n = this.getSequenceActiveDuration(t);
|
|
277
283
|
this.animationGroups.forEach((i, s) => {
|
|
278
284
|
i.animations.forEach((r, c) => {
|
|
279
285
|
const a = r.effect;
|
|
280
286
|
if (!a) return;
|
|
281
|
-
const { delay: m, duration: l, iterations: o } = this.timingOptions[s][c], u = m +
|
|
287
|
+
const { delay: m, duration: l, iterations: o } = this.timingOptions[s][c], u = m + t[s], f = n - (u + l * o);
|
|
282
288
|
a.updateTiming({ delay: u + this.delay, endDelay: f });
|
|
283
289
|
});
|
|
284
290
|
});
|
|
285
291
|
}
|
|
286
|
-
getSequenceActiveDuration(
|
|
292
|
+
getSequenceActiveDuration(t) {
|
|
287
293
|
const n = [];
|
|
288
294
|
for (let i = 0; i < this.timingOptions.length; i++) {
|
|
289
295
|
const s = this.timingOptions[i].reduce((r, c) => {
|
|
@@ -291,7 +297,7 @@ class Et extends I {
|
|
|
291
297
|
const { delay: a, duration: m, iterations: l } = c;
|
|
292
298
|
return Math.max(r, a + m * l);
|
|
293
299
|
}, 0);
|
|
294
|
-
n.push(
|
|
300
|
+
n.push(t[i] + s);
|
|
295
301
|
}
|
|
296
302
|
return Math.max(...n);
|
|
297
303
|
}
|
|
@@ -300,9 +306,9 @@ class Et extends I {
|
|
|
300
306
|
* stagger offsets for all groups. Each entry specifies the target index
|
|
301
307
|
* in the animationGroups array where the group should be inserted.
|
|
302
308
|
*/
|
|
303
|
-
addGroups(
|
|
304
|
-
if (
|
|
305
|
-
const n = [...
|
|
309
|
+
addGroups(t) {
|
|
310
|
+
if (t.length === 0) return;
|
|
311
|
+
const n = [...t].sort((i, s) => s.index - i.index);
|
|
306
312
|
for (const { index: i, group: s } of n) {
|
|
307
313
|
const r = Math.min(i, this.animationGroups.length);
|
|
308
314
|
this.animationGroups.splice(r, 0, s), this.timingOptions.splice(r, 0, s.getTimingOptions());
|
|
@@ -317,19 +323,19 @@ class Et extends I {
|
|
|
317
323
|
* stagger offsets for remaining groups. Cancelled animations in removed
|
|
318
324
|
* groups are returned.
|
|
319
325
|
*/
|
|
320
|
-
removeGroups(
|
|
326
|
+
removeGroups(t) {
|
|
321
327
|
const n = [], i = [], s = [];
|
|
322
328
|
for (let r = 0; r < this.animationGroups.length; r++)
|
|
323
|
-
|
|
329
|
+
t(this.animationGroups[r]) ? n.push(this.animationGroups[r]) : (i.push(this.animationGroups[r]), s.push(this.timingOptions[r]));
|
|
324
330
|
if (n.length === 0) return n;
|
|
325
331
|
for (const r of n)
|
|
326
332
|
r.cancel();
|
|
327
333
|
return this.animationGroups = i, this.timingOptions = s, this.animations = i.flatMap((r) => [...r.animations]), this.applyOffsets(), this.ready = Promise.all(this.animationGroups.map((r) => r.ready)).then(() => {
|
|
328
334
|
}), n;
|
|
329
335
|
}
|
|
330
|
-
async onFinish(
|
|
336
|
+
async onFinish(t) {
|
|
331
337
|
try {
|
|
332
|
-
await Promise.all(this.animationGroups.map((n) => n.finished)),
|
|
338
|
+
await Promise.all(this.animationGroups.map((n) => n.finished)), t();
|
|
333
339
|
} catch (n) {
|
|
334
340
|
console.warn("animation was interrupted - aborting onFinish callback - ", n);
|
|
335
341
|
}
|
|
@@ -341,25 +347,25 @@ class _t {
|
|
|
341
347
|
progress;
|
|
342
348
|
_tickCbId;
|
|
343
349
|
_finishHandler;
|
|
344
|
-
constructor(
|
|
350
|
+
constructor(t, n, i, s) {
|
|
345
351
|
const r = new KeyframeEffect(n, [], {
|
|
346
352
|
...i,
|
|
347
353
|
composite: "add"
|
|
348
354
|
}), { timeline: c } = s;
|
|
349
|
-
this._animation = new Animation(r, c), this._tickCbId = null, this.progress = null, this.customEffect = (a) =>
|
|
355
|
+
this._animation = new Animation(r, c), this._tickCbId = null, this.progress = null, this.customEffect = (a) => t(r.target, a), this._finishHandler = (a) => {
|
|
350
356
|
this.effect.target?.getAnimations().find((m) => m === this._animation) || this.cancel();
|
|
351
357
|
}, this.addEventListener("finish", this._finishHandler), this.addEventListener("remove", this._finishHandler);
|
|
352
358
|
}
|
|
353
359
|
// private tick method for customEffect loop implementation
|
|
354
360
|
_tick() {
|
|
355
361
|
try {
|
|
356
|
-
const
|
|
357
|
-
|
|
362
|
+
const t = this.effect?.getComputedTiming().progress ?? null;
|
|
363
|
+
t !== this.progress && (this.customEffect?.(t), this.progress = t), this._tickCbId = requestAnimationFrame(() => {
|
|
358
364
|
this._tick();
|
|
359
365
|
});
|
|
360
|
-
} catch (
|
|
366
|
+
} catch (t) {
|
|
361
367
|
this._tickCbId = null, console.error(
|
|
362
|
-
`failed to run customEffect! effectId: ${this.id}, error: ${
|
|
368
|
+
`failed to run customEffect! effectId: ${this.id}, error: ${t instanceof Error ? t.message : t}`
|
|
363
369
|
);
|
|
364
370
|
}
|
|
365
371
|
}
|
|
@@ -367,39 +373,39 @@ class _t {
|
|
|
367
373
|
get currentTime() {
|
|
368
374
|
return this._animation.currentTime;
|
|
369
375
|
}
|
|
370
|
-
set currentTime(
|
|
371
|
-
this._animation.currentTime =
|
|
376
|
+
set currentTime(t) {
|
|
377
|
+
this._animation.currentTime = t;
|
|
372
378
|
}
|
|
373
379
|
get startTime() {
|
|
374
380
|
return this._animation.startTime;
|
|
375
381
|
}
|
|
376
|
-
set startTime(
|
|
377
|
-
this._animation.startTime =
|
|
382
|
+
set startTime(t) {
|
|
383
|
+
this._animation.startTime = t;
|
|
378
384
|
}
|
|
379
385
|
get playbackRate() {
|
|
380
386
|
return this._animation.playbackRate;
|
|
381
387
|
}
|
|
382
|
-
set playbackRate(
|
|
383
|
-
this._animation.playbackRate =
|
|
388
|
+
set playbackRate(t) {
|
|
389
|
+
this._animation.playbackRate = t;
|
|
384
390
|
}
|
|
385
391
|
// Animation basic properties
|
|
386
392
|
get id() {
|
|
387
393
|
return this._animation.id;
|
|
388
394
|
}
|
|
389
|
-
set id(
|
|
390
|
-
this._animation.id =
|
|
395
|
+
set id(t) {
|
|
396
|
+
this._animation.id = t;
|
|
391
397
|
}
|
|
392
398
|
get effect() {
|
|
393
399
|
return this._animation.effect;
|
|
394
400
|
}
|
|
395
|
-
set effect(
|
|
396
|
-
this._animation.effect =
|
|
401
|
+
set effect(t) {
|
|
402
|
+
this._animation.effect = t;
|
|
397
403
|
}
|
|
398
404
|
get timeline() {
|
|
399
405
|
return this._animation.timeline;
|
|
400
406
|
}
|
|
401
|
-
set timeline(
|
|
402
|
-
this._animation.timeline =
|
|
407
|
+
set timeline(t) {
|
|
408
|
+
this._animation.timeline = t;
|
|
403
409
|
}
|
|
404
410
|
// Animation readonly state properties
|
|
405
411
|
get finished() {
|
|
@@ -421,20 +427,20 @@ class _t {
|
|
|
421
427
|
get oncancel() {
|
|
422
428
|
return this._animation.oncancel;
|
|
423
429
|
}
|
|
424
|
-
set oncancel(
|
|
425
|
-
this._animation.oncancel =
|
|
430
|
+
set oncancel(t) {
|
|
431
|
+
this._animation.oncancel = t;
|
|
426
432
|
}
|
|
427
433
|
get onfinish() {
|
|
428
434
|
return this._animation.onfinish;
|
|
429
435
|
}
|
|
430
|
-
set onfinish(
|
|
431
|
-
this._animation.onfinish =
|
|
436
|
+
set onfinish(t) {
|
|
437
|
+
this._animation.onfinish = t;
|
|
432
438
|
}
|
|
433
439
|
get onremove() {
|
|
434
440
|
return this._animation.onremove;
|
|
435
441
|
}
|
|
436
|
-
set onremove(
|
|
437
|
-
this._animation.onremove =
|
|
442
|
+
set onremove(t) {
|
|
443
|
+
this._animation.onremove = t;
|
|
438
444
|
}
|
|
439
445
|
// CustomAnimation overridden methods
|
|
440
446
|
play() {
|
|
@@ -461,34 +467,34 @@ class _t {
|
|
|
461
467
|
reverse() {
|
|
462
468
|
this._animation.reverse();
|
|
463
469
|
}
|
|
464
|
-
updatePlaybackRate(
|
|
465
|
-
this._animation.updatePlaybackRate(
|
|
470
|
+
updatePlaybackRate(t) {
|
|
471
|
+
this._animation.updatePlaybackRate(t);
|
|
466
472
|
}
|
|
467
473
|
// Animation events API
|
|
468
|
-
addEventListener(
|
|
469
|
-
this._animation.addEventListener(
|
|
474
|
+
addEventListener(t, n, i) {
|
|
475
|
+
this._animation.addEventListener(t, n, i);
|
|
470
476
|
}
|
|
471
|
-
removeEventListener(
|
|
472
|
-
this._animation.removeEventListener(
|
|
477
|
+
removeEventListener(t, n, i) {
|
|
478
|
+
this._animation.removeEventListener(t, n, i);
|
|
473
479
|
}
|
|
474
|
-
dispatchEvent(
|
|
475
|
-
return this._animation.dispatchEvent(
|
|
480
|
+
dispatchEvent(t) {
|
|
481
|
+
return this._animation.dispatchEvent(t);
|
|
476
482
|
}
|
|
477
483
|
}
|
|
478
|
-
function wt(
|
|
479
|
-
return
|
|
484
|
+
function wt(e) {
|
|
485
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
480
486
|
}
|
|
481
487
|
var A = { exports: {} }, F = A.exports, x;
|
|
482
|
-
function
|
|
483
|
-
return x || (x = 1, (function(
|
|
484
|
-
(function(
|
|
488
|
+
function It() {
|
|
489
|
+
return x || (x = 1, (function(e) {
|
|
490
|
+
(function(t) {
|
|
485
491
|
var n = function() {
|
|
486
|
-
}, i =
|
|
492
|
+
}, i = t.requestAnimationFrame || t.webkitRequestAnimationFrame || t.mozRequestAnimationFrame || t.msRequestAnimationFrame || function(o) {
|
|
487
493
|
return setTimeout(o, 16);
|
|
488
494
|
};
|
|
489
495
|
function s() {
|
|
490
496
|
var o = this;
|
|
491
|
-
o.reads = [], o.writes = [], o.raf = i.bind(
|
|
497
|
+
o.reads = [], o.writes = [], o.raf = i.bind(t);
|
|
492
498
|
}
|
|
493
499
|
s.prototype = {
|
|
494
500
|
constructor: s,
|
|
@@ -604,68 +610,68 @@ function Ot() {
|
|
|
604
610
|
for (var f in u)
|
|
605
611
|
u.hasOwnProperty(f) && (o[f] = u[f]);
|
|
606
612
|
}
|
|
607
|
-
var l =
|
|
608
|
-
|
|
613
|
+
var l = t.fastdom = t.fastdom || new s();
|
|
614
|
+
e.exports = l;
|
|
609
615
|
})(typeof window < "u" ? window : typeof F < "u" ? F : globalThis);
|
|
610
616
|
})(A)), A.exports;
|
|
611
617
|
}
|
|
612
|
-
var
|
|
613
|
-
const E = /* @__PURE__ */ wt(
|
|
614
|
-
function Nt(
|
|
615
|
-
Object.assign($,
|
|
618
|
+
var Ot = It();
|
|
619
|
+
const E = /* @__PURE__ */ wt(Ot), $ = {};
|
|
620
|
+
function Nt(e) {
|
|
621
|
+
Object.assign($, e);
|
|
616
622
|
}
|
|
617
|
-
function At(
|
|
618
|
-
return
|
|
619
|
-
`${
|
|
623
|
+
function At(e) {
|
|
624
|
+
return e in $ ? $[e] : (console.warn(
|
|
625
|
+
`${e} not found in registry. Please make sure to import and register the preset.`
|
|
620
626
|
), null);
|
|
621
627
|
}
|
|
622
|
-
function w(
|
|
623
|
-
return
|
|
628
|
+
function w(e, t) {
|
|
629
|
+
return e ? (t || document).getElementById(e) : null;
|
|
624
630
|
}
|
|
625
|
-
function Tt(
|
|
626
|
-
return
|
|
631
|
+
function Tt(e, t) {
|
|
632
|
+
return e?.matches(`[data-motion-part~="${t}"]`) ? e : e?.querySelector(`[data-motion-part~="${t}"]`);
|
|
627
633
|
}
|
|
628
|
-
function kt(
|
|
629
|
-
const
|
|
630
|
-
return
|
|
634
|
+
function kt(e) {
|
|
635
|
+
const t = e.alternate ? "alternate" : "";
|
|
636
|
+
return e.reversed ? `${t ? `${t}-` : ""}reverse` : t || "normal";
|
|
631
637
|
}
|
|
632
|
-
function k(
|
|
633
|
-
return `${
|
|
638
|
+
function k(e) {
|
|
639
|
+
return `${e.value}${pt(e.unit)}`;
|
|
634
640
|
}
|
|
635
|
-
function M(
|
|
636
|
-
return `${
|
|
641
|
+
function M(e, t, n) {
|
|
642
|
+
return `${e.name || "cover"} ${n && e.offset.unit !== "percentage" ? `calc(100% + ${k(e.offset)}${t ? ` + ${t}` : ""})` : t ? `calc(${k(e.offset)} + ${t})` : k(e.offset)}`;
|
|
637
643
|
}
|
|
638
|
-
function R(
|
|
644
|
+
function R(e) {
|
|
639
645
|
return {
|
|
640
|
-
start: M(
|
|
641
|
-
end: M(
|
|
646
|
+
start: M(e.startOffset, e.startOffsetAdd),
|
|
647
|
+
end: M(e.endOffset, e.endOffsetAdd, !0)
|
|
642
648
|
};
|
|
643
649
|
}
|
|
644
|
-
function L(
|
|
645
|
-
return (
|
|
650
|
+
function L(e) {
|
|
651
|
+
return (t) => E.measure(() => t(e));
|
|
646
652
|
}
|
|
647
|
-
function j(
|
|
648
|
-
return (
|
|
653
|
+
function j(e) {
|
|
654
|
+
return (t) => E.mutate(() => t(e));
|
|
649
655
|
}
|
|
650
|
-
function
|
|
651
|
-
if (
|
|
652
|
-
const
|
|
653
|
-
return typeof
|
|
654
|
-
} else if (
|
|
655
|
-
const
|
|
656
|
+
function I(e) {
|
|
657
|
+
if (e.namedEffect) {
|
|
658
|
+
const t = e.namedEffect.type;
|
|
659
|
+
return typeof t == "string" ? At(t) : null;
|
|
660
|
+
} else if (e.keyframeEffect) {
|
|
661
|
+
const t = (i) => {
|
|
656
662
|
const { name: s, keyframes: r } = i.keyframeEffect;
|
|
657
663
|
return [{ ...i, name: s, keyframes: r }];
|
|
658
664
|
};
|
|
659
|
-
return { web:
|
|
665
|
+
return { web: t, style: t, getNames: (i) => {
|
|
660
666
|
const { effectId: s } = i, { name: r } = i.keyframeEffect, c = r || s;
|
|
661
667
|
return c ? [c] : [];
|
|
662
668
|
} };
|
|
663
|
-
} else if (
|
|
664
|
-
return (
|
|
669
|
+
} else if (e.customEffect)
|
|
670
|
+
return (t) => [{ ...t, keyframes: [] }];
|
|
665
671
|
return null;
|
|
666
672
|
}
|
|
667
|
-
function H(
|
|
668
|
-
return
|
|
673
|
+
function H(e, t, n, i) {
|
|
674
|
+
return e.map((s, r) => {
|
|
669
675
|
const c = {
|
|
670
676
|
fill: s.fill,
|
|
671
677
|
easing: gt(s.easing),
|
|
@@ -673,7 +679,7 @@ function H(t, e, n, i) {
|
|
|
673
679
|
composite: s.composite,
|
|
674
680
|
direction: kt(s)
|
|
675
681
|
};
|
|
676
|
-
return S(
|
|
682
|
+
return S(t) ? (c.duration = s.duration, c.delay = s.delay || 0) : t?.trigger === "view-progress" && (i || window.ViewTimeline) ? c.duration = "auto" : (c.duration = 99.99, c.delay = 0.01), {
|
|
677
683
|
effect: s,
|
|
678
684
|
options: c,
|
|
679
685
|
id: n && `${n}-${r + 1}`,
|
|
@@ -681,50 +687,50 @@ function H(t, e, n, i) {
|
|
|
681
687
|
};
|
|
682
688
|
});
|
|
683
689
|
}
|
|
684
|
-
function S(
|
|
685
|
-
return !
|
|
690
|
+
function S(e) {
|
|
691
|
+
return !e || e.trigger !== "pointer-move" && e.trigger !== "view-progress";
|
|
686
692
|
}
|
|
687
|
-
function N(
|
|
688
|
-
if (
|
|
689
|
-
if (S(i) && (
|
|
690
|
-
if (
|
|
691
|
-
|
|
693
|
+
function N(e, t, n, i, s) {
|
|
694
|
+
if (e) {
|
|
695
|
+
if (S(i) && (t.duration = t.duration || 1, s?.reducedMotion))
|
|
696
|
+
if (t.iterations === 1 || t.iterations == null)
|
|
697
|
+
t = { ...t, duration: 1 };
|
|
692
698
|
else
|
|
693
699
|
return [];
|
|
694
700
|
let r;
|
|
695
|
-
return n instanceof HTMLElement && (r = { measure: L(n), mutate: j(n) }),
|
|
701
|
+
return n instanceof HTMLElement && (r = { measure: L(n), mutate: j(n) }), e.web ? e.web(t, r, s) : e(t, r, s);
|
|
696
702
|
}
|
|
697
703
|
return [];
|
|
698
704
|
}
|
|
699
|
-
function W(
|
|
700
|
-
const r =
|
|
701
|
-
if (n?.trigger === "pointer-move" && !
|
|
702
|
-
let f =
|
|
703
|
-
|
|
704
|
-
...
|
|
705
|
+
function W(e, t, n, i, s) {
|
|
706
|
+
const r = e instanceof HTMLElement ? e : w(e, s);
|
|
707
|
+
if (n?.trigger === "pointer-move" && !t.keyframeEffect) {
|
|
708
|
+
let f = t;
|
|
709
|
+
t.customEffect && (f = {
|
|
710
|
+
...t,
|
|
705
711
|
namedEffect: { id: "", type: "CustomMouse" }
|
|
706
712
|
});
|
|
707
|
-
const p =
|
|
713
|
+
const p = I(
|
|
708
714
|
f
|
|
709
715
|
), h = N(
|
|
710
716
|
p,
|
|
711
|
-
|
|
717
|
+
t,
|
|
712
718
|
r,
|
|
713
719
|
n,
|
|
714
720
|
i
|
|
715
721
|
);
|
|
716
722
|
return typeof h != "function" ? null : h(r);
|
|
717
723
|
}
|
|
718
|
-
const c =
|
|
724
|
+
const c = I(t), a = N(
|
|
719
725
|
c,
|
|
720
|
-
|
|
726
|
+
t,
|
|
721
727
|
r,
|
|
722
728
|
n,
|
|
723
729
|
i
|
|
724
730
|
);
|
|
725
731
|
if (!a || a.length === 0)
|
|
726
732
|
return null;
|
|
727
|
-
const m = H(a, n,
|
|
733
|
+
const m = H(a, n, t.effectId);
|
|
728
734
|
let l;
|
|
729
735
|
const o = n?.trigger === "view-progress";
|
|
730
736
|
o && window.ViewTimeline && (l = new ViewTimeline({
|
|
@@ -748,7 +754,7 @@ function W(t, e, n, i, s) {
|
|
|
748
754
|
b.rangeStart = _, b.rangeEnd = T, b.play();
|
|
749
755
|
});
|
|
750
756
|
else {
|
|
751
|
-
const { startOffset: _, endOffset: T } =
|
|
757
|
+
const { startOffset: _, endOffset: T } = t;
|
|
752
758
|
E.mutate(() => {
|
|
753
759
|
const q = f.startOffset || _, P = f.endOffset || T;
|
|
754
760
|
Object.assign(b, {
|
|
@@ -767,29 +773,29 @@ function W(t, e, n, i, s) {
|
|
|
767
773
|
}
|
|
768
774
|
return h && (b.id = h), b;
|
|
769
775
|
});
|
|
770
|
-
return new
|
|
771
|
-
...
|
|
776
|
+
return new O(u, {
|
|
777
|
+
...t,
|
|
772
778
|
trigger: { ...n || {} },
|
|
773
779
|
// make sure the group is ready after all animation targets are measured and mutated
|
|
774
780
|
measured: new Promise((f) => E.mutate(f))
|
|
775
781
|
});
|
|
776
782
|
}
|
|
777
|
-
function $t(
|
|
778
|
-
return
|
|
783
|
+
function $t(e, t) {
|
|
784
|
+
return e ? `#${e}${t ? `[data-motion-part~="${t}"]` : ""}` : "";
|
|
779
785
|
}
|
|
780
|
-
function St(
|
|
781
|
-
const { duration: n, delay: i, iterations: s = 1, fill: r, easing: c = "linear", direction: a } =
|
|
782
|
-
return `${m} ${l ? "auto" : `${n}ms`}${l ? " " : ` ${i || 1}ms `}${c}${r && r !== "none" ? ` ${r}` : ""} ${!s || s === 1 / 0 ? "infinite" : s}${a === "normal" ? "" : ` ${a}`} ${
|
|
786
|
+
function St(e, t) {
|
|
787
|
+
const { duration: n, delay: i, iterations: s = 1, fill: r, easing: c = "linear", direction: a } = e.options, m = e.effect.name, l = n === "auto";
|
|
788
|
+
return `${m} ${l ? "auto" : `${n}ms`}${l ? " " : ` ${i || 1}ms `}${c}${r && r !== "none" ? ` ${r}` : ""} ${!s || s === 1 / 0 ? "infinite" : s}${a === "normal" ? "" : ` ${a}`} ${t ? "" : "paused"}`;
|
|
783
789
|
}
|
|
784
|
-
function qt(
|
|
785
|
-
return
|
|
790
|
+
function qt(e, t, n) {
|
|
791
|
+
return e?.style ? (S(n) && (t.duration = t.duration || 1), e.style(t)) : [];
|
|
786
792
|
}
|
|
787
|
-
function Gt(
|
|
788
|
-
const i =
|
|
793
|
+
function Gt(e, t, n) {
|
|
794
|
+
const i = I(t), s = qt(i, t), r = H(s, n, t.effectId, !0), c = n?.trigger === "view-progress";
|
|
789
795
|
return r.map((a, m) => {
|
|
790
796
|
const { start: l, end: o } = c ? R(a.effect) : {};
|
|
791
797
|
return {
|
|
792
|
-
target: $t(
|
|
798
|
+
target: $t(e, a.part),
|
|
793
799
|
animation: St(a, c),
|
|
794
800
|
composition: a.options.composite,
|
|
795
801
|
custom: a.effect.custom,
|
|
@@ -801,36 +807,36 @@ function Gt(t, e, n) {
|
|
|
801
807
|
};
|
|
802
808
|
});
|
|
803
809
|
}
|
|
804
|
-
function Pt(
|
|
805
|
-
const i =
|
|
810
|
+
function Pt(e, t, n) {
|
|
811
|
+
const i = I(t), s = e instanceof HTMLElement ? e : w(e);
|
|
806
812
|
if (i && i.prepare && s) {
|
|
807
813
|
const r = { measure: L(s), mutate: j(s) };
|
|
808
|
-
i.prepare(
|
|
814
|
+
i.prepare(t, r);
|
|
809
815
|
}
|
|
810
816
|
n && E.mutate(n);
|
|
811
817
|
}
|
|
812
|
-
function Ct(
|
|
813
|
-
const n =
|
|
818
|
+
function Ct(e, t) {
|
|
819
|
+
const n = I(t);
|
|
814
820
|
if (!n)
|
|
815
821
|
return null;
|
|
816
822
|
if (!n.style)
|
|
817
|
-
return
|
|
818
|
-
const i = n.getNames(
|
|
823
|
+
return t.effectId && e ? zt(e, t.effectId) : null;
|
|
824
|
+
const i = n.getNames(t), r = (typeof e == "string" ? w(e) : e)?.getAnimations(), c = r?.map((m) => m.animationName) || [], a = [];
|
|
819
825
|
return i.forEach((m) => {
|
|
820
826
|
c.includes(m) && a.push(
|
|
821
827
|
r?.find((l) => l.animationName === m)
|
|
822
828
|
);
|
|
823
|
-
}), a?.length ? new
|
|
829
|
+
}), a?.length ? new O(a) : null;
|
|
824
830
|
}
|
|
825
|
-
function zt(
|
|
826
|
-
const i = (typeof
|
|
831
|
+
function zt(e, t) {
|
|
832
|
+
const i = (typeof e == "string" ? w(e) : e)?.getAnimations().filter((s) => {
|
|
827
833
|
const r = s.id || s.animationName;
|
|
828
|
-
return r ? r.startsWith(
|
|
834
|
+
return r ? r.startsWith(t) : !0;
|
|
829
835
|
});
|
|
830
|
-
return i?.length ? new
|
|
836
|
+
return i?.length ? new O(i) : null;
|
|
831
837
|
}
|
|
832
|
-
function Dt(
|
|
833
|
-
const { disabled: s, allowActiveEvent: r, ...c } = i, a = W(
|
|
838
|
+
function Dt(e, t, n, i = {}) {
|
|
839
|
+
const { disabled: s, allowActiveEvent: r, ...c } = i, a = W(e, t, n, c);
|
|
834
840
|
if (!a)
|
|
835
841
|
return null;
|
|
836
842
|
let m = {};
|
|
@@ -860,7 +866,7 @@ function Dt(t, e, n, i = {}) {
|
|
|
860
866
|
}
|
|
861
867
|
}));
|
|
862
868
|
} else if (n.trigger === "pointer-move") {
|
|
863
|
-
const l =
|
|
869
|
+
const l = t, { centeredToTarget: o, transitionDuration: u, transitionEasing: f } = l, p = n.axis;
|
|
864
870
|
if (l.keyframeEffect) {
|
|
865
871
|
const h = a;
|
|
866
872
|
return h.animations?.length === 0 ? null : {
|
|
@@ -884,7 +890,7 @@ function Dt(t, e, n, i = {}) {
|
|
|
884
890
|
m = {
|
|
885
891
|
centeredToTarget: o,
|
|
886
892
|
allowActiveEvent: r
|
|
887
|
-
},
|
|
893
|
+
}, t.customEffect && u && (m.transitionDuration = u, m.transitionEasing = D(f)), m.target = a.target;
|
|
888
894
|
}
|
|
889
895
|
return {
|
|
890
896
|
...m,
|
|
@@ -907,34 +913,34 @@ function Dt(t, e, n, i = {}) {
|
|
|
907
913
|
}
|
|
908
914
|
};
|
|
909
915
|
}
|
|
910
|
-
function Ft(
|
|
911
|
-
const s = Ct(
|
|
916
|
+
function Ft(e, t, n, i = !1) {
|
|
917
|
+
const s = Ct(e, t);
|
|
912
918
|
return s ? (s.ready = new Promise((r) => {
|
|
913
|
-
Pt(
|
|
914
|
-
}), s) : W(
|
|
919
|
+
Pt(e, t, r);
|
|
920
|
+
}), s) : W(e, t, n, { reducedMotion: i });
|
|
915
921
|
}
|
|
916
|
-
function xt(
|
|
917
|
-
return
|
|
922
|
+
function xt(e) {
|
|
923
|
+
return e === null ? [null] : typeof e == "string" ? Array.from(document.querySelectorAll(e)) : Array.isArray(e) ? e : [e];
|
|
918
924
|
}
|
|
919
|
-
function Mt(
|
|
925
|
+
function Mt(e, t) {
|
|
920
926
|
const n = [];
|
|
921
|
-
for (const { target: i, options: s } of
|
|
927
|
+
for (const { target: i, options: s } of e) {
|
|
922
928
|
const r = xt(i);
|
|
923
929
|
for (const c of r) {
|
|
924
930
|
const a = Ft(
|
|
925
931
|
c,
|
|
926
932
|
s,
|
|
927
933
|
void 0,
|
|
928
|
-
|
|
934
|
+
t?.reducedMotion
|
|
929
935
|
);
|
|
930
|
-
a instanceof
|
|
936
|
+
a instanceof O && n.push(a);
|
|
931
937
|
}
|
|
932
938
|
}
|
|
933
939
|
return n;
|
|
934
940
|
}
|
|
935
|
-
function Rt(
|
|
936
|
-
const i = Mt(
|
|
937
|
-
return new Et(i,
|
|
941
|
+
function Rt(e, t, n) {
|
|
942
|
+
const i = Mt(t, n);
|
|
943
|
+
return new Et(i, e);
|
|
938
944
|
}
|
|
939
945
|
export {
|
|
940
946
|
lt as backIn,
|