@mkbabb/keyframes.js 5.0.0 → 5.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/README.md +31 -216
- package/dist/animation-BGyzfzBq.js +947 -0
- package/dist/compile-CcSUwM8R.js +276 -0
- package/dist/{waapi-D0ssxKy1.js → delegation-DWwr4IXr.js} +115 -93
- package/dist/{draw-svg-Dat9mHgi.js → draw-svg-GURj9nin.js} +17 -13
- package/dist/easing-registry-DHV2-5gA.js +27 -0
- package/dist/easing-registry-y1p9McFy.js +2 -0
- package/dist/engine/index.d.ts +2873 -0
- package/dist/engine/index.js +17 -0
- package/dist/engine-DEVgCTUy.js +156 -0
- package/dist/engine-DrBtsKaf.js +4 -0
- package/dist/{format-BUgCTjmr.js → format-C-Gi9r7L.js} +4 -4
- package/dist/{scroll-grammar-B4kPvGh5.js → grammar-BLucehC4.js} +1 -1
- package/dist/group-vJcsHKN9.js +360 -0
- package/dist/{ingest-CU-kdYcM.js → ingest-S5hUe20K.js} +62 -56
- package/dist/keyframes.d.ts +475 -942
- package/dist/keyframes.js +196 -137
- package/dist/morph-svg-BToeumw5.js +89 -0
- package/dist/{motion-path-C0OHqcA3.js → motion-path-pQVbamWT.js} +16 -12
- package/dist/parse-flatten-DRMHFytp.js +2 -0
- package/dist/parse-flatten-ZZUSEQEL.js +63 -0
- package/dist/{animations-CZxf0rep.js → presets-BG2Fczzq.js} +124 -73
- package/dist/{scheduler-7eIr_q1g.js → scheduler-CUtVnuoU.js} +1 -1
- package/dist/{scroll-scene-DQxhxn9I.js → scroll-CxpYFO4u.js} +50 -46
- package/dist/sequence-C_DCiOIQ.js +708 -0
- package/dist/validate-DDeGnvSt.js +39 -0
- package/package.json +12 -3
- package/dist/animate-CTWr6K7j.js +0 -26
- package/dist/compile-YRJRdpKF.js +0 -251
- package/dist/decay-BvNmFk51.js +0 -25
- package/dist/engine-DQcb7CLW.js +0 -1349
- package/dist/errors-W8zkvPw4.js +0 -21
- package/dist/morph-svg-83uyYxoW.js +0 -84
- package/dist/rolldown-runtime-Dy4uBu1J.js +0 -11
- package/dist/sequence-cBr7thU8.js +0 -198
- package/dist/springTimingFunction-D26gPkAy.js +0 -63
- package/dist/timeline-vY3eD3Ax.js +0 -430
- package/dist/utils-BPRImVl5.js +0 -100
- package/dist/validate-B1pE-Y_T.js +0 -35
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { t as e } from "../presets-BG2Fczzq.js";
|
|
2
|
+
import { f as t, g as n, h as r, n as i, p as a, t as o } from "../animation-BGyzfzBq.js";
|
|
3
|
+
import { r as s } from "../parse-flatten-ZZUSEQEL.js";
|
|
4
|
+
import { t as c } from "../easing-registry-DHV2-5gA.js";
|
|
5
|
+
import { n as l, t as u } from "../engine-DEVgCTUy.js";
|
|
6
|
+
import { n as d } from "../group-vJcsHKN9.js";
|
|
7
|
+
import { n as f } from "../scheduler-CUtVnuoU.js";
|
|
8
|
+
import { n as p, t as m } from "../motion-path-pQVbamWT.js";
|
|
9
|
+
import { r as h, t as g } from "../draw-svg-GURj9nin.js";
|
|
10
|
+
import { n as _, t as v } from "../morph-svg-BToeumw5.js";
|
|
11
|
+
import { a as y, i as b, n as x, r as S } from "../ingest-S5hUe20K.js";
|
|
12
|
+
import { a as C, i as w, n as T, o as E, r as D } from "../scroll-CxpYFO4u.js";
|
|
13
|
+
import { a as O, i as k, n as A, r as j, t as M } from "../grammar-BLucehC4.js";
|
|
14
|
+
import { n as N } from "../compile-CcSUwM8R.js";
|
|
15
|
+
import { a as P, n as F, t as I } from "../format-C-Gi9r7L.js";
|
|
16
|
+
import { n as L, t as R } from "../validate-DDeGnvSt.js";
|
|
17
|
+
export { d as AnimationGroup, u as CSSKeyframesAnimation, I as CSSKeyframesToString, F as CSSKeyframesToStrings, t as DIRECTIONS, g as DrawSVG, a as FILL_MODES, o as KeyframesAnimation, v as MorphSVG, m as MotionPath, T as ScrollScene, x as adoptRunning, N as compileToCSS, D as createScrollScene, r as defaultLayerConfig, n as defaultOptions, w as dispatchScrollBackend, R as explain, P as formatCSSKeyframeString, h as fromDrawSVG, S as fromLiveAnimations, _ as fromMorphSVG, p as fromMotionPath, b as fromStyleSheets, i as getAnimationId, c as getTimingFunction, M as parseScrollCSS, A as parseScrollRange, j as parseScrollTimeline, C as pinCSS, e as presets, l as resolveKeyframes, y as resolveLiveKeyframes, E as resolveRange, k as roundTripScrollCSS, O as serializeScrollOptions, s as transformTargetsStyle, L as validate, f as yieldToMain };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { g as e } from "./sequence-C_DCiOIQ.js";
|
|
2
|
+
import { a as t, i as n, o as r, r as i, t as a, u as o } from "./animation-BGyzfzBq.js";
|
|
3
|
+
import { r as s } from "./parse-flatten-ZZUSEQEL.js";
|
|
4
|
+
import { t as c } from "./easing-registry-DHV2-5gA.js";
|
|
5
|
+
import { ValueArray as l, ValueUnit as u, extractAnimationOptions as d, extractFunctions as f, extractKeyframes as p, extractProperties as m, extractTimelineOptions as h, isObject as g, parseCSSStylesheet as _ } from "@mkbabb/value.js";
|
|
6
|
+
//#region src/animation/adapter.ts
|
|
7
|
+
var v = (e, r) => {
|
|
8
|
+
let a = {};
|
|
9
|
+
for (let o of e.declarations) {
|
|
10
|
+
let e = o.value;
|
|
11
|
+
if (e instanceof l && i(e)) {
|
|
12
|
+
let i = n(e, r);
|
|
13
|
+
if (i === t) continue;
|
|
14
|
+
e = i;
|
|
15
|
+
}
|
|
16
|
+
a[o.name] = e;
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
}, y = (e) => {
|
|
20
|
+
let t = [];
|
|
21
|
+
for (let n of e.selectors) n.kind === "percent" ? t.push(`${n.value}%`) : t.push(n.name);
|
|
22
|
+
return t;
|
|
23
|
+
}, b = (e) => {
|
|
24
|
+
let t = p(e);
|
|
25
|
+
for (let e of t.values()) if (e.length > 0) return e;
|
|
26
|
+
return [];
|
|
27
|
+
}, x = (e, t) => {
|
|
28
|
+
let n = [], i = (e, t) => {
|
|
29
|
+
n.push({
|
|
30
|
+
code: e,
|
|
31
|
+
message: t.message ?? e,
|
|
32
|
+
...t
|
|
33
|
+
});
|
|
34
|
+
}, a = typeof e == "string" ? _(e) : e, o = b(a);
|
|
35
|
+
typeof e == "string" && o.length === 0 && e.trim() && (a = _(`@keyframes anonymous {\n${e.trim()}\n}`), o = b(a)), typeof e == "string" && o.length === 0 && e.trim() && i("EMPTY_PARSE", {
|
|
36
|
+
message: "the input is non-empty but parsed to zero @keyframes rules (no animatable stops) — the resulting animation has no frames",
|
|
37
|
+
input: e
|
|
38
|
+
});
|
|
39
|
+
let s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = f(a), p = r(u, t, n);
|
|
40
|
+
for (let e of o) {
|
|
41
|
+
let t = v(e, p);
|
|
42
|
+
for (let n of y(e)) {
|
|
43
|
+
let r = s.get(n);
|
|
44
|
+
s.set(n, {
|
|
45
|
+
...r ?? {},
|
|
46
|
+
...t
|
|
47
|
+
}), e.timingFunction != null && c.set(n, e.timingFunction);
|
|
48
|
+
let i = e.composition;
|
|
49
|
+
i != null && l.set(n, i);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
keyframes: s,
|
|
54
|
+
timingFunctions: c,
|
|
55
|
+
composition: l,
|
|
56
|
+
properties: m(a),
|
|
57
|
+
functions: u,
|
|
58
|
+
options: d(a),
|
|
59
|
+
diagnostics: n,
|
|
60
|
+
stylesheet: a
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/animation/engine/css-metadata.ts
|
|
65
|
+
function S(e) {
|
|
66
|
+
let t = {};
|
|
67
|
+
return e.duration != null && (t.duration = e.duration), e.timingFunction != null && (t.timingFunction = e.timingFunction), e.iterationCount !== void 0 && (t.iterationCount = e.iterationCount === null ? Infinity : e.iterationCount), e.direction != null && (t.direction = e.direction), e.delay != null && (t.delay = e.delay), e.fillMode != null && (t.fillMode = e.fillMode), e.composition != null && (t.composite = e.composition), t;
|
|
68
|
+
}
|
|
69
|
+
function C(e) {
|
|
70
|
+
let t = h(e);
|
|
71
|
+
return Object.keys(t).length > 0 ? t : void 0;
|
|
72
|
+
}
|
|
73
|
+
function w(e, t) {
|
|
74
|
+
if (!(typeof CSS > "u" || typeof CSS.registerProperty != "function")) for (let [n, r] of e) {
|
|
75
|
+
if (r.syntax == null) continue;
|
|
76
|
+
let e = {
|
|
77
|
+
name: n,
|
|
78
|
+
syntax: r.syntax,
|
|
79
|
+
inherits: r.inherits ?? !1
|
|
80
|
+
};
|
|
81
|
+
r.initialValue != null && (e.initialValue = r.initialValue.toString());
|
|
82
|
+
try {
|
|
83
|
+
CSS.registerProperty(e);
|
|
84
|
+
} catch (e) {
|
|
85
|
+
if (e instanceof DOMException && e.name === "InvalidModificationError") continue;
|
|
86
|
+
t.push({
|
|
87
|
+
code: "PROPERTY_REGISTER_REJECTED",
|
|
88
|
+
property: n,
|
|
89
|
+
message: `CSS.registerProperty refused @property ${n}: ${String(e)}`
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/animation/engine/css-animation.ts
|
|
96
|
+
var T = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function", E = class extends a {
|
|
97
|
+
_boundTimeline;
|
|
98
|
+
constructor(e, ...t) {
|
|
99
|
+
super(e, t), this.unflatten = !1;
|
|
100
|
+
}
|
|
101
|
+
bindTimeline(e) {
|
|
102
|
+
this._boundTimeline = e;
|
|
103
|
+
let t = !1;
|
|
104
|
+
for (let e of this.compiler.templateFrames) e.start.superType?.includes("named-selector") && (e.start = new u(o(String(e.start.value)) * 100, "%"), t = !0);
|
|
105
|
+
return t && this.compiler.frames.length > 0 && this.parse(), this;
|
|
106
|
+
}
|
|
107
|
+
resolveTransform(e) {
|
|
108
|
+
return this.unflatten = e != null, e ?? this._defaultTransform;
|
|
109
|
+
}
|
|
110
|
+
fromVars(e, t) {
|
|
111
|
+
t = this.resolveTransform(t);
|
|
112
|
+
for (let n = 0; n < e.length; n++) {
|
|
113
|
+
let r = e[n], i = Math.round(n / (e.length - 1) * 100);
|
|
114
|
+
this.addFrame(i, r, t);
|
|
115
|
+
}
|
|
116
|
+
return this.parse(), this;
|
|
117
|
+
}
|
|
118
|
+
fromKeyframes(e, t) {
|
|
119
|
+
t = this.resolveTransform(t), g(e) && (e = new Map(Object.entries(e)));
|
|
120
|
+
let n = e instanceof Map ? e.entries() : Object.entries(e);
|
|
121
|
+
for (let [e, r] of n) this.addFrame(e, r, t);
|
|
122
|
+
return this.parse(), this;
|
|
123
|
+
}
|
|
124
|
+
propertyRegistry = /* @__PURE__ */ new Map();
|
|
125
|
+
scrollOptions;
|
|
126
|
+
fromString(t, n) {
|
|
127
|
+
n = this.resolveTransform(n);
|
|
128
|
+
let r = x(t);
|
|
129
|
+
this.propertyRegistry = r.properties;
|
|
130
|
+
let i = C(r.stylesheet);
|
|
131
|
+
i === void 0 ? delete this.scrollOptions : this.scrollOptions = i, this.diagnostics = [...r.diagnostics];
|
|
132
|
+
let a = S(r.options);
|
|
133
|
+
Object.keys(a).length > 0 && this.setOptions({
|
|
134
|
+
...a,
|
|
135
|
+
...this._ctorOptions
|
|
136
|
+
});
|
|
137
|
+
for (let [t, i] of r.keyframes.entries()) {
|
|
138
|
+
let a = Object.fromEntries(Object.entries(i).map(([e, t]) => [e, T(t) ? t.clone() : t])), o = r.timingFunctions.get(t), s = o ? c(o) : void 0, l;
|
|
139
|
+
if (s) {
|
|
140
|
+
let t = o ? e(o) : void 0;
|
|
141
|
+
l = t ? {
|
|
142
|
+
fn: s,
|
|
143
|
+
css: t
|
|
144
|
+
} : { fn: s };
|
|
145
|
+
}
|
|
146
|
+
let u = r.composition.get(t);
|
|
147
|
+
this.addFrame(t, a, n, l, u);
|
|
148
|
+
}
|
|
149
|
+
return this.parse(), w(this.propertyRegistry, this.diagnostics), this;
|
|
150
|
+
}
|
|
151
|
+
transform(e) {
|
|
152
|
+
s(e, this.targets);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
//#endregion
|
|
156
|
+
export { x as n, E as t };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { f as e, g as t, h as n, n as r, p as i, t as a } from "./animation-BGyzfzBq.js";
|
|
2
|
+
import { t as o } from "./easing-registry-DHV2-5gA.js";
|
|
3
|
+
import { n as s, t as c } from "./engine-DEVgCTUy.js";
|
|
4
|
+
export { c as CSSKeyframesAnimation, e as DIRECTIONS, i as FILL_MODES, a as KeyframesAnimation, n as defaultLayerConfig, t as defaultOptions, r as getAnimationId, o as getTimingFunction, s as resolveKeyframes };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "./
|
|
1
|
+
import { n as e } from "./presets-BG2Fczzq.js";
|
|
2
|
+
import { y as t } from "./sequence-C_DCiOIQ.js";
|
|
3
3
|
import { camelCaseToHyphen as n, formatCSS as r, reverseAnimationShorthand as i, reverseCSSTime as a, serializeStylesheetItem as o, timingFunctions as s, unflattenObjectToString as c } from "@mkbabb/value.js";
|
|
4
|
-
//#region src/animation/format.ts
|
|
4
|
+
//#region src/animation/compile/format.ts
|
|
5
5
|
var l = /* @__PURE__ */ e({
|
|
6
6
|
CSSKeyframesToString: () => w,
|
|
7
7
|
CSSKeyframesToStrings: () => h,
|
|
@@ -120,4 +120,4 @@ async function w(e, t = "animation", n = void 0) {
|
|
|
120
120
|
return (await r(`${l ? `${l}\n\n` : ""}${c}\n@keyframes ${t} {\n${s}}`, n)).replace(/\(\s*\{/g, "{").replace(/\}\s*\)/g, "}");
|
|
121
121
|
}
|
|
122
122
|
//#endregion
|
|
123
|
-
export {
|
|
123
|
+
export { g as a, b as c, x as i, u as l, h as n, l as o, S as r, y as s, w as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { extractTimelineOptions as e, parseAnimationRange as t, parseAnimationTimeline as n, parseCSSStylesheet as r, serializeTimelineOptions as i } from "@mkbabb/value.js";
|
|
2
|
-
//#region src/animation/scroll
|
|
2
|
+
//#region src/animation/scroll/grammar.ts
|
|
3
3
|
function a(e) {
|
|
4
4
|
return n(e);
|
|
5
5
|
}
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import { n as e } from "./presets-BG2Fczzq.js";
|
|
2
|
+
import { d as t, l as n, s as r } from "./sequence-C_DCiOIQ.js";
|
|
3
|
+
import { d as i, h as a, m as o, n as s, t as c } from "./animation-BGyzfzBq.js";
|
|
4
|
+
import { n as l } from "./scheduler-CUtVnuoU.js";
|
|
5
|
+
import { ValueUnit as u, lerp as d } from "@mkbabb/value.js";
|
|
6
|
+
//#region src/animation/group/entries.ts
|
|
7
|
+
var f = (e) => typeof e == "string" ? e : s(e), p = (e, t, n) => {
|
|
8
|
+
let r = f(t), i = e[r];
|
|
9
|
+
if (!i) throw Error(`AnimationGroup.${n}: no animation registered for key "${r}". Known keys: ${Object.keys(e).join(", ") || "(none)"}.`);
|
|
10
|
+
return i;
|
|
11
|
+
}, m = (e) => {
|
|
12
|
+
let t = /* @__PURE__ */ new Set();
|
|
13
|
+
for (let n of e) {
|
|
14
|
+
let e = n.layer.properties;
|
|
15
|
+
for (let r of n.animation.flatKeys) e && !e.has(r) || t.add(r);
|
|
16
|
+
}
|
|
17
|
+
return [...t];
|
|
18
|
+
}, h = (e) => {
|
|
19
|
+
let t = !0;
|
|
20
|
+
for (let n of e) n.animation.interpFrames(n.animation.t, !0), t &&= n.animation.done;
|
|
21
|
+
return t;
|
|
22
|
+
}, g = (e) => {
|
|
23
|
+
for (let t of e) {
|
|
24
|
+
let e = t.animation;
|
|
25
|
+
e.started = !0, e.t = e.options.duration, e.interpFrames(e.t, !0);
|
|
26
|
+
}
|
|
27
|
+
}, _ = (e, t) => {
|
|
28
|
+
for (let n of e) n.animation.paused = t;
|
|
29
|
+
}, v = (e, t) => {
|
|
30
|
+
let n;
|
|
31
|
+
for (let r of e) {
|
|
32
|
+
let e = r.animation;
|
|
33
|
+
if (e.paused && e.pausedTime !== 0) continue;
|
|
34
|
+
let i = e.advanceTo(t);
|
|
35
|
+
typeof i != "number" && (n ??= []).push(i);
|
|
36
|
+
}
|
|
37
|
+
return n && Promise.all(n).then(() => void 0);
|
|
38
|
+
}, y = async (e, t, n) => {
|
|
39
|
+
for (let r = 0; r < e.length; r += n) await v(e.slice(r, r + n), t), r + n < e.length && await l();
|
|
40
|
+
}, b = (e, t, n) => {
|
|
41
|
+
let i = new r({
|
|
42
|
+
...n,
|
|
43
|
+
initial: e
|
|
44
|
+
});
|
|
45
|
+
return i.target = t, i;
|
|
46
|
+
}, x = (e, t) => {
|
|
47
|
+
let n = !1;
|
|
48
|
+
for (let r of e) {
|
|
49
|
+
let e = r.layer.weightSpring;
|
|
50
|
+
e !== void 0 && (t > 0 && e.tickDt(t), e.settled ? (r.layer.weight = e.value, delete r.layer.weightSpring) : n = !0);
|
|
51
|
+
}
|
|
52
|
+
return n;
|
|
53
|
+
}, S = (e) => e instanceof u && typeof e.value == "number", C = (e, t) => {
|
|
54
|
+
let { carriers: n, incomings: r } = t, i = n.length;
|
|
55
|
+
if (i !== 0) {
|
|
56
|
+
for (let t = 0; t < i; t++) e[t] = n[t].value;
|
|
57
|
+
if (t.weighted) {
|
|
58
|
+
let n = t.layer.weightSpring?.value ?? t.layer.weight;
|
|
59
|
+
for (let t = 0; t < i; t++) e[t] = d(e[t], r[t].value, n);
|
|
60
|
+
} else for (let t = 0; t < i; t++) e[t] = e[t] + r[t].value;
|
|
61
|
+
for (let t = 0; t < i; t++) n[t].value = e[t];
|
|
62
|
+
}
|
|
63
|
+
}, w = (e, t) => {
|
|
64
|
+
let n = [], r = {}, i = 0;
|
|
65
|
+
for (let t of e) {
|
|
66
|
+
let { layer: e, values: a } = t;
|
|
67
|
+
if (!e.enabled) continue;
|
|
68
|
+
let o = e.properties, s = e.blendMode === "weighted";
|
|
69
|
+
if (e.blendMode === "replace") {
|
|
70
|
+
for (let e in a) {
|
|
71
|
+
if (o && !o.has(e)) continue;
|
|
72
|
+
let t = a[e];
|
|
73
|
+
t !== void 0 && (r[e] = t);
|
|
74
|
+
}
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
let c = [], l = [], u = [];
|
|
78
|
+
for (let e in a) {
|
|
79
|
+
if (o && !o.has(e)) continue;
|
|
80
|
+
let t = a[e];
|
|
81
|
+
if (t === void 0) continue;
|
|
82
|
+
let n = r[e];
|
|
83
|
+
if (Array.isArray(n) && Array.isArray(t)) {
|
|
84
|
+
let r = Math.min(n.length, t.length), i = !0;
|
|
85
|
+
for (let e = 0; e < r; e++) if (!S(n[e]) || !S(t[e])) {
|
|
86
|
+
i = !1;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
if (i) for (let e = 0; e < r; e++) c.push(n[e]), l.push(t[e]);
|
|
90
|
+
else u.push(e);
|
|
91
|
+
} else u.push(e), r[e] = t;
|
|
92
|
+
}
|
|
93
|
+
c.length > i && (i = c.length), n.push({
|
|
94
|
+
layer: e,
|
|
95
|
+
weighted: s,
|
|
96
|
+
carriers: c,
|
|
97
|
+
incomings: l,
|
|
98
|
+
boxedKeys: u
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
let a = t;
|
|
102
|
+
return i > 0 && (a === null || a.length < i) && (a = new Float64Array(i)), {
|
|
103
|
+
plans: n,
|
|
104
|
+
compositeBuf: a
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/animation/group/compositor.ts
|
|
109
|
+
function T(e, t) {
|
|
110
|
+
let n = e._grouped;
|
|
111
|
+
e._groupedKeysDirty && (e._groupedKeys = m(e.getEntries()), e._groupedKeysDirty = !1, e._soaPlans = null);
|
|
112
|
+
let r = e._groupedKeys;
|
|
113
|
+
for (let e = 0; e < r.length; e++) n[r[e]] = void 0;
|
|
114
|
+
let i = e.getEntries(), a = e._soaPlans !== null, s = 0, c = !0;
|
|
115
|
+
for (let t of i) {
|
|
116
|
+
let { animation: r, layer: i, values: o } = t;
|
|
117
|
+
if (c &&= r.done, !i.enabled) continue;
|
|
118
|
+
r.interpFrames(r.t, !1, o);
|
|
119
|
+
let l = i.properties;
|
|
120
|
+
if (i.blendMode === "replace") {
|
|
121
|
+
for (let e in o) {
|
|
122
|
+
if (l && !l.has(e)) continue;
|
|
123
|
+
let t = o[e];
|
|
124
|
+
t !== void 0 && (n[e] = t);
|
|
125
|
+
}
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (a) {
|
|
129
|
+
let t = e._soaPlans[s++];
|
|
130
|
+
C(e._compositeBuf, t), t.boxedKeys.length > 0 && E(i, o, n, l, t.boxedKeys);
|
|
131
|
+
} else E(i, o, n, l);
|
|
132
|
+
}
|
|
133
|
+
if (!a) {
|
|
134
|
+
let { plans: t, compositeBuf: n } = w(i, e._compositeBuf);
|
|
135
|
+
e._soaPlans = t, e._compositeBuf = n;
|
|
136
|
+
}
|
|
137
|
+
e.done = c;
|
|
138
|
+
for (let e = 0; e < r.length; e++) {
|
|
139
|
+
let t = r[e];
|
|
140
|
+
n[t] === void 0 && delete n[t];
|
|
141
|
+
}
|
|
142
|
+
if (e.transform === o) for (let t of e.getEntries()) {
|
|
143
|
+
let n = t.animation.frames[0];
|
|
144
|
+
if (n != null && n.transform != null) {
|
|
145
|
+
e.transform = n.transform;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return e.transform(n, t), n;
|
|
150
|
+
}
|
|
151
|
+
function E(e, t, n, r, i) {
|
|
152
|
+
let a = i ? new Set(i) : void 0;
|
|
153
|
+
if (e.blendMode === "add") {
|
|
154
|
+
for (let e in t) {
|
|
155
|
+
if (a && !a.has(e) || r && !r.has(e)) continue;
|
|
156
|
+
let i = t[e];
|
|
157
|
+
if (i === void 0) continue;
|
|
158
|
+
let o = n[e];
|
|
159
|
+
if (Array.isArray(o) && Array.isArray(i)) {
|
|
160
|
+
let e = Math.min(o.length, i.length);
|
|
161
|
+
for (let t = 0; t < e; t++) S(o[t]) && S(i[t]) ? o[t].value += i[t].value : o[t] = i[t];
|
|
162
|
+
} else n[e] = i;
|
|
163
|
+
}
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
let o = e.weightSpring?.value ?? e.weight;
|
|
167
|
+
for (let e in t) {
|
|
168
|
+
if (a && !a.has(e) || r && !r.has(e)) continue;
|
|
169
|
+
let i = t[e];
|
|
170
|
+
if (i === void 0) continue;
|
|
171
|
+
let s = n[e];
|
|
172
|
+
if (Array.isArray(s) && Array.isArray(i)) {
|
|
173
|
+
let e = Math.min(s.length, i.length);
|
|
174
|
+
for (let t = 0; t < e; t++) S(s[t]) && S(i[t]) ? s[t].value = d(s[t].value, i[t].value, o) : s[t] = i[t];
|
|
175
|
+
} else n[e] = i;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/animation/group/layer-api.ts
|
|
180
|
+
function D(e, t, n) {
|
|
181
|
+
let r = p(e.animations, t, "setLayerConfig");
|
|
182
|
+
Object.assign(r.layer, n), e.invalidateEntries();
|
|
183
|
+
}
|
|
184
|
+
function O(e, t) {
|
|
185
|
+
return e.animations[f(t)]?.layer;
|
|
186
|
+
}
|
|
187
|
+
function k(e, t, n) {
|
|
188
|
+
let i = p(e.animations, t, "transitionLayer").layer;
|
|
189
|
+
i.blendMode = "weighted";
|
|
190
|
+
let a = i.weightSpring;
|
|
191
|
+
a instanceof r ? a.target = n.weight : i.weightSpring = b(i.weight, n.weight, n.spring), e._hasLayerSprings = !0, e.invalidateEntries();
|
|
192
|
+
}
|
|
193
|
+
function A(e, t, n, r) {
|
|
194
|
+
let i = r?.spring;
|
|
195
|
+
k(e, t, {
|
|
196
|
+
weight: 0,
|
|
197
|
+
...i ? { spring: i } : {}
|
|
198
|
+
}), k(e, n, {
|
|
199
|
+
weight: 1,
|
|
200
|
+
...i ? { spring: i } : {}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/animation/group/group.ts
|
|
205
|
+
var j = class e {
|
|
206
|
+
animations = {};
|
|
207
|
+
transform = o;
|
|
208
|
+
superKey;
|
|
209
|
+
paused = !1;
|
|
210
|
+
started = !1;
|
|
211
|
+
done = !1;
|
|
212
|
+
respectReducedMotion = !1;
|
|
213
|
+
static YIELD_BATCH = 32;
|
|
214
|
+
singleTarget = !0;
|
|
215
|
+
lastTickTime = 0;
|
|
216
|
+
playback = new n();
|
|
217
|
+
resolvePromise = null;
|
|
218
|
+
_playingPromise = null;
|
|
219
|
+
_boundFrame;
|
|
220
|
+
_entries = [];
|
|
221
|
+
_entriesDirty = !0;
|
|
222
|
+
_grouped = {};
|
|
223
|
+
_groupedKeys = [];
|
|
224
|
+
_groupedKeysDirty = !0;
|
|
225
|
+
_soaPlans = null;
|
|
226
|
+
_compositeBuf = null;
|
|
227
|
+
_hasLayerSprings = !1;
|
|
228
|
+
constructor(...e) {
|
|
229
|
+
this._boundFrame = this._frame.bind(this);
|
|
230
|
+
let t = [];
|
|
231
|
+
for (let n of e) {
|
|
232
|
+
let e, r;
|
|
233
|
+
n instanceof c ? e = n : (e = n.animation, r = n.layer), this.transform === o && e.frames[0] != null && (this.transform = e.frames[0].transform);
|
|
234
|
+
let i = s(e);
|
|
235
|
+
this.animations[i] = {
|
|
236
|
+
values: {},
|
|
237
|
+
animation: e,
|
|
238
|
+
layer: {
|
|
239
|
+
...a,
|
|
240
|
+
...r
|
|
241
|
+
}
|
|
242
|
+
}, e.managed = !0, t.push(e);
|
|
243
|
+
}
|
|
244
|
+
this.singleTarget = t.every((e) => e.targets[0] === t[0]?.targets[0]), this.invalidateEntries();
|
|
245
|
+
}
|
|
246
|
+
getEntries() {
|
|
247
|
+
return this._entriesDirty &&= (this._entries = Object.values(this.animations), this._entries.sort((e, t) => e.layer.zIndex - t.layer.zIndex), !1), this._entries;
|
|
248
|
+
}
|
|
249
|
+
invalidateEntries() {
|
|
250
|
+
this._entriesDirty = !0, this._groupedKeysDirty = !0;
|
|
251
|
+
}
|
|
252
|
+
setSuperKey(e) {
|
|
253
|
+
this.superKey = e;
|
|
254
|
+
for (let t of this.getEntries()) t.animation.superKey = e;
|
|
255
|
+
return this;
|
|
256
|
+
}
|
|
257
|
+
setTargets(...e) {
|
|
258
|
+
let t = this.getEntries();
|
|
259
|
+
for (let n of t) n.animation.setTargets(...e);
|
|
260
|
+
return this.singleTarget = t.every((e) => e.animation.targets[0] === t[0]?.animation.targets[0]), this;
|
|
261
|
+
}
|
|
262
|
+
transformFramesGrouped(e) {
|
|
263
|
+
return T(this, e);
|
|
264
|
+
}
|
|
265
|
+
render(e = this.lastTickTime) {
|
|
266
|
+
this.singleTarget ? this.transformFramesGrouped(e) : h(this.getEntries());
|
|
267
|
+
}
|
|
268
|
+
setChildTime(e, t) {
|
|
269
|
+
let n = p(this.animations, e, "setChildTime").animation;
|
|
270
|
+
return n.t = t, n.startTime !== void 0 && (n.pausedTime = n.startTime + t), this;
|
|
271
|
+
}
|
|
272
|
+
advanceTo(t) {
|
|
273
|
+
let n = this.lastTickTime === 0 ? 0 : t - this.lastTickTime;
|
|
274
|
+
this._hasLayerSprings && this.advanceLayerSprings(n), this.lastTickTime = t, this.started = !0;
|
|
275
|
+
let r = this.getEntries(), i = e.YIELD_BATCH, a = r.length <= i ? v(r, t) : y(r, t, i);
|
|
276
|
+
return a ? a.then(() => this) : this;
|
|
277
|
+
}
|
|
278
|
+
_frame(e) {
|
|
279
|
+
let t = this.advanceTo(e);
|
|
280
|
+
return typeof t.then == "function" ? t.then(() => this._renderFrame(e)) : this._renderFrame(e);
|
|
281
|
+
}
|
|
282
|
+
_renderFrame(e) {
|
|
283
|
+
return this.paused ? !1 : (this.singleTarget ? this.transformFramesGrouped(e) : this.done = h(this.getEntries()), this.done ? (this.settle(), this._resolvePlay(), !1) : !0);
|
|
284
|
+
}
|
|
285
|
+
_resolvePlay() {
|
|
286
|
+
let e = this.resolvePromise;
|
|
287
|
+
this.resolvePromise = null, e?.();
|
|
288
|
+
}
|
|
289
|
+
get finished() {
|
|
290
|
+
return this._playingPromise ?? Promise.resolve();
|
|
291
|
+
}
|
|
292
|
+
async play() {
|
|
293
|
+
if (this._playingPromise) return this._playingPromise;
|
|
294
|
+
let e = t(this.respectReducedMotion, () => this._playReducedMotion(), () => new Promise((e) => {
|
|
295
|
+
this.resolvePromise = e, this.playback.loop(this._boundFrame);
|
|
296
|
+
}));
|
|
297
|
+
return this._playingPromise = e, e.finally(() => {
|
|
298
|
+
this._playingPromise = null;
|
|
299
|
+
}), e;
|
|
300
|
+
}
|
|
301
|
+
_playReducedMotion() {
|
|
302
|
+
this.started = !0;
|
|
303
|
+
let e = this.lastTickTime;
|
|
304
|
+
return g(this.getEntries()), this.singleTarget && this.transformFramesGrouped(e), this.settle(), Promise.resolve();
|
|
305
|
+
}
|
|
306
|
+
pause() {
|
|
307
|
+
if (!this.started || this.paused) return this;
|
|
308
|
+
this.paused = !0;
|
|
309
|
+
let e = this.lastTickTime;
|
|
310
|
+
for (let t of this.getEntries()) {
|
|
311
|
+
let n = t.animation;
|
|
312
|
+
n.pause(), n.pausedTime === 0 && (n.pausedTime = e);
|
|
313
|
+
}
|
|
314
|
+
return this.playback.stop(), this.render(), this;
|
|
315
|
+
}
|
|
316
|
+
resume() {
|
|
317
|
+
return !this.started || !this.paused ? this : (this.paused = !1, _(this.getEntries(), !1), this.playback.loop(this._boundFrame), this);
|
|
318
|
+
}
|
|
319
|
+
toggle() {
|
|
320
|
+
return this.paused ? this.resume() : this.pause();
|
|
321
|
+
}
|
|
322
|
+
settle() {
|
|
323
|
+
for (let e of this.getEntries()) e.animation.managed = !1, e.animation.settle();
|
|
324
|
+
return this.started = !1, this.done = !1, this.paused = !1, this.lastTickTime = 0, this;
|
|
325
|
+
}
|
|
326
|
+
reset() {
|
|
327
|
+
for (let e of this.getEntries()) {
|
|
328
|
+
let t = e.animation;
|
|
329
|
+
t.started && t.frames.length > 0 && t.interpFrames(0, !0);
|
|
330
|
+
}
|
|
331
|
+
return this.settle();
|
|
332
|
+
}
|
|
333
|
+
stop() {
|
|
334
|
+
return this.playback.stop(), this.reset(), this._resolvePlay(), this;
|
|
335
|
+
}
|
|
336
|
+
playing() {
|
|
337
|
+
return !(!this.started || this.paused);
|
|
338
|
+
}
|
|
339
|
+
setLayerConfig(e, t) {
|
|
340
|
+
return D(this, e, t), this;
|
|
341
|
+
}
|
|
342
|
+
setLayerEnabled(e, t) {
|
|
343
|
+
return this.setLayerConfig(e, { enabled: t });
|
|
344
|
+
}
|
|
345
|
+
getLayerConfig(e) {
|
|
346
|
+
return O(this, e);
|
|
347
|
+
}
|
|
348
|
+
transitionLayer(e, t) {
|
|
349
|
+
return k(this, e, t), this;
|
|
350
|
+
}
|
|
351
|
+
crossfade(e, t, n) {
|
|
352
|
+
return A(this, e, t, n), this;
|
|
353
|
+
}
|
|
354
|
+
advanceLayerSprings(e) {
|
|
355
|
+
this._hasLayerSprings = x(this.getEntries(), e);
|
|
356
|
+
}
|
|
357
|
+
}, M = /* @__PURE__ */ e({ AnimationGroup: () => j });
|
|
358
|
+
i((e, ...t) => new j(e, ...t));
|
|
359
|
+
//#endregion
|
|
360
|
+
export { j as n, M as t };
|