@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 O {
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: s, iterations: r } = n.effect.getTiming(), u = (Number.isFinite(s) ? s : 0) * (Number.isFinite(r) ? r : 1);
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 s = new Event("animationend");
50
- i.dispatchEvent(s);
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, s = Number(n?.duration) || 0, r = n?.iterations ?? 1;
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: s,
70
- iterations: r
69
+ duration: r,
70
+ iterations: s
71
71
  };
72
72
  });
73
73
  }
74
74
  }
75
- const D = (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, dt = (t) => 1 + 2.70158 * (t - 1) ** 3 + 1.70158 * (t - 1) ** 2, ht = (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: D,
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: dt,
100
- backInOut: ht
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 bt(t, e, n, i) {
139
- const s = 3 * t, r = 3 * (n - t) - s, u = 1 - s - r, a = 3 * e, l = 3 * (i - e) - a, m = 1 - a - l, o = (d) => ((u * d + r) * d + s) * d, c = (d) => ((m * d + l) * d + a) * d, f = (d) => (3 * u * d + 2 * r) * d + s;
140
- function p(d) {
141
- let h = d;
142
- for (let b = 0; b < 8; b++) {
143
- const y = o(h) - d;
144
- if (Math.abs(y) < 1e-7) return h;
145
- const _ = f(h);
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
- h -= y / _;
147
+ d -= b / _;
148
148
  }
149
149
  let v = 0, g = 1;
150
- for (h = (v + g) / 2; g - v > 1e-7; ) {
151
- const b = o(h);
152
- if (Math.abs(b - d) < 1e-7) return h;
153
- d > b ? v = h : g = h, h = (v + g) / 2;
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 h;
155
+ return d;
156
156
  }
157
- return (d) => d <= 0 ? 0 : d >= 1 ? 1 : c(p(d));
157
+ return (h) => h <= 0 ? 0 : h >= 1 ? 1 : c(p(h));
158
158
  }
159
- function yt(t) {
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]), s = parseFloat(e[3]), r = parseFloat(e[4]);
165
- if (![n, i, s, r].some(isNaN))
166
- return bt(n, i, s, r);
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 s = 0;
189
- for (; s < i.length; )
190
- if (i[s].pos === null) {
191
- const u = s - 1;
192
- let a = s;
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
- s = a + 1;
197
+ r = a + 1;
198
198
  } else
199
- s++;
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 r = i;
202
+ const s = i;
203
203
  return (u) => {
204
- if (u <= r[0].pos) return r[0].output;
205
- const a = r[r.length - 1];
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 = r.length - 1;
207
+ let l = 0, m = s.length - 1;
208
208
  for (; l < m - 1; ) {
209
209
  const f = l + m >>> 1;
210
- r[f].pos <= u ? l = f : m = f;
210
+ s[f].pos <= u ? l = f : m = f;
211
211
  }
212
- const o = r[l], c = r[m];
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 R(t) {
216
+ function D(t) {
217
217
  if (!t) return;
218
218
  const e = z[t];
219
- return e || (yt(t) ?? vt(t) ?? z.linear);
219
+ return e || (bt(t) ?? vt(t) ?? z.linear);
220
220
  }
221
- class Et extends O {
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((s) => [...s.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 : R(n.offsetEasing) ?? D, this.timingOptions = this.animationGroups.map((s) => s.getTimingOptions().map(({ delay: r, duration: u, iterations: a }) => ({
230
- delay: r,
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((s) => s.ready)).then(() => {
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, s) => this.offsetEasing(s / n) * n * this.offset | 0
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, s) => {
253
- i.animations.forEach((r, u) => {
254
- const a = r.effect;
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[s][u], c = l + e[s], f = n - (c + m * o);
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 s = this.timingOptions[i].reduce((r, u) => {
265
- if (!u) return r;
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(r, a + l * m);
267
+ return Math.max(s, a + l * m);
268
268
  }, 0);
269
- n.push(e[i] + s);
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, s) => s.index - i.index);
281
- for (const { index: i, group: s } of n) {
282
- const r = Math.min(i, this.animationGroups.length);
283
- this.animationGroups.splice(r, 0, s), this.timingOptions.splice(r, 0, s.getTimingOptions());
284
- const u = [...s.animations], a = this.animationGroups.slice(0, r).reduce((l, m) => l + m.animations.length, 0);
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, s) {
305
- const r = new KeyframeEffect(n, [], {
319
+ constructor(e, n, i, r) {
320
+ const s = new KeyframeEffect(n, [], {
306
321
  ...i,
307
322
  composite: "add"
308
- }), { timeline: u } = s;
309
- this._animation = new Animation(r, u), this._tickCbId = null, this.progress = null, this.customEffect = (a) => e(r.target, a), this._finishHandler = (a) => {
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 It() {
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 s() {
464
+ function r() {
450
465
  var o = this;
451
466
  o.reads = [], o.writes = [], o.raf = i.bind(e);
452
467
  }
453
- s.prototype = {
454
- constructor: s,
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), r(this), 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), r(this), 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 r(o) {
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 (d) {
553
- p = d;
567
+ } catch (h) {
568
+ p = h;
554
569
  }
555
- if (o.scheduled = !1, (f.length || c.length) && r(o), p)
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 s();
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 Ot = It();
573
- const E = /* @__PURE__ */ wt(Ot), $ = {};
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 G(t) {
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 I(t) {
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: s, keyframes: r } = i.keyframeEffect;
617
- return [{ ...i, name: s, keyframes: r }];
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: s } = i, { name: r } = i.keyframeEffect, u = r || s;
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, s) => {
629
- const r = {
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) ? (r.duration = i.duration, r.delay = i.delay || 0) : window.ViewTimeline && e?.trigger === "view-progress" ? r.duration = "auto" : (r.duration = 99.99, r.delay = 0.01), {
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: r,
639
- id: n && `${n}-${s + 1}`,
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, s) {
662
+ function N(t, e, n, i, r) {
648
663
  if (t) {
649
- if (q(i) && (e.duration = e.duration || 1, s?.reducedMotion))
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 r;
655
- return n instanceof HTMLElement && (r = { measure: L(n), mutate: j(n) }), t.web ? t.web(e, r, s) : t(e, r, s);
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, s) {
660
- const r = t instanceof HTMLElement ? t : w(t, s);
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 = I(
682
+ const p = O(
668
683
  f
669
- ), d = N(
684
+ ), h = N(
670
685
  p,
671
686
  e,
672
- r,
687
+ s,
673
688
  n,
674
689
  i
675
690
  );
676
- return typeof d != "function" ? null : d(r);
691
+ return typeof h != "function" ? null : h(s);
677
692
  }
678
- const u = I(e), a = N(
693
+ const u = O(e), a = N(
679
694
  u,
680
695
  e,
681
- r,
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: d, part: h }) => {
694
- const v = h ? kt(r, h) : r, g = new KeyframeEffect(v || null, [], p);
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 b = o && m ? { timeline: m } : {}, y = typeof f.customEffect == "function" ? new _t(
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
- b
703
- ) : new Animation(g, b.timeline);
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 } = G(f);
708
- y.rangeStart = _, y.rangeEnd = k, y.play();
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 S = f.startOffset || _, P = f.endOffset || k;
714
- Object.assign(y, {
728
+ const P = f.startOffset || _, S = f.endOffset || k;
729
+ Object.assign(b, {
715
730
  start: {
716
- name: S.name,
717
- offset: S.offset?.value,
731
+ name: P.name,
732
+ offset: P.offset?.value,
718
733
  add: f.startOffsetAdd
719
734
  },
720
735
  end: {
721
- name: P.name,
722
- offset: P.offset?.value,
736
+ name: S.name,
737
+ offset: S.offset?.value,
723
738
  add: f.endOffsetAdd
724
739
  }
725
740
  });
726
741
  });
727
742
  }
728
- return d && (y.id = d), y;
743
+ return h && (b.id = h), b;
729
744
  });
730
- return new O(c, {
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: s = 1, fill: r, easing: u = "linear", direction: a } = t.options, l = t.effect.name, m = n === "auto";
742
- return `${l} ${m ? "auto" : `${n}ms`}${m ? " " : ` ${i || 1}ms `}${u}${r && r !== "none" ? ` ${r}` : ""} ${!s || s === 1 / 0 ? "infinite" : s}${a === "normal" ? "" : ` ${a}`} ${e ? "" : "paused"}`;
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 St(t, e, n) {
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 Dt(t, e, n) {
748
- const i = I(e), s = St(i, e), r = H(s, n, e.effectId), u = n?.trigger === "view-progress";
749
- return r.map((a, l) => {
750
- const { start: m, end: o } = u ? G(a.effect) : {};
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 Pt(t, e, n) {
765
- const i = I(e), s = t instanceof HTMLElement ? t : w(t);
766
- if (i && i.prepare && s) {
767
- const r = { measure: L(s), mutate: j(s) };
768
- i.prepare(e, r);
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 = I(e);
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), r = (typeof t == "string" ? w(t) : t)?.getAnimations(), u = r?.map((l) => l.animationName) || [], a = [];
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
- r?.find((m) => m.animationName === l)
796
+ s?.find((m) => m.animationName === l)
782
797
  );
783
- }), a?.length ? new O(a) : null;
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((s) => {
787
- const r = s.id || s.animationName;
788
- return r ? r.startsWith(e) : !0;
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 O(i) : null;
805
+ return i?.length ? new I(i) : null;
791
806
  }
792
- function Rt(t, e, n, i = {}) {
793
- const { disabled: s, allowActiveEvent: r, ...u } = i, a = V(t, e, n, u);
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: d } = c.effect.getComputedTiming(), { delay: h } = c.effect.getTiming();
815
- c.currentTime = ((h || 0) + (d || 0)) * p;
829
+ const { activeDuration: h } = c.effect.getComputedTiming(), { delay: d } = c.effect.getTiming();
830
+ c.currentTime = ((d || 0) + (h || 0)) * p;
816
831
  },
817
- disabled: s,
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 d = a;
826
- return d.animations?.length === 0 ? null : {
840
+ const h = a;
841
+ return h.animations?.length === 0 ? null : {
827
842
  target: void 0,
828
843
  centeredToTarget: o,
829
- ready: d.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 b = p === "x" ? g.x : g.y;
836
- this._currentProgress = b, d.progress(b);
850
+ const y = p === "x" ? g.x : g.y;
851
+ this._currentProgress = y, h.progress(y);
837
852
  },
838
- disabled: s ?? !1,
853
+ disabled: r ?? !1,
839
854
  destroy() {
840
- d.cancel();
855
+ h.cancel();
841
856
  }
842
857
  };
843
858
  }
844
859
  l = {
845
860
  centeredToTarget: o,
846
- allowActiveEvent: r
847
- }, e.customEffect && c && (l.transitionDuration = c, l.transitionEasing = R(f)), l.target = a.target;
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: s,
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 s = zt(t, e);
872
- return s ? (s.ready = new Promise((r) => {
873
- Pt(t, e, r);
874
- }), s) : V(t, e, n, { reducedMotion: i });
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: s } of t) {
882
- const r = xt(i);
883
- for (const u of r) {
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
- s,
901
+ r,
887
902
  void 0,
888
903
  e?.reducedMotion
889
904
  );
890
- a instanceof O && n.push(a);
905
+ a instanceof I && n.push(a);
891
906
  }
892
907
  }
893
908
  return n;
894
909
  }
895
- function Gt(t, e, n) {
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
- ht as backInOut,
902
- dt as backOut,
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
- Dt as getCSSAnimation,
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
- R as getJsEasing,
921
- Rt as getScrubScene,
922
- Gt as getSequence,
935
+ D as getJsEasing,
936
+ Dt as getScrubScene,
937
+ Rt as getSequence,
923
938
  V as getWebAnimation,
924
939
  z as jsEasings,
925
- D as linear,
926
- Pt as prepareAnimation,
940
+ G as linear,
941
+ St as prepareAnimation,
927
942
  X as quadIn,
928
943
  U as quadInOut,
929
944
  J as quadOut,