@wix/motion 2.1.5 → 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 +340 -334
- 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/dist/types/api/common.d.ts +1 -1
- package/dist/types/api/common.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/es/motion.js
CHANGED
|
@@ -1,102 +1,108 @@
|
|
|
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 >
|
|
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
|
-
const { delay: i, duration:
|
|
38
|
-
n.currentTime = ((i || 0) +
|
|
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) * 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 r = new
|
|
56
|
+
const s = this.options?.effectId || n.id, r = new CustomEvent("animationend", { detail: { effectId: s } });
|
|
57
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) {
|
|
69
69
|
if (n.name === "AbortError") {
|
|
70
70
|
const i = this.animations[0];
|
|
71
71
|
if (i && !this.isCSS) {
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
|
|
72
|
+
const s = i.effect?.target;
|
|
73
|
+
if (s) {
|
|
74
|
+
const r = new Event("animationcancel");
|
|
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
|
-
duration:
|
|
94
|
-
iterations:
|
|
99
|
+
duration: s,
|
|
100
|
+
iterations: r
|
|
95
101
|
};
|
|
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
|
|
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++) {
|
|
@@ -178,83 +184,83 @@ function yt(t, e, n, i) {
|
|
|
178
184
|
}
|
|
179
185
|
return d;
|
|
180
186
|
}
|
|
181
|
-
return (h) => h <= 0 ? 0 : h >= 1 ? 1 :
|
|
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(
|
|
189
|
-
if (![n, i,
|
|
190
|
-
return yt(n, i,
|
|
193
|
+
if (!t) return;
|
|
194
|
+
const n = parseFloat(t[1]), i = parseFloat(t[2]), s = parseFloat(t[3]), r = parseFloat(t[4]);
|
|
195
|
+
if (![n, i, s, r].some(isNaN))
|
|
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
|
-
for (const
|
|
199
|
-
const a =
|
|
204
|
+
for (const c of n) {
|
|
205
|
+
const a = c.split(/\s+/), m = parseFloat(a[0]);
|
|
200
206
|
if (isNaN(m)) return;
|
|
201
207
|
const l = [];
|
|
202
208
|
for (let o = 1; o < a.length; o++)
|
|
203
209
|
if (a[o].endsWith("%")) {
|
|
204
|
-
const
|
|
205
|
-
if (isNaN(
|
|
206
|
-
l.push(
|
|
210
|
+
const u = parseFloat(a[o]) / 100;
|
|
211
|
+
if (isNaN(u)) return;
|
|
212
|
+
l.push(u);
|
|
207
213
|
}
|
|
208
214
|
l.length === 0 ? i.push({ output: m, pos: null }) : l.length === 1 ? i.push({ output: m, pos: l[0] }) : (i.push({ output: m, pos: l[0] }), i.push({ output: m, pos: l[1] }));
|
|
209
215
|
}
|
|
210
216
|
if (i.length === 0) return;
|
|
211
217
|
i[0].pos === null && (i[0].pos = 0), i[i.length - 1].pos === null && (i[i.length - 1].pos = 1);
|
|
212
|
-
let
|
|
213
|
-
for (;
|
|
214
|
-
if (i[
|
|
215
|
-
const
|
|
216
|
-
let a =
|
|
218
|
+
let s = 0;
|
|
219
|
+
for (; s < i.length; )
|
|
220
|
+
if (i[s].pos === null) {
|
|
221
|
+
const c = s - 1;
|
|
222
|
+
let a = s;
|
|
217
223
|
for (; a < i.length && i[a].pos === null; ) a++;
|
|
218
|
-
const m = i[
|
|
219
|
-
for (let
|
|
220
|
-
i[
|
|
221
|
-
|
|
224
|
+
const m = i[c].pos, l = i[a].pos, o = a - c;
|
|
225
|
+
for (let u = c + 1; u < a; u++)
|
|
226
|
+
i[u].pos = m + (l - m) * (u - c) / o;
|
|
227
|
+
s = a + 1;
|
|
222
228
|
} else
|
|
223
|
-
|
|
224
|
-
for (let
|
|
225
|
-
i[
|
|
226
|
-
const
|
|
227
|
-
return (
|
|
228
|
-
if (
|
|
229
|
-
const a =
|
|
230
|
-
if (
|
|
231
|
-
let m = 0, l =
|
|
229
|
+
s++;
|
|
230
|
+
for (let c = 1; c < i.length; c++)
|
|
231
|
+
i[c].pos < i[c - 1].pos && (i[c].pos = i[c - 1].pos);
|
|
232
|
+
const r = i;
|
|
233
|
+
return (c) => {
|
|
234
|
+
if (c <= r[0].pos) return r[0].output;
|
|
235
|
+
const a = r[r.length - 1];
|
|
236
|
+
if (c >= a.pos) return a.output;
|
|
237
|
+
let m = 0, l = r.length - 1;
|
|
232
238
|
for (; m < l - 1; ) {
|
|
233
239
|
const f = m + l >>> 1;
|
|
234
|
-
|
|
240
|
+
r[f].pos <= c ? m = f : l = f;
|
|
235
241
|
}
|
|
236
|
-
const o =
|
|
237
|
-
return
|
|
242
|
+
const o = r[m], u = r[l];
|
|
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 =
|
|
254
|
-
delay:
|
|
255
|
-
duration: Number.isFinite(
|
|
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 }) => ({
|
|
260
|
+
delay: r,
|
|
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,35 +269,35 @@ 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:
|
|
271
|
-
(i,
|
|
276
|
+
{ length: t },
|
|
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
|
|
277
|
-
this.animationGroups.forEach((i,
|
|
278
|
-
i.animations.forEach((
|
|
279
|
-
const a =
|
|
282
|
+
const t = this.calculateOffsets(), n = this.getSequenceActiveDuration(t);
|
|
283
|
+
this.animationGroups.forEach((i, s) => {
|
|
284
|
+
i.animations.forEach((r, c) => {
|
|
285
|
+
const a = r.effect;
|
|
280
286
|
if (!a) return;
|
|
281
|
-
const { delay: m, duration: l, iterations: o } = this.timingOptions[
|
|
282
|
-
a.updateTiming({ delay:
|
|
287
|
+
const { delay: m, duration: l, iterations: o } = this.timingOptions[s][c], u = m + t[s], f = n - (u + l * o);
|
|
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
|
-
const
|
|
290
|
-
if (!
|
|
291
|
-
const { delay: a, duration: m, iterations: l } =
|
|
292
|
-
return Math.max(
|
|
295
|
+
const s = this.timingOptions[i].reduce((r, c) => {
|
|
296
|
+
if (!c) return r;
|
|
297
|
+
const { delay: a, duration: m, iterations: l } = c;
|
|
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,14 +306,14 @@ 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 = [...
|
|
306
|
-
for (const { index: i, group:
|
|
307
|
-
const
|
|
308
|
-
this.animationGroups.splice(
|
|
309
|
-
const
|
|
310
|
-
this.animations.splice(a, 0, ...
|
|
309
|
+
addGroups(t) {
|
|
310
|
+
if (t.length === 0) return;
|
|
311
|
+
const n = [...t].sort((i, s) => s.index - i.index);
|
|
312
|
+
for (const { index: i, group: s } of n) {
|
|
313
|
+
const r = Math.min(i, this.animationGroups.length);
|
|
314
|
+
this.animationGroups.splice(r, 0, s), this.timingOptions.splice(r, 0, s.getTimingOptions());
|
|
315
|
+
const c = [...s.animations], a = this.animationGroups.slice(0, r).reduce((m, l) => m + l.animations.length, 0);
|
|
316
|
+
this.animations.splice(a, 0, ...c);
|
|
311
317
|
}
|
|
312
318
|
this.applyOffsets(), this.ready = Promise.all(this.animationGroups.map((i) => i.ready)).then(() => {
|
|
313
319
|
});
|
|
@@ -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(
|
|
321
|
-
const n = [], i = [],
|
|
322
|
-
for (let
|
|
323
|
-
|
|
326
|
+
removeGroups(t) {
|
|
327
|
+
const n = [], i = [], s = [];
|
|
328
|
+
for (let r = 0; r < this.animationGroups.length; r++)
|
|
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
|
-
for (const
|
|
326
|
-
|
|
327
|
-
return this.animationGroups = i, this.timingOptions =
|
|
331
|
+
for (const r of n)
|
|
332
|
+
r.cancel();
|
|
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(
|
|
345
|
-
const
|
|
350
|
+
constructor(t, n, i, s) {
|
|
351
|
+
const r = new KeyframeEffect(n, [], {
|
|
346
352
|
...i,
|
|
347
353
|
composite: "add"
|
|
348
|
-
}), { timeline:
|
|
349
|
-
this._animation = new Animation(
|
|
354
|
+
}), { timeline: c } = s;
|
|
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,37 +467,37 @@ 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
|
-
function
|
|
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
|
-
|
|
494
|
-
constructor:
|
|
499
|
+
s.prototype = {
|
|
500
|
+
constructor: s,
|
|
495
501
|
/**
|
|
496
502
|
* We run this inside a try catch
|
|
497
503
|
* so that if any jobs error, we
|
|
@@ -501,7 +507,7 @@ function Ot() {
|
|
|
501
507
|
* @param {Array} tasks
|
|
502
508
|
*/
|
|
503
509
|
runTasks: function(o) {
|
|
504
|
-
for (var
|
|
510
|
+
for (var u; u = o.shift(); ) u();
|
|
505
511
|
},
|
|
506
512
|
/**
|
|
507
513
|
* Adds a job to the read batch and
|
|
@@ -511,9 +517,9 @@ function Ot() {
|
|
|
511
517
|
* @param {Object} ctx the context to be bound to `fn` (optional).
|
|
512
518
|
* @public
|
|
513
519
|
*/
|
|
514
|
-
measure: function(o,
|
|
515
|
-
var f =
|
|
516
|
-
return this.reads.push(f),
|
|
520
|
+
measure: function(o, u) {
|
|
521
|
+
var f = u ? o.bind(u) : o;
|
|
522
|
+
return this.reads.push(f), r(this), f;
|
|
517
523
|
},
|
|
518
524
|
/**
|
|
519
525
|
* Adds a job to the
|
|
@@ -524,9 +530,9 @@ function Ot() {
|
|
|
524
530
|
* @param {Object} ctx the context to be bound to `fn` (optional).
|
|
525
531
|
* @public
|
|
526
532
|
*/
|
|
527
|
-
mutate: function(o,
|
|
528
|
-
var f =
|
|
529
|
-
return this.writes.push(f),
|
|
533
|
+
mutate: function(o, u) {
|
|
534
|
+
var f = u ? o.bind(u) : o;
|
|
535
|
+
return this.writes.push(f), r(this), f;
|
|
530
536
|
},
|
|
531
537
|
/**
|
|
532
538
|
* Clears a scheduled 'read' or 'write' task.
|
|
@@ -574,164 +580,164 @@ function Ot() {
|
|
|
574
580
|
*/
|
|
575
581
|
extend: function(o) {
|
|
576
582
|
if (typeof o != "object") throw new Error("expected object");
|
|
577
|
-
var
|
|
578
|
-
return m(
|
|
583
|
+
var u = Object.create(this);
|
|
584
|
+
return m(u, o), u.fastdom = this, u.initialize && u.initialize(), u;
|
|
579
585
|
},
|
|
580
586
|
// override this with a function
|
|
581
587
|
// to prevent Errors in console
|
|
582
588
|
// when tasks throw
|
|
583
589
|
catch: null
|
|
584
590
|
};
|
|
585
|
-
function
|
|
586
|
-
o.scheduled || (o.scheduled = !0, o.raf(
|
|
591
|
+
function r(o) {
|
|
592
|
+
o.scheduled || (o.scheduled = !0, o.raf(c.bind(null, o)));
|
|
587
593
|
}
|
|
588
|
-
function
|
|
589
|
-
var
|
|
594
|
+
function c(o) {
|
|
595
|
+
var u = o.writes, f = o.reads, p;
|
|
590
596
|
try {
|
|
591
|
-
n("flushing reads", f.length), o.runTasks(f), n("flushing writes",
|
|
597
|
+
n("flushing reads", f.length), o.runTasks(f), n("flushing writes", u.length), o.runTasks(u);
|
|
592
598
|
} catch (h) {
|
|
593
599
|
p = h;
|
|
594
600
|
}
|
|
595
|
-
if (o.scheduled = !1, (f.length ||
|
|
601
|
+
if (o.scheduled = !1, (f.length || u.length) && r(o), p)
|
|
596
602
|
if (n("task errored", p.message), o.catch) o.catch(p);
|
|
597
603
|
else throw p;
|
|
598
604
|
}
|
|
599
|
-
function a(o,
|
|
600
|
-
var f = o.indexOf(
|
|
605
|
+
function a(o, u) {
|
|
606
|
+
var f = o.indexOf(u);
|
|
601
607
|
return !!~f && !!o.splice(f, 1);
|
|
602
608
|
}
|
|
603
|
-
function m(o,
|
|
604
|
-
for (var f in
|
|
605
|
-
|
|
609
|
+
function m(o, u) {
|
|
610
|
+
for (var f in u)
|
|
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
|
-
const { name:
|
|
657
|
-
return [{ ...i, name:
|
|
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) => {
|
|
662
|
+
const { name: s, keyframes: r } = i.keyframeEffect;
|
|
663
|
+
return [{ ...i, name: s, keyframes: r }];
|
|
658
664
|
};
|
|
659
|
-
return { web:
|
|
660
|
-
const { effectId:
|
|
661
|
-
return
|
|
665
|
+
return { web: t, style: t, getNames: (i) => {
|
|
666
|
+
const { effectId: s } = i, { name: r } = i.keyframeEffect, c = r || s;
|
|
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(t,
|
|
668
|
-
return
|
|
669
|
-
const
|
|
670
|
-
fill:
|
|
671
|
-
easing: gt(
|
|
672
|
-
iterations:
|
|
673
|
-
composite:
|
|
674
|
-
direction: kt(
|
|
673
|
+
function H(e, t, n, i) {
|
|
674
|
+
return e.map((s, r) => {
|
|
675
|
+
const c = {
|
|
676
|
+
fill: s.fill,
|
|
677
|
+
easing: gt(s.easing),
|
|
678
|
+
iterations: s.iterations === 0 ? 1 / 0 : s.iterations || 1,
|
|
679
|
+
composite: s.composite,
|
|
680
|
+
direction: kt(s)
|
|
675
681
|
};
|
|
676
|
-
return S(
|
|
677
|
-
effect:
|
|
678
|
-
options:
|
|
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), {
|
|
683
|
+
effect: s,
|
|
684
|
+
options: c,
|
|
679
685
|
id: n && `${n}-${r + 1}`,
|
|
680
|
-
part:
|
|
686
|
+
part: s.part
|
|
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
|
-
let
|
|
695
|
-
return n instanceof HTMLElement && (
|
|
700
|
+
let r;
|
|
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
|
|
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
|
-
|
|
712
|
-
|
|
717
|
+
t,
|
|
718
|
+
r,
|
|
713
719
|
n,
|
|
714
720
|
i
|
|
715
721
|
);
|
|
716
|
-
return typeof h != "function" ? null : h(
|
|
722
|
+
return typeof h != "function" ? null : h(r);
|
|
717
723
|
}
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
724
|
+
const c = I(t), a = N(
|
|
725
|
+
c,
|
|
726
|
+
t,
|
|
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({
|
|
731
737
|
subject: n.element || w(n.componentId)
|
|
732
738
|
}));
|
|
733
|
-
const
|
|
734
|
-
const v = d ? Tt(
|
|
739
|
+
const u = m.map(({ effect: f, options: p, id: h, part: d }) => {
|
|
740
|
+
const v = d ? Tt(r, d) : r, g = new KeyframeEffect(v || null, [], p);
|
|
735
741
|
E.mutate(() => {
|
|
736
742
|
"timing" in f && g.updateTiming(f.timing), g.setKeyframes(f.keyframes);
|
|
737
743
|
});
|
|
@@ -748,7 +754,7 @@ function W(t, e, n, i, r) {
|
|
|
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,83 +773,83 @@ function W(t, e, n, i, r) {
|
|
|
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:
|
|
782
|
-
return `${m} ${l ? "auto" : `${n}ms`}${l ? " " : ` ${i || 1}ms `}${
|
|
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 =
|
|
789
|
-
return
|
|
790
|
-
const { start: l, end: o } =
|
|
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";
|
|
795
|
+
return r.map((a, m) => {
|
|
796
|
+
const { start: l, end: o } = c ? R(a.effect) : {};
|
|
791
797
|
return {
|
|
792
|
-
target: $t(
|
|
793
|
-
animation: St(a,
|
|
798
|
+
target: $t(e, a.part),
|
|
799
|
+
animation: St(a, c),
|
|
794
800
|
composition: a.options.composite,
|
|
795
801
|
custom: a.effect.custom,
|
|
796
802
|
name: a.effect.name,
|
|
797
803
|
keyframes: a.effect.keyframes,
|
|
798
804
|
id: a.id && `${a.id}-${m + 1}`,
|
|
799
|
-
animationTimeline:
|
|
805
|
+
animationTimeline: c ? `--${n?.id}` : "",
|
|
800
806
|
animationRange: l || o ? `${l} ${o}` : ""
|
|
801
807
|
};
|
|
802
808
|
});
|
|
803
809
|
}
|
|
804
|
-
function Pt(
|
|
805
|
-
const i =
|
|
806
|
-
if (i && i.prepare &&
|
|
807
|
-
const
|
|
808
|
-
i.prepare(
|
|
810
|
+
function Pt(e, t, n) {
|
|
811
|
+
const i = I(t), s = e instanceof HTMLElement ? e : w(e);
|
|
812
|
+
if (i && i.prepare && s) {
|
|
813
|
+
const r = { measure: L(s), mutate: j(s) };
|
|
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
|
-
|
|
821
|
-
|
|
826
|
+
c.includes(m) && a.push(
|
|
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
|
|
827
|
-
const
|
|
828
|
-
return
|
|
831
|
+
function zt(e, t) {
|
|
832
|
+
const i = (typeof e == "string" ? w(e) : e)?.getAnimations().filter((s) => {
|
|
833
|
+
const r = s.id || s.animationName;
|
|
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:
|
|
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 = {};
|
|
837
843
|
if (n.trigger === "view-progress" && !window.ViewTimeline) {
|
|
838
844
|
const l = n.element || w(n.componentId), { ready: o } = a;
|
|
839
|
-
return a.animations.map((
|
|
845
|
+
return a.animations.map((u) => ({
|
|
840
846
|
/* we use getters for start and end in order to access the animation's start and end
|
|
841
847
|
only when initializing the scrub scene rather than immediately */
|
|
842
848
|
get start() {
|
|
843
|
-
return
|
|
849
|
+
return u.start;
|
|
844
850
|
},
|
|
845
851
|
get end() {
|
|
846
|
-
return
|
|
852
|
+
return u.end;
|
|
847
853
|
},
|
|
848
854
|
viewSource: l,
|
|
849
855
|
ready: o,
|
|
@@ -851,16 +857,16 @@ function Dt(t, e, n, i = {}) {
|
|
|
851
857
|
return a.getProgress();
|
|
852
858
|
},
|
|
853
859
|
effect(f, p) {
|
|
854
|
-
const { activeDuration: h } =
|
|
855
|
-
|
|
860
|
+
const { activeDuration: h } = u.effect.getComputedTiming(), { delay: d } = u.effect.getTiming();
|
|
861
|
+
u.currentTime = ((d || 0) + (h || 0)) * p;
|
|
856
862
|
},
|
|
857
|
-
disabled:
|
|
863
|
+
disabled: s,
|
|
858
864
|
destroy() {
|
|
859
|
-
|
|
865
|
+
u.cancel();
|
|
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 : {
|
|
@@ -875,7 +881,7 @@ function Dt(t, e, n, i = {}) {
|
|
|
875
881
|
const y = p === "x" ? g.x : g.y;
|
|
876
882
|
this._currentProgress = y, h.progress(y);
|
|
877
883
|
},
|
|
878
|
-
disabled:
|
|
884
|
+
disabled: s ?? !1,
|
|
879
885
|
destroy() {
|
|
880
886
|
h.cancel();
|
|
881
887
|
}
|
|
@@ -883,58 +889,58 @@ function Dt(t, e, n, i = {}) {
|
|
|
883
889
|
}
|
|
884
890
|
m = {
|
|
885
891
|
centeredToTarget: o,
|
|
886
|
-
allowActiveEvent:
|
|
887
|
-
},
|
|
892
|
+
allowActiveEvent: r
|
|
893
|
+
}, t.customEffect && u && (m.transitionDuration = u, m.transitionEasing = D(f)), m.target = a.target;
|
|
888
894
|
}
|
|
889
895
|
return {
|
|
890
896
|
...m,
|
|
891
897
|
getProgress() {
|
|
892
898
|
return a.getProgress();
|
|
893
899
|
},
|
|
894
|
-
effect(l, o,
|
|
900
|
+
effect(l, o, u, f) {
|
|
895
901
|
a.progress(
|
|
896
|
-
|
|
902
|
+
u ? {
|
|
897
903
|
// @ts-expect-error spread error on p
|
|
898
904
|
...o,
|
|
899
|
-
v:
|
|
905
|
+
v: u,
|
|
900
906
|
active: f
|
|
901
907
|
} : o
|
|
902
908
|
);
|
|
903
909
|
},
|
|
904
|
-
disabled:
|
|
910
|
+
disabled: s,
|
|
905
911
|
destroy() {
|
|
906
912
|
a.cancel();
|
|
907
913
|
}
|
|
908
914
|
};
|
|
909
915
|
}
|
|
910
|
-
function Ft(
|
|
911
|
-
const
|
|
912
|
-
return
|
|
913
|
-
Pt(
|
|
914
|
-
}),
|
|
916
|
+
function Ft(e, t, n, i = !1) {
|
|
917
|
+
const s = Ct(e, t);
|
|
918
|
+
return s ? (s.ready = new Promise((r) => {
|
|
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:
|
|
922
|
-
const
|
|
923
|
-
for (const
|
|
927
|
+
for (const { target: i, options: s } of e) {
|
|
928
|
+
const r = xt(i);
|
|
929
|
+
for (const c of r) {
|
|
924
930
|
const a = Ft(
|
|
925
|
-
|
|
926
|
-
|
|
931
|
+
c,
|
|
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,
|