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