@wix/motion 2.1.3 → 2.1.5
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/cjs/motion.js +1 -1
- package/dist/cjs/motion.js.map +1 -1
- package/dist/es/motion.js +38 -31
- package/dist/es/motion.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/AnimationGroup.d.ts +5 -0
- package/dist/types/AnimationGroup.d.ts.map +1 -1
- package/package.json +10 -6
package/dist/es/motion.js
CHANGED
|
@@ -3,11 +3,18 @@ class I {
|
|
|
3
3
|
options;
|
|
4
4
|
ready;
|
|
5
5
|
isCSS;
|
|
6
|
+
longestAnimation;
|
|
6
7
|
constructor(e, n) {
|
|
7
|
-
this.animations = e, this.options = n, this.ready = n?.measured || Promise.resolve(), this.isCSS = e[0] instanceof CSSAnimation;
|
|
8
|
+
this.animations = e, this.options = n, this.ready = n?.measured || Promise.resolve(), this.isCSS = e[0] instanceof CSSAnimation, this.longestAnimation = this._getAnimationWithLongestEndTime();
|
|
9
|
+
}
|
|
10
|
+
_getAnimationWithLongestEndTime() {
|
|
11
|
+
return this.animations.reduce((e, n) => {
|
|
12
|
+
const i = e.effect?.getComputedTiming().endTime ?? 0, r = n.effect?.getComputedTiming().endTime ?? 0;
|
|
13
|
+
return i > r ? e : n;
|
|
14
|
+
}, this.animations[0]);
|
|
8
15
|
}
|
|
9
16
|
getProgress() {
|
|
10
|
-
return this.
|
|
17
|
+
return this.longestAnimation?.effect?.getComputedTiming().progress || 0;
|
|
11
18
|
}
|
|
12
19
|
async play(e) {
|
|
13
20
|
await this.ready;
|
|
@@ -89,9 +96,9 @@ class I {
|
|
|
89
96
|
});
|
|
90
97
|
}
|
|
91
98
|
}
|
|
92
|
-
const G = (t) => t,
|
|
99
|
+
const G = (t) => t, V = (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), mt = (t) => t < 0.5 ? (1 - Math.sqrt(1 - 4 * t ** 2)) / 2 : (Math.sqrt(-(2 * t - 3) * (2 * t - 1)) + 1) / 2, lt = (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, C = {
|
|
93
100
|
linear: G,
|
|
94
|
-
sineIn:
|
|
101
|
+
sineIn: V,
|
|
95
102
|
sineOut: B,
|
|
96
103
|
sineInOut: K,
|
|
97
104
|
quadIn: X,
|
|
@@ -115,7 +122,7 @@ const G = (t) => t, W = (t) => 1 - Math.cos(t * Math.PI / 2), B = (t) => Math.si
|
|
|
115
122
|
backIn: lt,
|
|
116
123
|
backOut: ht,
|
|
117
124
|
backInOut: dt
|
|
118
|
-
},
|
|
125
|
+
}, z = {
|
|
119
126
|
linear: "linear",
|
|
120
127
|
ease: "ease",
|
|
121
128
|
easeIn: "ease-in",
|
|
@@ -150,7 +157,7 @@ function pt(t) {
|
|
|
150
157
|
return t === "percentage" ? "%" : t || "px";
|
|
151
158
|
}
|
|
152
159
|
function gt(t) {
|
|
153
|
-
return t ?
|
|
160
|
+
return t ? z[t] || t : z.linear;
|
|
154
161
|
}
|
|
155
162
|
function yt(t, e, n, i) {
|
|
156
163
|
const r = 3 * t, s = 3 * (n - t) - r, u = 1 - r - s, a = 3 * e, m = 3 * (i - e) - a, l = 1 - a - m, o = (h) => ((u * h + s) * h + r) * h, c = (h) => ((l * h + m) * h + a) * h, f = (h) => (3 * u * h + 2 * s) * h + r;
|
|
@@ -232,8 +239,8 @@ function vt(t) {
|
|
|
232
239
|
}
|
|
233
240
|
function D(t) {
|
|
234
241
|
if (!t) return;
|
|
235
|
-
const e =
|
|
236
|
-
return e || (bt(t) ?? vt(t) ??
|
|
242
|
+
const e = C[t];
|
|
243
|
+
return e || (bt(t) ?? vt(t) ?? C.linear);
|
|
237
244
|
}
|
|
238
245
|
class Et extends I {
|
|
239
246
|
animationGroups;
|
|
@@ -615,18 +622,18 @@ function At(t) {
|
|
|
615
622
|
function w(t, e) {
|
|
616
623
|
return t ? (e || document).getElementById(t) : null;
|
|
617
624
|
}
|
|
618
|
-
function
|
|
625
|
+
function Tt(t, e) {
|
|
619
626
|
return t?.matches(`[data-motion-part~="${e}"]`) ? t : t?.querySelector(`[data-motion-part~="${e}"]`);
|
|
620
627
|
}
|
|
621
|
-
function
|
|
628
|
+
function kt(t) {
|
|
622
629
|
const e = t.alternate ? "alternate" : "";
|
|
623
630
|
return t.reversed ? `${e ? `${e}-` : ""}reverse` : e || "normal";
|
|
624
631
|
}
|
|
625
|
-
function
|
|
632
|
+
function k(t) {
|
|
626
633
|
return `${t.value}${pt(t.unit)}`;
|
|
627
634
|
}
|
|
628
635
|
function M(t, e, n) {
|
|
629
|
-
return `${t.name || "cover"} ${n && t.offset.unit !== "percentage" ? `calc(100% + ${
|
|
636
|
+
return `${t.name || "cover"} ${n && t.offset.unit !== "percentage" ? `calc(100% + ${k(t.offset)}${e ? ` + ${e}` : ""})` : e ? `calc(${k(t.offset)} + ${e})` : k(t.offset)}`;
|
|
630
637
|
}
|
|
631
638
|
function R(t) {
|
|
632
639
|
return {
|
|
@@ -664,7 +671,7 @@ function H(t, e, n) {
|
|
|
664
671
|
easing: gt(i.easing),
|
|
665
672
|
iterations: i.iterations === 0 ? 1 / 0 : i.iterations || 1,
|
|
666
673
|
composite: i.composite,
|
|
667
|
-
direction:
|
|
674
|
+
direction: kt(i)
|
|
668
675
|
};
|
|
669
676
|
return S(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), {
|
|
670
677
|
effect: i,
|
|
@@ -689,7 +696,7 @@ function N(t, e, n, i, r) {
|
|
|
689
696
|
}
|
|
690
697
|
return [];
|
|
691
698
|
}
|
|
692
|
-
function
|
|
699
|
+
function W(t, e, n, i, r) {
|
|
693
700
|
const s = t instanceof HTMLElement ? t : w(t, r);
|
|
694
701
|
if (n?.trigger === "pointer-move" && !e.keyframeEffect) {
|
|
695
702
|
let f = e;
|
|
@@ -724,7 +731,7 @@ function V(t, e, n, i, r) {
|
|
|
724
731
|
subject: n.element || w(n.componentId)
|
|
725
732
|
}));
|
|
726
733
|
const c = m.map(({ effect: f, options: p, id: h, part: d }) => {
|
|
727
|
-
const v = d ?
|
|
734
|
+
const v = d ? Tt(s, d) : s, g = new KeyframeEffect(v || null, [], p);
|
|
728
735
|
E.mutate(() => {
|
|
729
736
|
"timing" in f && g.updateTiming(f.timing), g.setKeyframes(f.keyframes);
|
|
730
737
|
});
|
|
@@ -737,13 +744,13 @@ function V(t, e, n, i, r) {
|
|
|
737
744
|
if (o)
|
|
738
745
|
if (l)
|
|
739
746
|
E.mutate(() => {
|
|
740
|
-
const { start: _, end:
|
|
741
|
-
b.rangeStart = _, b.rangeEnd =
|
|
747
|
+
const { start: _, end: T } = R(f);
|
|
748
|
+
b.rangeStart = _, b.rangeEnd = T, b.play();
|
|
742
749
|
});
|
|
743
750
|
else {
|
|
744
|
-
const { startOffset: _, endOffset:
|
|
751
|
+
const { startOffset: _, endOffset: T } = e;
|
|
745
752
|
E.mutate(() => {
|
|
746
|
-
const q = f.startOffset || _, P = f.endOffset ||
|
|
753
|
+
const q = f.startOffset || _, P = f.endOffset || T;
|
|
747
754
|
Object.assign(b, {
|
|
748
755
|
start: {
|
|
749
756
|
name: q.name,
|
|
@@ -802,12 +809,12 @@ function Pt(t, e, n) {
|
|
|
802
809
|
}
|
|
803
810
|
n && E.mutate(n);
|
|
804
811
|
}
|
|
805
|
-
function
|
|
812
|
+
function Ct(t, e) {
|
|
806
813
|
const n = O(e);
|
|
807
814
|
if (!n)
|
|
808
815
|
return null;
|
|
809
816
|
if (!n.style)
|
|
810
|
-
return e.effectId && t ?
|
|
817
|
+
return e.effectId && t ? zt(t, e.effectId) : null;
|
|
811
818
|
const i = n.getNames(e), s = (typeof t == "string" ? w(t) : t)?.getAnimations(), u = s?.map((m) => m.animationName) || [], a = [];
|
|
812
819
|
return i.forEach((m) => {
|
|
813
820
|
u.includes(m) && a.push(
|
|
@@ -815,7 +822,7 @@ function zt(t, e) {
|
|
|
815
822
|
);
|
|
816
823
|
}), a?.length ? new I(a) : null;
|
|
817
824
|
}
|
|
818
|
-
function
|
|
825
|
+
function zt(t, e) {
|
|
819
826
|
const i = (typeof t == "string" ? w(t) : t)?.getAnimations().filter((r) => {
|
|
820
827
|
const s = r.id || r.animationName;
|
|
821
828
|
return s ? s.startsWith(e) : !0;
|
|
@@ -823,7 +830,7 @@ function Ct(t, e) {
|
|
|
823
830
|
return i?.length ? new I(i) : null;
|
|
824
831
|
}
|
|
825
832
|
function Dt(t, e, n, i = {}) {
|
|
826
|
-
const { disabled: r, allowActiveEvent: s, ...u } = i, a =
|
|
833
|
+
const { disabled: r, allowActiveEvent: s, ...u } = i, a = W(t, e, n, u);
|
|
827
834
|
if (!a)
|
|
828
835
|
return null;
|
|
829
836
|
let m = {};
|
|
@@ -901,10 +908,10 @@ function Dt(t, e, n, i = {}) {
|
|
|
901
908
|
};
|
|
902
909
|
}
|
|
903
910
|
function Ft(t, e, n, i = !1) {
|
|
904
|
-
const r =
|
|
911
|
+
const r = Ct(t, e);
|
|
905
912
|
return r ? (r.ready = new Promise((s) => {
|
|
906
913
|
Pt(t, e, s);
|
|
907
|
-
}), r) :
|
|
914
|
+
}), r) : W(t, e, n, { reducedMotion: i });
|
|
908
915
|
}
|
|
909
916
|
function xt(t) {
|
|
910
917
|
return t === null ? [null] : typeof t == "string" ? Array.from(document.querySelectorAll(t)) : Array.isArray(t) ? t : [t];
|
|
@@ -937,7 +944,7 @@ export {
|
|
|
937
944
|
mt as circInOut,
|
|
938
945
|
ft as circOut,
|
|
939
946
|
Mt as createAnimationGroups,
|
|
940
|
-
|
|
947
|
+
z as cssEasings,
|
|
941
948
|
Y as cubicIn,
|
|
942
949
|
Z as cubicInOut,
|
|
943
950
|
Q as cubicOut,
|
|
@@ -948,13 +955,13 @@ export {
|
|
|
948
955
|
Gt as getCSSAnimation,
|
|
949
956
|
pt as getCssUnits,
|
|
950
957
|
gt as getEasing,
|
|
951
|
-
|
|
952
|
-
|
|
958
|
+
zt as getElementAnimation,
|
|
959
|
+
Ct as getElementCSSAnimation,
|
|
953
960
|
D as getJsEasing,
|
|
954
961
|
Dt as getScrubScene,
|
|
955
962
|
Rt as getSequence,
|
|
956
|
-
|
|
957
|
-
|
|
963
|
+
W as getWebAnimation,
|
|
964
|
+
C as jsEasings,
|
|
958
965
|
G as linear,
|
|
959
966
|
Pt as prepareAnimation,
|
|
960
967
|
X as quadIn,
|
|
@@ -967,7 +974,7 @@ export {
|
|
|
967
974
|
rt as quintInOut,
|
|
968
975
|
st as quintOut,
|
|
969
976
|
Nt as registerEffects,
|
|
970
|
-
|
|
977
|
+
V as sineIn,
|
|
971
978
|
K as sineInOut,
|
|
972
979
|
B as sineOut
|
|
973
980
|
};
|