@wix/motion 2.0.1 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/motion.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class I {
|
|
2
2
|
animations;
|
|
3
3
|
options;
|
|
4
4
|
ready;
|
|
@@ -27,7 +27,7 @@ class O {
|
|
|
27
27
|
}
|
|
28
28
|
progress(e) {
|
|
29
29
|
for (const n of this.animations) {
|
|
30
|
-
const { delay: i, duration:
|
|
30
|
+
const { delay: i, duration: r, iterations: s } = n.effect.getTiming(), u = (Number.isFinite(r) ? r : 0) * (Number.isFinite(s) ? s : 1);
|
|
31
31
|
n.currentTime = ((i || 0) + u) * e;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -46,8 +46,8 @@ class O {
|
|
|
46
46
|
if (n && !this.isCSS) {
|
|
47
47
|
const i = n.effect?.target;
|
|
48
48
|
if (i) {
|
|
49
|
-
const
|
|
50
|
-
i.dispatchEvent(
|
|
49
|
+
const r = new Event("animationend");
|
|
50
|
+
i.dispatchEvent(r);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
e();
|
|
@@ -63,17 +63,17 @@ class O {
|
|
|
63
63
|
}
|
|
64
64
|
getTimingOptions() {
|
|
65
65
|
return this.animations.map((e) => {
|
|
66
|
-
const n = e.effect?.getTiming(), i = n?.delay ?? 0,
|
|
66
|
+
const n = e.effect?.getTiming(), i = n?.delay ?? 0, r = Number(n?.duration) || 0, s = n?.iterations ?? 1;
|
|
67
67
|
return {
|
|
68
68
|
delay: i,
|
|
69
|
-
duration:
|
|
70
|
-
iterations:
|
|
69
|
+
duration: r,
|
|
70
|
+
iterations: s
|
|
71
71
|
};
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
const
|
|
76
|
-
linear:
|
|
75
|
+
const G = (t) => t, W = (t) => 1 - Math.cos(t * Math.PI / 2), B = (t) => Math.sin(t * Math.PI / 2), K = (t) => -(Math.cos(Math.PI * t) - 1) / 2, X = (t) => t ** 2, J = (t) => 1 - (1 - t) ** 2, U = (t) => t < 0.5 ? 2 * t ** 2 : 1 - (-2 * t + 2) ** 2 / 2, Y = (t) => t ** 3, Q = (t) => 1 - (1 - t) ** 3, Z = (t) => t < 0.5 ? 4 * t ** 3 : 1 - (-2 * t + 2) ** 3 / 2, tt = (t) => t ** 4, et = (t) => 1 - (1 - t) ** 4, nt = (t) => t < 0.5 ? 8 * t ** 4 : 1 - (-2 * t + 2) ** 4 / 2, it = (t) => t ** 5, st = (t) => 1 - (1 - t) ** 5, rt = (t) => t < 0.5 ? 16 * t ** 5 : 1 - (-2 * t + 2) ** 5 / 2, ot = (t) => t === 0 ? 0 : 2 ** (10 * t - 10), at = (t) => t === 1 ? 1 : 1 - 2 ** (-10 * t), ct = (t) => t === 0 ? 0 : t === 1 ? 1 : t < 0.5 ? 2 ** (20 * t - 10) / 2 : (2 - 2 ** (-20 * t + 10)) / 2, ut = (t) => 1 - Math.sqrt(1 - t ** 2), ft = (t) => Math.sqrt(1 - (t - 1) ** 2), lt = (t) => t < 0.5 ? (1 - Math.sqrt(1 - 4 * t ** 2)) / 2 : (Math.sqrt(-(2 * t - 3) * (2 * t - 1)) + 1) / 2, mt = (t) => 2.70158 * t ** 3 - 1.70158 * t ** 2, ht = (t) => 1 + 2.70158 * (t - 1) ** 3 + 1.70158 * (t - 1) ** 2, dt = (t, e = 1.70158 * 1.525) => t < 0.5 ? (2 * t) ** 2 * ((e + 1) * 2 * t - e) / 2 : ((2 * t - 2) ** 2 * ((e + 1) * (t * 2 - 2) + e) + 2) / 2, z = {
|
|
76
|
+
linear: G,
|
|
77
77
|
sineIn: W,
|
|
78
78
|
sineOut: B,
|
|
79
79
|
sineInOut: K,
|
|
@@ -96,8 +96,8 @@ const D = (t) => t, W = (t) => 1 - Math.cos(t * Math.PI / 2), B = (t) => Math.si
|
|
|
96
96
|
circOut: ft,
|
|
97
97
|
circInOut: lt,
|
|
98
98
|
backIn: mt,
|
|
99
|
-
backOut:
|
|
100
|
-
backInOut:
|
|
99
|
+
backOut: ht,
|
|
100
|
+
backInOut: dt
|
|
101
101
|
}, F = {
|
|
102
102
|
linear: "linear",
|
|
103
103
|
ease: "ease",
|
|
@@ -135,35 +135,35 @@ function pt(t) {
|
|
|
135
135
|
function gt(t) {
|
|
136
136
|
return t ? F[t] || t : F.linear;
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
const
|
|
140
|
-
function p(
|
|
141
|
-
let
|
|
142
|
-
for (let
|
|
143
|
-
const
|
|
144
|
-
if (Math.abs(
|
|
145
|
-
const _ = f(
|
|
138
|
+
function yt(t, e, n, i) {
|
|
139
|
+
const r = 3 * t, s = 3 * (n - t) - r, u = 1 - r - s, a = 3 * e, l = 3 * (i - e) - a, m = 1 - a - l, o = (h) => ((u * h + s) * h + r) * h, c = (h) => ((m * h + l) * h + a) * h, f = (h) => (3 * u * h + 2 * s) * h + r;
|
|
140
|
+
function p(h) {
|
|
141
|
+
let d = h;
|
|
142
|
+
for (let y = 0; y < 8; y++) {
|
|
143
|
+
const b = o(d) - h;
|
|
144
|
+
if (Math.abs(b) < 1e-7) return d;
|
|
145
|
+
const _ = f(d);
|
|
146
146
|
if (Math.abs(_) < 1e-6) break;
|
|
147
|
-
|
|
147
|
+
d -= b / _;
|
|
148
148
|
}
|
|
149
149
|
let v = 0, g = 1;
|
|
150
|
-
for (
|
|
151
|
-
const
|
|
152
|
-
if (Math.abs(
|
|
153
|
-
|
|
150
|
+
for (d = (v + g) / 2; g - v > 1e-7; ) {
|
|
151
|
+
const y = o(d);
|
|
152
|
+
if (Math.abs(y - h) < 1e-7) return d;
|
|
153
|
+
h > y ? v = d : g = d, d = (v + g) / 2;
|
|
154
154
|
}
|
|
155
|
-
return
|
|
155
|
+
return d;
|
|
156
156
|
}
|
|
157
|
-
return (
|
|
157
|
+
return (h) => h <= 0 ? 0 : h >= 1 ? 1 : c(p(h));
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function bt(t) {
|
|
160
160
|
const e = t.match(
|
|
161
161
|
/^cubic-bezier\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)$/
|
|
162
162
|
);
|
|
163
163
|
if (!e) return;
|
|
164
|
-
const n = parseFloat(e[1]), i = parseFloat(e[2]),
|
|
165
|
-
if (![n, i,
|
|
166
|
-
return
|
|
164
|
+
const n = parseFloat(e[1]), i = parseFloat(e[2]), r = parseFloat(e[3]), s = parseFloat(e[4]);
|
|
165
|
+
if (![n, i, r, s].some(isNaN))
|
|
166
|
+
return yt(n, i, r, s);
|
|
167
167
|
}
|
|
168
168
|
function vt(t) {
|
|
169
169
|
const e = t.match(/^linear\((.+)\)$/);
|
|
@@ -185,52 +185,52 @@ function vt(t) {
|
|
|
185
185
|
}
|
|
186
186
|
if (i.length === 0) return;
|
|
187
187
|
i[0].pos === null && (i[0].pos = 0), i[i.length - 1].pos === null && (i[i.length - 1].pos = 1);
|
|
188
|
-
let
|
|
189
|
-
for (;
|
|
190
|
-
if (i[
|
|
191
|
-
const u =
|
|
192
|
-
let a =
|
|
188
|
+
let r = 0;
|
|
189
|
+
for (; r < i.length; )
|
|
190
|
+
if (i[r].pos === null) {
|
|
191
|
+
const u = r - 1;
|
|
192
|
+
let a = r;
|
|
193
193
|
for (; a < i.length && i[a].pos === null; ) a++;
|
|
194
194
|
const l = i[u].pos, m = i[a].pos, o = a - u;
|
|
195
195
|
for (let c = u + 1; c < a; c++)
|
|
196
196
|
i[c].pos = l + (m - l) * (c - u) / o;
|
|
197
|
-
|
|
197
|
+
r = a + 1;
|
|
198
198
|
} else
|
|
199
|
-
|
|
199
|
+
r++;
|
|
200
200
|
for (let u = 1; u < i.length; u++)
|
|
201
201
|
i[u].pos < i[u - 1].pos && (i[u].pos = i[u - 1].pos);
|
|
202
|
-
const
|
|
202
|
+
const s = i;
|
|
203
203
|
return (u) => {
|
|
204
|
-
if (u <=
|
|
205
|
-
const a =
|
|
204
|
+
if (u <= s[0].pos) return s[0].output;
|
|
205
|
+
const a = s[s.length - 1];
|
|
206
206
|
if (u >= a.pos) return a.output;
|
|
207
|
-
let l = 0, m =
|
|
207
|
+
let l = 0, m = s.length - 1;
|
|
208
208
|
for (; l < m - 1; ) {
|
|
209
209
|
const f = l + m >>> 1;
|
|
210
|
-
|
|
210
|
+
s[f].pos <= u ? l = f : m = f;
|
|
211
211
|
}
|
|
212
|
-
const o =
|
|
212
|
+
const o = s[l], c = s[m];
|
|
213
213
|
return c.pos === o.pos ? c.output : o.output + (c.output - o.output) * (u - o.pos) / (c.pos - o.pos);
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function D(t) {
|
|
217
217
|
if (!t) return;
|
|
218
218
|
const e = z[t];
|
|
219
|
-
return e || (
|
|
219
|
+
return e || (bt(t) ?? vt(t) ?? z.linear);
|
|
220
220
|
}
|
|
221
|
-
class Et extends
|
|
221
|
+
class Et extends I {
|
|
222
222
|
animationGroups;
|
|
223
223
|
delay;
|
|
224
224
|
offset;
|
|
225
225
|
offsetEasing;
|
|
226
226
|
timingOptions;
|
|
227
227
|
constructor(e, n = {}) {
|
|
228
|
-
const i = e.flatMap((
|
|
229
|
-
super(i), this.animationGroups = e, this.delay = n.delay ?? 0, this.offset = n.offset ?? 0, this.offsetEasing = typeof n.offsetEasing == "function" ? n.offsetEasing :
|
|
230
|
-
delay:
|
|
228
|
+
const i = e.flatMap((r) => [...r.animations]);
|
|
229
|
+
super(i), this.animationGroups = e, 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((r) => r.getTimingOptions().map(({ delay: s, duration: u, iterations: a }) => ({
|
|
230
|
+
delay: s,
|
|
231
231
|
duration: Number.isFinite(u) ? u : 0,
|
|
232
232
|
iterations: Number.isFinite(a) ? a : 1
|
|
233
|
-
}))), this.applyOffsets(), this.ready = Promise.all(e.map((
|
|
233
|
+
}))), this.applyOffsets(), this.ready = Promise.all(e.map((r) => r.ready)).then(() => {
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
236
|
/**
|
|
@@ -244,16 +244,17 @@ class Et extends O {
|
|
|
244
244
|
const n = e - 1;
|
|
245
245
|
return Array.from(
|
|
246
246
|
{ length: e },
|
|
247
|
-
(i,
|
|
247
|
+
(i, r) => this.offsetEasing(r / n) * n * this.offset | 0
|
|
248
248
|
);
|
|
249
249
|
}
|
|
250
250
|
applyOffsets() {
|
|
251
|
+
if (this.animationGroups.length === 0 || this.animations.length === 0) return;
|
|
251
252
|
const e = this.calculateOffsets(), n = this.getSequenceActiveDuration(e);
|
|
252
|
-
this.animationGroups.forEach((i,
|
|
253
|
-
i.animations.forEach((
|
|
254
|
-
const a =
|
|
253
|
+
this.animationGroups.forEach((i, r) => {
|
|
254
|
+
i.animations.forEach((s, u) => {
|
|
255
|
+
const a = s.effect;
|
|
255
256
|
if (!a) return;
|
|
256
|
-
const { delay: l, duration: m, iterations: o } = this.timingOptions[
|
|
257
|
+
const { delay: l, duration: m, iterations: o } = this.timingOptions[r][u], c = l + e[r], f = n - (c + m * o);
|
|
257
258
|
a.updateTiming({ delay: c + this.delay, endDelay: f });
|
|
258
259
|
});
|
|
259
260
|
});
|
|
@@ -261,12 +262,12 @@ class Et extends O {
|
|
|
261
262
|
getSequenceActiveDuration(e) {
|
|
262
263
|
const n = [];
|
|
263
264
|
for (let i = 0; i < this.timingOptions.length; i++) {
|
|
264
|
-
const
|
|
265
|
-
if (!u) return
|
|
265
|
+
const r = this.timingOptions[i].reduce((s, u) => {
|
|
266
|
+
if (!u) return s;
|
|
266
267
|
const { delay: a, duration: l, iterations: m } = u;
|
|
267
|
-
return Math.max(
|
|
268
|
+
return Math.max(s, a + l * m);
|
|
268
269
|
}, 0);
|
|
269
|
-
n.push(e[i] +
|
|
270
|
+
n.push(e[i] + r);
|
|
270
271
|
}
|
|
271
272
|
return Math.max(...n);
|
|
272
273
|
}
|
|
@@ -277,16 +278,31 @@ class Et extends O {
|
|
|
277
278
|
*/
|
|
278
279
|
addGroups(e) {
|
|
279
280
|
if (e.length === 0) return;
|
|
280
|
-
const n = [...e].sort((i,
|
|
281
|
-
for (const { index: i, group:
|
|
282
|
-
const
|
|
283
|
-
this.animationGroups.splice(
|
|
284
|
-
const u = [...
|
|
281
|
+
const n = [...e].sort((i, r) => r.index - i.index);
|
|
282
|
+
for (const { index: i, group: r } of n) {
|
|
283
|
+
const s = Math.min(i, this.animationGroups.length);
|
|
284
|
+
this.animationGroups.splice(s, 0, r), this.timingOptions.splice(s, 0, r.getTimingOptions());
|
|
285
|
+
const u = [...r.animations], a = this.animationGroups.slice(0, s).reduce((l, m) => l + m.animations.length, 0);
|
|
285
286
|
this.animations.splice(a, 0, ...u);
|
|
286
287
|
}
|
|
287
288
|
this.applyOffsets(), this.ready = Promise.all(this.animationGroups.map((i) => i.ready)).then(() => {
|
|
288
289
|
});
|
|
289
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Removes AnimationGroups that match the predicate, then recalculates
|
|
293
|
+
* stagger offsets for remaining groups. Cancelled animations in removed
|
|
294
|
+
* groups are returned.
|
|
295
|
+
*/
|
|
296
|
+
removeGroups(e) {
|
|
297
|
+
const n = [], i = [], r = [];
|
|
298
|
+
for (let s = 0; s < this.animationGroups.length; s++)
|
|
299
|
+
e(this.animationGroups[s]) ? n.push(this.animationGroups[s]) : (i.push(this.animationGroups[s]), r.push(this.timingOptions[s]));
|
|
300
|
+
if (n.length === 0) return n;
|
|
301
|
+
for (const s of n)
|
|
302
|
+
s.cancel();
|
|
303
|
+
return this.animationGroups = i, this.timingOptions = r, this.animations = i.flatMap((s) => [...s.animations]), this.applyOffsets(), this.ready = Promise.all(this.animationGroups.map((s) => s.ready)).then(() => {
|
|
304
|
+
}), n;
|
|
305
|
+
}
|
|
290
306
|
async onFinish(e) {
|
|
291
307
|
try {
|
|
292
308
|
await Promise.all(this.animationGroups.map((n) => n.finished)), e();
|
|
@@ -301,12 +317,12 @@ class _t {
|
|
|
301
317
|
progress;
|
|
302
318
|
_tickCbId;
|
|
303
319
|
_finishHandler;
|
|
304
|
-
constructor(e, n, i,
|
|
305
|
-
const
|
|
320
|
+
constructor(e, n, i, r) {
|
|
321
|
+
const s = new KeyframeEffect(n, [], {
|
|
306
322
|
...i,
|
|
307
323
|
composite: "add"
|
|
308
|
-
}), { timeline: u } =
|
|
309
|
-
this._animation = new Animation(
|
|
324
|
+
}), { timeline: u } = r;
|
|
325
|
+
this._animation = new Animation(s, u), this._tickCbId = null, this.progress = null, this.customEffect = (a) => e(s.target, a), this._finishHandler = (a) => {
|
|
310
326
|
this.effect.target?.getAnimations().find((l) => l === this._animation) || this.cancel();
|
|
311
327
|
}, this.addEventListener("finish", this._finishHandler), this.addEventListener("remove", this._finishHandler);
|
|
312
328
|
}
|
|
@@ -439,19 +455,19 @@ function wt(t) {
|
|
|
439
455
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
440
456
|
}
|
|
441
457
|
var A = { exports: {} }, C = A.exports, x;
|
|
442
|
-
function
|
|
458
|
+
function Ot() {
|
|
443
459
|
return x || (x = 1, (function(t) {
|
|
444
460
|
(function(e) {
|
|
445
461
|
var n = function() {
|
|
446
462
|
}, i = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.msRequestAnimationFrame || function(o) {
|
|
447
463
|
return setTimeout(o, 16);
|
|
448
464
|
};
|
|
449
|
-
function
|
|
465
|
+
function r() {
|
|
450
466
|
var o = this;
|
|
451
467
|
o.reads = [], o.writes = [], o.raf = i.bind(e);
|
|
452
468
|
}
|
|
453
|
-
|
|
454
|
-
constructor:
|
|
469
|
+
r.prototype = {
|
|
470
|
+
constructor: r,
|
|
455
471
|
/**
|
|
456
472
|
* We run this inside a try catch
|
|
457
473
|
* so that if any jobs error, we
|
|
@@ -473,7 +489,7 @@ function It() {
|
|
|
473
489
|
*/
|
|
474
490
|
measure: function(o, c) {
|
|
475
491
|
var f = c ? o.bind(c) : o;
|
|
476
|
-
return this.reads.push(f),
|
|
492
|
+
return this.reads.push(f), s(this), f;
|
|
477
493
|
},
|
|
478
494
|
/**
|
|
479
495
|
* Adds a job to the
|
|
@@ -486,7 +502,7 @@ function It() {
|
|
|
486
502
|
*/
|
|
487
503
|
mutate: function(o, c) {
|
|
488
504
|
var f = c ? o.bind(c) : o;
|
|
489
|
-
return this.writes.push(f),
|
|
505
|
+
return this.writes.push(f), s(this), f;
|
|
490
506
|
},
|
|
491
507
|
/**
|
|
492
508
|
* Clears a scheduled 'read' or 'write' task.
|
|
@@ -542,17 +558,17 @@ function It() {
|
|
|
542
558
|
// when tasks throw
|
|
543
559
|
catch: null
|
|
544
560
|
};
|
|
545
|
-
function
|
|
561
|
+
function s(o) {
|
|
546
562
|
o.scheduled || (o.scheduled = !0, o.raf(u.bind(null, o)));
|
|
547
563
|
}
|
|
548
564
|
function u(o) {
|
|
549
565
|
var c = o.writes, f = o.reads, p;
|
|
550
566
|
try {
|
|
551
567
|
n("flushing reads", f.length), o.runTasks(f), n("flushing writes", c.length), o.runTasks(c);
|
|
552
|
-
} catch (
|
|
553
|
-
p =
|
|
568
|
+
} catch (h) {
|
|
569
|
+
p = h;
|
|
554
570
|
}
|
|
555
|
-
if (o.scheduled = !1, (f.length || c.length) &&
|
|
571
|
+
if (o.scheduled = !1, (f.length || c.length) && s(o), p)
|
|
556
572
|
if (n("task errored", p.message), o.catch) o.catch(p);
|
|
557
573
|
else throw p;
|
|
558
574
|
}
|
|
@@ -564,13 +580,13 @@ function It() {
|
|
|
564
580
|
for (var f in c)
|
|
565
581
|
c.hasOwnProperty(f) && (o[f] = c[f]);
|
|
566
582
|
}
|
|
567
|
-
var m = e.fastdom = e.fastdom || new
|
|
583
|
+
var m = e.fastdom = e.fastdom || new r();
|
|
568
584
|
t.exports = m;
|
|
569
585
|
})(typeof window < "u" ? window : typeof C < "u" ? C : globalThis);
|
|
570
586
|
})(A)), A.exports;
|
|
571
587
|
}
|
|
572
|
-
var
|
|
573
|
-
const E = /* @__PURE__ */ wt(
|
|
588
|
+
var It = Ot();
|
|
589
|
+
const E = /* @__PURE__ */ wt(It), $ = {};
|
|
574
590
|
function Nt(t) {
|
|
575
591
|
Object.assign($, t);
|
|
576
592
|
}
|
|
@@ -595,7 +611,7 @@ function T(t) {
|
|
|
595
611
|
function M(t, e, n) {
|
|
596
612
|
return `${t.name || "cover"} ${n && t.offset.unit !== "percentage" ? `calc(100% + ${T(t.offset)}${e ? ` + ${e}` : ""})` : e ? `calc(${T(t.offset)} + ${e})` : T(t.offset)}`;
|
|
597
613
|
}
|
|
598
|
-
function
|
|
614
|
+
function R(t) {
|
|
599
615
|
return {
|
|
600
616
|
start: M(t.startOffset, t.startOffsetAdd),
|
|
601
617
|
end: M(t.endOffset, t.endOffsetAdd, !0)
|
|
@@ -607,17 +623,17 @@ function L(t) {
|
|
|
607
623
|
function j(t) {
|
|
608
624
|
return (e) => E.mutate(() => e(t));
|
|
609
625
|
}
|
|
610
|
-
function
|
|
626
|
+
function O(t) {
|
|
611
627
|
if (t.namedEffect) {
|
|
612
628
|
const e = t.namedEffect.type;
|
|
613
629
|
return typeof e == "string" ? At(e) : null;
|
|
614
630
|
} else if (t.keyframeEffect) {
|
|
615
631
|
const e = (i) => {
|
|
616
|
-
const { name:
|
|
617
|
-
return [{ ...i, name:
|
|
632
|
+
const { name: r, keyframes: s } = i.keyframeEffect;
|
|
633
|
+
return [{ ...i, name: r, keyframes: s }];
|
|
618
634
|
};
|
|
619
635
|
return { web: e, style: e, getNames: (i) => {
|
|
620
|
-
const { effectId:
|
|
636
|
+
const { effectId: r } = i, { name: s } = i.keyframeEffect, u = s || r;
|
|
621
637
|
return u ? [u] : [];
|
|
622
638
|
} };
|
|
623
639
|
} else if (t.customEffect)
|
|
@@ -625,18 +641,18 @@ function I(t) {
|
|
|
625
641
|
return null;
|
|
626
642
|
}
|
|
627
643
|
function H(t, e, n) {
|
|
628
|
-
return t.map((i,
|
|
629
|
-
const
|
|
644
|
+
return t.map((i, r) => {
|
|
645
|
+
const s = {
|
|
630
646
|
fill: i.fill,
|
|
631
647
|
easing: gt(i.easing),
|
|
632
648
|
iterations: i.iterations === 0 ? 1 / 0 : i.iterations || 1,
|
|
633
649
|
composite: i.composite,
|
|
634
650
|
direction: Tt(i)
|
|
635
651
|
};
|
|
636
|
-
return q(e) ? (
|
|
652
|
+
return q(e) ? (s.duration = i.duration, s.delay = i.delay || 0) : window.ViewTimeline && e?.trigger === "view-progress" ? s.duration = "auto" : (s.duration = 99.99, s.delay = 0.01), {
|
|
637
653
|
effect: i,
|
|
638
|
-
options:
|
|
639
|
-
id: n && `${n}-${
|
|
654
|
+
options: s,
|
|
655
|
+
id: n && `${n}-${r + 1}`,
|
|
640
656
|
part: i.part
|
|
641
657
|
};
|
|
642
658
|
});
|
|
@@ -644,41 +660,41 @@ function H(t, e, n) {
|
|
|
644
660
|
function q(t) {
|
|
645
661
|
return !t || t.trigger !== "pointer-move" && t.trigger !== "view-progress";
|
|
646
662
|
}
|
|
647
|
-
function N(t, e, n, i,
|
|
663
|
+
function N(t, e, n, i, r) {
|
|
648
664
|
if (t) {
|
|
649
|
-
if (q(i) && (e.duration = e.duration || 1,
|
|
665
|
+
if (q(i) && (e.duration = e.duration || 1, r?.reducedMotion))
|
|
650
666
|
if (e.iterations === 1 || e.iterations == null)
|
|
651
667
|
e = { ...e, duration: 1 };
|
|
652
668
|
else
|
|
653
669
|
return [];
|
|
654
|
-
let
|
|
655
|
-
return n instanceof HTMLElement && (
|
|
670
|
+
let s;
|
|
671
|
+
return n instanceof HTMLElement && (s = { measure: L(n), mutate: j(n) }), t.web ? t.web(e, s, r) : t(e, s, r);
|
|
656
672
|
}
|
|
657
673
|
return [];
|
|
658
674
|
}
|
|
659
|
-
function V(t, e, n, i,
|
|
660
|
-
const
|
|
675
|
+
function V(t, e, n, i, r) {
|
|
676
|
+
const s = t instanceof HTMLElement ? t : w(t, r);
|
|
661
677
|
if (n?.trigger === "pointer-move" && !e.keyframeEffect) {
|
|
662
678
|
let f = e;
|
|
663
679
|
e.customEffect && (f = {
|
|
664
680
|
...e,
|
|
665
681
|
namedEffect: { id: "", type: "CustomMouse" }
|
|
666
682
|
});
|
|
667
|
-
const p =
|
|
683
|
+
const p = O(
|
|
668
684
|
f
|
|
669
|
-
),
|
|
685
|
+
), h = N(
|
|
670
686
|
p,
|
|
671
687
|
e,
|
|
672
|
-
|
|
688
|
+
s,
|
|
673
689
|
n,
|
|
674
690
|
i
|
|
675
691
|
);
|
|
676
|
-
return typeof
|
|
692
|
+
return typeof h != "function" ? null : h(s);
|
|
677
693
|
}
|
|
678
|
-
const u =
|
|
694
|
+
const u = O(e), a = N(
|
|
679
695
|
u,
|
|
680
696
|
e,
|
|
681
|
-
|
|
697
|
+
s,
|
|
682
698
|
n,
|
|
683
699
|
i
|
|
684
700
|
);
|
|
@@ -690,44 +706,44 @@ function V(t, e, n, i, s) {
|
|
|
690
706
|
o && window.ViewTimeline && (m = new ViewTimeline({
|
|
691
707
|
subject: n.element || w(n.componentId)
|
|
692
708
|
}));
|
|
693
|
-
const c = l.map(({ effect: f, options: p, id:
|
|
694
|
-
const v =
|
|
709
|
+
const c = l.map(({ effect: f, options: p, id: h, part: d }) => {
|
|
710
|
+
const v = d ? kt(s, d) : s, g = new KeyframeEffect(v || null, [], p);
|
|
695
711
|
E.mutate(() => {
|
|
696
712
|
"timing" in f && g.updateTiming(f.timing), g.setKeyframes(f.keyframes);
|
|
697
713
|
});
|
|
698
|
-
const
|
|
714
|
+
const y = o && m ? { timeline: m } : {}, b = typeof f.customEffect == "function" ? new _t(
|
|
699
715
|
f.customEffect,
|
|
700
716
|
v || null,
|
|
701
717
|
p,
|
|
702
|
-
|
|
703
|
-
) : new Animation(g,
|
|
718
|
+
y
|
|
719
|
+
) : new Animation(g, y.timeline);
|
|
704
720
|
if (o)
|
|
705
721
|
if (m)
|
|
706
722
|
E.mutate(() => {
|
|
707
|
-
const { start: _, end: k } =
|
|
708
|
-
|
|
723
|
+
const { start: _, end: k } = R(f);
|
|
724
|
+
b.rangeStart = _, b.rangeEnd = k, b.play();
|
|
709
725
|
});
|
|
710
726
|
else {
|
|
711
727
|
const { startOffset: _, endOffset: k } = e;
|
|
712
728
|
E.mutate(() => {
|
|
713
|
-
const
|
|
714
|
-
Object.assign(
|
|
729
|
+
const P = f.startOffset || _, S = f.endOffset || k;
|
|
730
|
+
Object.assign(b, {
|
|
715
731
|
start: {
|
|
716
|
-
name:
|
|
717
|
-
offset:
|
|
732
|
+
name: P.name,
|
|
733
|
+
offset: P.offset?.value,
|
|
718
734
|
add: f.startOffsetAdd
|
|
719
735
|
},
|
|
720
736
|
end: {
|
|
721
|
-
name:
|
|
722
|
-
offset:
|
|
737
|
+
name: S.name,
|
|
738
|
+
offset: S.offset?.value,
|
|
723
739
|
add: f.endOffsetAdd
|
|
724
740
|
}
|
|
725
741
|
});
|
|
726
742
|
});
|
|
727
743
|
}
|
|
728
|
-
return
|
|
744
|
+
return h && (b.id = h), b;
|
|
729
745
|
});
|
|
730
|
-
return new
|
|
746
|
+
return new I(c, {
|
|
731
747
|
...e,
|
|
732
748
|
trigger: { ...n || {} },
|
|
733
749
|
// make sure the group is ready after all animation targets are measured and mutated
|
|
@@ -738,16 +754,16 @@ function $t(t, e) {
|
|
|
738
754
|
return t ? `#${t}${e ? `[data-motion-part~="${e}"]` : ""}` : "";
|
|
739
755
|
}
|
|
740
756
|
function qt(t, e) {
|
|
741
|
-
const { duration: n, delay: i, iterations:
|
|
742
|
-
return `${l} ${m ? "auto" : `${n}ms`}${m ? " " : ` ${i || 1}ms `}${u}${
|
|
757
|
+
const { duration: n, delay: i, iterations: r = 1, fill: s, easing: u = "linear", direction: a } = t.options, l = t.effect.name, m = n === "auto";
|
|
758
|
+
return `${l} ${m ? "auto" : `${n}ms`}${m ? " " : ` ${i || 1}ms `}${u}${s && s !== "none" ? ` ${s}` : ""} ${!r || r === 1 / 0 ? "infinite" : r}${a === "normal" ? "" : ` ${a}`} ${e ? "" : "paused"}`;
|
|
743
759
|
}
|
|
744
|
-
function
|
|
760
|
+
function Pt(t, e, n) {
|
|
745
761
|
return t?.style ? (q(n) && (e.duration = e.duration || 1), t.style(e)) : [];
|
|
746
762
|
}
|
|
747
|
-
function
|
|
748
|
-
const i =
|
|
749
|
-
return
|
|
750
|
-
const { start: m, end: o } = u ?
|
|
763
|
+
function Gt(t, e, n) {
|
|
764
|
+
const i = O(e), r = Pt(i, e), s = H(r, n, e.effectId), u = n?.trigger === "view-progress";
|
|
765
|
+
return s.map((a, l) => {
|
|
766
|
+
const { start: m, end: o } = u ? R(a.effect) : {};
|
|
751
767
|
return {
|
|
752
768
|
target: $t(t, a.part),
|
|
753
769
|
animation: qt(a, u),
|
|
@@ -761,36 +777,36 @@ function Dt(t, e, n) {
|
|
|
761
777
|
};
|
|
762
778
|
});
|
|
763
779
|
}
|
|
764
|
-
function
|
|
765
|
-
const i =
|
|
766
|
-
if (i && i.prepare &&
|
|
767
|
-
const
|
|
768
|
-
i.prepare(e,
|
|
780
|
+
function St(t, e, n) {
|
|
781
|
+
const i = O(e), r = t instanceof HTMLElement ? t : w(t);
|
|
782
|
+
if (i && i.prepare && r) {
|
|
783
|
+
const s = { measure: L(r), mutate: j(r) };
|
|
784
|
+
i.prepare(e, s);
|
|
769
785
|
}
|
|
770
786
|
n && E.mutate(n);
|
|
771
787
|
}
|
|
772
788
|
function zt(t, e) {
|
|
773
|
-
const n =
|
|
789
|
+
const n = O(e);
|
|
774
790
|
if (!n)
|
|
775
791
|
return null;
|
|
776
792
|
if (!n.style)
|
|
777
793
|
return e.effectId && t ? Ft(t, e.effectId) : null;
|
|
778
|
-
const i = n.getNames(e),
|
|
794
|
+
const i = n.getNames(e), s = (typeof t == "string" ? w(t) : t)?.getAnimations(), u = s?.map((l) => l.animationName) || [], a = [];
|
|
779
795
|
return i.forEach((l) => {
|
|
780
796
|
u.includes(l) && a.push(
|
|
781
|
-
|
|
797
|
+
s?.find((m) => m.animationName === l)
|
|
782
798
|
);
|
|
783
|
-
}), a?.length ? new
|
|
799
|
+
}), a?.length ? new I(a) : null;
|
|
784
800
|
}
|
|
785
801
|
function Ft(t, e) {
|
|
786
|
-
const i = (typeof t == "string" ? w(t) : t)?.getAnimations().filter((
|
|
787
|
-
const
|
|
788
|
-
return
|
|
802
|
+
const i = (typeof t == "string" ? w(t) : t)?.getAnimations().filter((r) => {
|
|
803
|
+
const s = r.id || r.animationName;
|
|
804
|
+
return s ? s.startsWith(e) : !0;
|
|
789
805
|
});
|
|
790
|
-
return i?.length ? new
|
|
806
|
+
return i?.length ? new I(i) : null;
|
|
791
807
|
}
|
|
792
|
-
function
|
|
793
|
-
const { disabled:
|
|
808
|
+
function Dt(t, e, n, i = {}) {
|
|
809
|
+
const { disabled: r, allowActiveEvent: s, ...u } = i, a = V(t, e, n, u);
|
|
794
810
|
if (!a)
|
|
795
811
|
return null;
|
|
796
812
|
let l = {};
|
|
@@ -811,10 +827,10 @@ function Rt(t, e, n, i = {}) {
|
|
|
811
827
|
return a.getProgress();
|
|
812
828
|
},
|
|
813
829
|
effect(f, p) {
|
|
814
|
-
const { activeDuration:
|
|
815
|
-
c.currentTime = ((
|
|
830
|
+
const { activeDuration: h } = c.effect.getComputedTiming(), { delay: d } = c.effect.getTiming();
|
|
831
|
+
c.currentTime = ((d || 0) + (h || 0)) * p;
|
|
816
832
|
},
|
|
817
|
-
disabled:
|
|
833
|
+
disabled: r,
|
|
818
834
|
destroy() {
|
|
819
835
|
c.cancel();
|
|
820
836
|
}
|
|
@@ -822,29 +838,29 @@ function Rt(t, e, n, i = {}) {
|
|
|
822
838
|
} else if (n.trigger === "pointer-move") {
|
|
823
839
|
const m = e, { centeredToTarget: o, transitionDuration: c, transitionEasing: f } = m, p = n.axis;
|
|
824
840
|
if (m.keyframeEffect) {
|
|
825
|
-
const
|
|
826
|
-
return
|
|
841
|
+
const h = a;
|
|
842
|
+
return h.animations?.length === 0 ? null : {
|
|
827
843
|
target: void 0,
|
|
828
844
|
centeredToTarget: o,
|
|
829
|
-
ready:
|
|
845
|
+
ready: h.ready,
|
|
830
846
|
_currentProgress: 0,
|
|
831
847
|
getProgress() {
|
|
832
848
|
return this._currentProgress;
|
|
833
849
|
},
|
|
834
850
|
effect(v, g) {
|
|
835
|
-
const
|
|
836
|
-
this._currentProgress =
|
|
851
|
+
const y = p === "x" ? g.x : g.y;
|
|
852
|
+
this._currentProgress = y, h.progress(y);
|
|
837
853
|
},
|
|
838
|
-
disabled:
|
|
854
|
+
disabled: r ?? !1,
|
|
839
855
|
destroy() {
|
|
840
|
-
|
|
856
|
+
h.cancel();
|
|
841
857
|
}
|
|
842
858
|
};
|
|
843
859
|
}
|
|
844
860
|
l = {
|
|
845
861
|
centeredToTarget: o,
|
|
846
|
-
allowActiveEvent:
|
|
847
|
-
}, e.customEffect && c && (l.transitionDuration = c, l.transitionEasing =
|
|
862
|
+
allowActiveEvent: s
|
|
863
|
+
}, e.customEffect && c && (l.transitionDuration = c, l.transitionEasing = D(f)), l.target = a.target;
|
|
848
864
|
}
|
|
849
865
|
return {
|
|
850
866
|
...l,
|
|
@@ -861,45 +877,45 @@ function Rt(t, e, n, i = {}) {
|
|
|
861
877
|
} : o
|
|
862
878
|
);
|
|
863
879
|
},
|
|
864
|
-
disabled:
|
|
880
|
+
disabled: r,
|
|
865
881
|
destroy() {
|
|
866
882
|
a.cancel();
|
|
867
883
|
}
|
|
868
884
|
};
|
|
869
885
|
}
|
|
870
886
|
function Ct(t, e, n, i = !1) {
|
|
871
|
-
const
|
|
872
|
-
return
|
|
873
|
-
|
|
874
|
-
}),
|
|
887
|
+
const r = zt(t, e);
|
|
888
|
+
return r ? (r.ready = new Promise((s) => {
|
|
889
|
+
St(t, e, s);
|
|
890
|
+
}), r) : V(t, e, n, { reducedMotion: i });
|
|
875
891
|
}
|
|
876
892
|
function xt(t) {
|
|
877
893
|
return t === null ? [null] : typeof t == "string" ? Array.from(document.querySelectorAll(t)) : Array.isArray(t) ? t : [t];
|
|
878
894
|
}
|
|
879
895
|
function Mt(t, e) {
|
|
880
896
|
const n = [];
|
|
881
|
-
for (const { target: i, options:
|
|
882
|
-
const
|
|
883
|
-
for (const u of
|
|
897
|
+
for (const { target: i, options: r } of t) {
|
|
898
|
+
const s = xt(i);
|
|
899
|
+
for (const u of s) {
|
|
884
900
|
const a = Ct(
|
|
885
901
|
u,
|
|
886
|
-
|
|
902
|
+
r,
|
|
887
903
|
void 0,
|
|
888
904
|
e?.reducedMotion
|
|
889
905
|
);
|
|
890
|
-
a instanceof
|
|
906
|
+
a instanceof I && n.push(a);
|
|
891
907
|
}
|
|
892
908
|
}
|
|
893
909
|
return n;
|
|
894
910
|
}
|
|
895
|
-
function
|
|
911
|
+
function Rt(t, e, n) {
|
|
896
912
|
const i = Mt(e, n);
|
|
897
913
|
return new Et(i, t);
|
|
898
914
|
}
|
|
899
915
|
export {
|
|
900
916
|
mt as backIn,
|
|
901
|
-
|
|
902
|
-
|
|
917
|
+
dt as backInOut,
|
|
918
|
+
ht as backOut,
|
|
903
919
|
ut as circIn,
|
|
904
920
|
lt as circInOut,
|
|
905
921
|
ft as circOut,
|
|
@@ -912,18 +928,18 @@ export {
|
|
|
912
928
|
ct as expoInOut,
|
|
913
929
|
at as expoOut,
|
|
914
930
|
Ct as getAnimation,
|
|
915
|
-
|
|
931
|
+
Gt as getCSSAnimation,
|
|
916
932
|
pt as getCssUnits,
|
|
917
933
|
gt as getEasing,
|
|
918
934
|
Ft as getElementAnimation,
|
|
919
935
|
zt as getElementCSSAnimation,
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
936
|
+
D as getJsEasing,
|
|
937
|
+
Dt as getScrubScene,
|
|
938
|
+
Rt as getSequence,
|
|
923
939
|
V as getWebAnimation,
|
|
924
940
|
z as jsEasings,
|
|
925
|
-
|
|
926
|
-
|
|
941
|
+
G as linear,
|
|
942
|
+
St as prepareAnimation,
|
|
927
943
|
X as quadIn,
|
|
928
944
|
U as quadInOut,
|
|
929
945
|
J as quadOut,
|