@mkbabb/keyframes.js 4.2.0 → 4.4.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 +151 -1
- package/dist/animate-CuUJt2Tb.js +26 -0
- package/dist/{animations-WlZvjmDT.js → animations-5nf2kBkv.js} +3 -3
- package/dist/compile-DgNRG6Lo.js +251 -0
- package/dist/decay-BvNmFk51.js +25 -0
- package/dist/{draw-svg-Dm9f0vTl.js → draw-svg-DYRDxBlL.js} +1 -1
- package/dist/engine-CNHvTgpw.js +1122 -0
- package/dist/errors-W8zkvPw4.js +21 -0
- package/dist/format-BUgCTjmr.js +123 -0
- package/dist/ingest-CNM5xkQT.js +160 -0
- package/dist/keyframes.d.ts +2417 -666
- package/dist/keyframes.js +226 -244
- package/dist/morph-svg-DRjl9Hfz.js +62 -0
- package/dist/{motion-path-DQ73oD2j.js → motion-path-J-RSNmRQ.js} +1 -1
- package/dist/rolldown-runtime-Dy4uBu1J.js +11 -0
- package/dist/scheduler-7eIr_q1g.js +14 -0
- package/dist/scroll-grammar-B4kPvGh5.js +23 -0
- package/dist/scroll-scene-CXEgM49Q.js +176 -0
- package/dist/sequence-CF5hazqz.js +198 -0
- package/dist/springTimingFunction-CDHZ00JQ.js +63 -0
- package/dist/timeline-B7SV3T_E.js +442 -0
- package/dist/utils-D7nuAND5.js +97 -0
- package/dist/validate-8r6Yo-uc.js +35 -0
- package/dist/waapi-D9MHMm_9.js +179 -0
- package/package.json +49 -8
- package/dist/animate-WjeAtXAe.js +0 -21
- package/dist/engine-Gk4Q7ltr.js +0 -1083
- package/dist/springTimingFunction-DMb11kBe.js +0 -178
- package/dist/timeline-CPT7qUV1.js +0 -282
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { c as e, o as t, s as n } from "./timeline-CPT7qUV1.js";
|
|
2
|
-
//#region src/animation/spring.ts
|
|
3
|
-
function r(t) {
|
|
4
|
-
let { visualDuration: n, duration: r, bounce: a = 0, ...o } = t, s = n ?? r ?? i.response, c = 1 - e(a, -1, 1);
|
|
5
|
-
return {
|
|
6
|
-
...o,
|
|
7
|
-
response: s,
|
|
8
|
-
dampingFraction: c
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
var i = {
|
|
12
|
-
response: .5,
|
|
13
|
-
dampingFraction: .86,
|
|
14
|
-
initial: 0,
|
|
15
|
-
initialVelocity: 0,
|
|
16
|
-
settleThreshold: .001,
|
|
17
|
-
velocitySettleThreshold: .001,
|
|
18
|
-
respectReducedMotion: !1
|
|
19
|
-
}, a = class e {
|
|
20
|
-
options;
|
|
21
|
-
targetValue;
|
|
22
|
-
currentValue;
|
|
23
|
-
currentVelocity;
|
|
24
|
-
isSettled;
|
|
25
|
-
elapsed;
|
|
26
|
-
originValue;
|
|
27
|
-
originVelocity;
|
|
28
|
-
omega;
|
|
29
|
-
zeta;
|
|
30
|
-
omegaD;
|
|
31
|
-
subscribers = /* @__PURE__ */ new Set();
|
|
32
|
-
disposed = !1;
|
|
33
|
-
_playback = new t();
|
|
34
|
-
_onFrame = void 0;
|
|
35
|
-
constructor(e) {
|
|
36
|
-
this.options = {
|
|
37
|
-
...i,
|
|
38
|
-
...e
|
|
39
|
-
}, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.currentVelocity = this.options.initialVelocity, this.isSettled = this.options.initialVelocity === 0, this.elapsed = 0, this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.omega = 2 * Math.PI / this.options.response, this.zeta = this.options.dampingFraction, this.omegaD = this.zeta < 1 ? this.omega * Math.sqrt(1 - this.zeta * this.zeta) : 0;
|
|
40
|
-
}
|
|
41
|
-
static fromDuration(t) {
|
|
42
|
-
return new e(r(t ?? {}));
|
|
43
|
-
}
|
|
44
|
-
get target() {
|
|
45
|
-
return this.targetValue;
|
|
46
|
-
}
|
|
47
|
-
get value() {
|
|
48
|
-
return this.currentValue;
|
|
49
|
-
}
|
|
50
|
-
get velocity() {
|
|
51
|
-
return this.currentVelocity;
|
|
52
|
-
}
|
|
53
|
-
get settled() {
|
|
54
|
-
return this.isSettled;
|
|
55
|
-
}
|
|
56
|
-
set target(e) {
|
|
57
|
-
e === this.targetValue && !this.options.initialVelocity || this.reseatTarget(e);
|
|
58
|
-
}
|
|
59
|
-
reseatTarget(e) {
|
|
60
|
-
this.targetValue = e, n(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
61
|
-
this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.elapsed = 0, this.isSettled = !1, this._onFrame && this._startLoop();
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
_snapSettled() {
|
|
65
|
-
this.currentValue = this.targetValue, this.currentVelocity = 0, this.originValue = this.targetValue, this.originVelocity = 0, this.elapsed = 0, this.isSettled = !0, this.emit(), this._playback.stop();
|
|
66
|
-
}
|
|
67
|
-
tickDt(e) {
|
|
68
|
-
return this._stepSeconds(e / 1e3);
|
|
69
|
-
}
|
|
70
|
-
_stepSeconds(e) {
|
|
71
|
-
return this.disposed || this.isSettled || e <= 0 ? this.currentValue : (this.elapsed += e, this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
|
|
72
|
-
}
|
|
73
|
-
tickToTime(e) {
|
|
74
|
-
return this.disposed || this.isSettled ? this.currentValue : (this.elapsed = Math.max(0, e), this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
|
|
75
|
-
}
|
|
76
|
-
evaluateAt(e) {
|
|
77
|
-
let t = this.originValue - this.targetValue, n = this.originVelocity, r = this.omega, i = this.zeta, a, o;
|
|
78
|
-
if (i < 1) {
|
|
79
|
-
let s = this.omegaD, c = Math.exp(-i * r * e), l = t, u = (n + i * r * t) / s, d = Math.cos(s * e), f = Math.sin(s * e);
|
|
80
|
-
a = c * (l * d + u * f), o = c * ((u * s - l * i * r) * d - (l * s + u * i * r) * f);
|
|
81
|
-
} else if (i === 1) {
|
|
82
|
-
let i = Math.exp(-r * e), s = t, c = n + r * t;
|
|
83
|
-
a = i * (s + c * e), o = i * (c - r * (s + c * e));
|
|
84
|
-
} else {
|
|
85
|
-
let s = r * Math.sqrt(i * i - 1), c = -i * r + s, l = -i * r - s, u = (n - l * t) / (c - l), d = t - u, f = Math.exp(c * e), p = Math.exp(l * e);
|
|
86
|
-
a = u * f + d * p, o = u * c * f + d * l * p;
|
|
87
|
-
}
|
|
88
|
-
this.currentValue = this.targetValue + a, this.currentVelocity = o;
|
|
89
|
-
}
|
|
90
|
-
checkSettled() {
|
|
91
|
-
let e = Math.abs(this.currentValue - this.targetValue), t = Math.abs(this.currentVelocity);
|
|
92
|
-
e < this.options.settleThreshold && t < this.options.velocitySettleThreshold && (this.currentValue = this.targetValue, this.currentVelocity = 0, this.isSettled = !0);
|
|
93
|
-
}
|
|
94
|
-
snap() {
|
|
95
|
-
this._snapSettled();
|
|
96
|
-
}
|
|
97
|
-
reset(e, t) {
|
|
98
|
-
let n = e ?? 0, r = t ?? 0;
|
|
99
|
-
this.targetValue = n, this.currentValue = n, this.currentVelocity = r, this.originValue = n, this.originVelocity = r, this.elapsed = 0, this.isSettled = r === 0, this.emit(), this._playback.stop();
|
|
100
|
-
}
|
|
101
|
-
subscribe(e) {
|
|
102
|
-
return this.subscribers.add(e), () => {
|
|
103
|
-
this.subscribers.delete(e);
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
emit() {
|
|
107
|
-
if (this.subscribers.size !== 0) for (let e of this.subscribers) e(this.currentValue, this.currentVelocity);
|
|
108
|
-
}
|
|
109
|
-
dispose() {
|
|
110
|
-
this.disposed = !0, this._playback.stop(), this.subscribers.clear();
|
|
111
|
-
}
|
|
112
|
-
play(e) {
|
|
113
|
-
this.disposed || (this._onFrame = e, n(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
114
|
-
if (this.isSettled) {
|
|
115
|
-
e?.(this.currentValue, this.currentVelocity);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
this._startLoop();
|
|
119
|
-
}));
|
|
120
|
-
}
|
|
121
|
-
stop() {
|
|
122
|
-
this._onFrame = void 0, this._playback.stop();
|
|
123
|
-
}
|
|
124
|
-
_startLoop() {
|
|
125
|
-
this._playback.drive(this, () => this._onFrame?.(this.currentValue, this.currentVelocity));
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region src/animation/springLinearStops.ts
|
|
130
|
-
function o(e) {
|
|
131
|
-
let t = e.sampleCount ?? 24, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = new a({
|
|
132
|
-
response: e.response,
|
|
133
|
-
dampingFraction: e.dampingFraction,
|
|
134
|
-
initial: 0,
|
|
135
|
-
settleThreshold: n,
|
|
136
|
-
velocitySettleThreshold: n
|
|
137
|
-
});
|
|
138
|
-
i.target = 1;
|
|
139
|
-
let o = ["0"], s = r / (t + 1);
|
|
140
|
-
for (let e = 1; e <= t; e++) {
|
|
141
|
-
i._stepSeconds(s);
|
|
142
|
-
let n = e / (t + 1) * 100, r = i.settled ? 1 : i.value;
|
|
143
|
-
o.push(`${r.toFixed(5)} ${n.toFixed(3)}%`);
|
|
144
|
-
}
|
|
145
|
-
return o.push("1"), i.dispose(), `linear(${o.join(", ")})`;
|
|
146
|
-
}
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region src/animation/springTimingFunction.ts
|
|
149
|
-
function s(e) {
|
|
150
|
-
let t = e.sampleCount ?? 64, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = new a({
|
|
151
|
-
response: e.response,
|
|
152
|
-
dampingFraction: e.dampingFraction,
|
|
153
|
-
initial: 0,
|
|
154
|
-
settleThreshold: n,
|
|
155
|
-
velocitySettleThreshold: n
|
|
156
|
-
});
|
|
157
|
-
i.target = 1;
|
|
158
|
-
let s = new Float64Array(t + 1);
|
|
159
|
-
s[0] = 0;
|
|
160
|
-
let c = r / t;
|
|
161
|
-
for (let e = 1; e <= t; e++) i._stepSeconds(c), s[e] = i.settled ? 1 : i.value;
|
|
162
|
-
s[t] = 1, i.dispose();
|
|
163
|
-
let l = (e) => {
|
|
164
|
-
if (e <= 0) return 0;
|
|
165
|
-
if (e >= 1) return 1;
|
|
166
|
-
let n = e * t, r = Math.floor(n), i = n - r, a = s[r];
|
|
167
|
-
return a + (s[r + 1] - a) * i;
|
|
168
|
-
}, u = {
|
|
169
|
-
response: e.response,
|
|
170
|
-
dampingFraction: e.dampingFraction
|
|
171
|
-
};
|
|
172
|
-
return e.settleThreshold !== void 0 && (u.settleThreshold = e.settleThreshold), e.maxDuration !== void 0 && (u.maxDuration = e.maxDuration), {
|
|
173
|
-
fn: l,
|
|
174
|
-
css: o(u)
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
//#endregion
|
|
178
|
-
export { o as n, a as r, s as t };
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
//#region src/animation/internal/errors.ts
|
|
2
|
-
var e = (e) => typeof e == "string" ? JSON.stringify(e) : typeof e == "function" ? `[function ${e.name || "anonymous"}]` : String(e), t = class extends Error {
|
|
3
|
-
option;
|
|
4
|
-
value;
|
|
5
|
-
code;
|
|
6
|
-
constructor(t, n, r, i) {
|
|
7
|
-
super(`Invalid value for animation option "${t}": ${e(n)} — ${r}`), this.name = "AnimationOptionError", this.option = t, this.value = n, i !== void 0 && (this.code = i);
|
|
8
|
-
}
|
|
9
|
-
}, n = class extends Error {
|
|
10
|
-
easingName;
|
|
11
|
-
constructor(t) {
|
|
12
|
-
super(`Unknown easing name ${e(t)} — not a value.js registry entry or cubic-bezier() literal. Pass a callable TimingFunction (or a typed Easing), or resolve the name first via \`await resolveEasing(name)\`.`), this.name = "UnknownEasingError", this.easingName = t;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
function r(e, n, r, i) {
|
|
16
|
-
let a = r(n);
|
|
17
|
-
if (a === void 0) throw new t(e, n, i);
|
|
18
|
-
return a;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/animation/easing.ts
|
|
22
|
-
var i = (e) => typeof e == "function" ? { fn: e } : e, a = /^(linear|ease|ease-in|ease-out|ease-in-out)$/, o = /^(cubic-bezier\(|steps\(|linear\(|step-start$|step-end$)/, s = (e) => {
|
|
23
|
-
let t = e.trim();
|
|
24
|
-
if (a.test(t) || o.test(t)) return t;
|
|
25
|
-
};
|
|
26
|
-
async function c(e) {
|
|
27
|
-
let t;
|
|
28
|
-
try {
|
|
29
|
-
t = await import("./engine-Gk4Q7ltr.js");
|
|
30
|
-
} catch (t) {
|
|
31
|
-
throw Error(`keyframes: the engine chunk failed to load while resolving easing "${e}" — the easing registry is unreachable.`, { cause: t });
|
|
32
|
-
}
|
|
33
|
-
let r = t.getTimingFunction(e);
|
|
34
|
-
if (!r) throw new n(e);
|
|
35
|
-
let i = { fn: r }, a = s(e);
|
|
36
|
-
return a && (i.css = a), i;
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/animation/internal/binarySearch.ts
|
|
40
|
-
function l(e, t, n, r) {
|
|
41
|
-
let i = 0, a = e.length - 1;
|
|
42
|
-
for (; i <= a;) {
|
|
43
|
-
let o = i + a >> 1, s = e[o];
|
|
44
|
-
if (t < n(s)) a = o - 1;
|
|
45
|
-
else if (t > r(s)) i = o + 1;
|
|
46
|
-
else return o;
|
|
47
|
-
}
|
|
48
|
-
return -1;
|
|
49
|
-
}
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/animation/internal/leaves.ts
|
|
52
|
-
var u = 1e3 / 60;
|
|
53
|
-
function d(e, t, n) {
|
|
54
|
-
return Math.min(Math.max(e, t), n);
|
|
55
|
-
}
|
|
56
|
-
function f(e, t, n, r = 0, i = 1) {
|
|
57
|
-
if (n === t) throw Error("fromMax and fromMin cannot be equal");
|
|
58
|
-
let a = (i - r) / (n - t);
|
|
59
|
-
return (e - t) * a + r;
|
|
60
|
-
}
|
|
61
|
-
function p(e, t, n) {
|
|
62
|
-
return (1 - n) * e + n * t;
|
|
63
|
-
}
|
|
64
|
-
function m(e) {
|
|
65
|
-
if (typeof window < "u" && window.requestAnimationFrame) return window.requestAnimationFrame(e);
|
|
66
|
-
let t = u, n = Date.now();
|
|
67
|
-
return setTimeout(() => {
|
|
68
|
-
let r = Date.now(), i = r - n;
|
|
69
|
-
n = r, t = Math.max(0, u - i), e(r);
|
|
70
|
-
}, t);
|
|
71
|
-
}
|
|
72
|
-
function h(e) {
|
|
73
|
-
if (e != null) {
|
|
74
|
-
if (typeof e == "number" && typeof window < "u" && window.cancelAnimationFrame) return window.cancelAnimationFrame(e);
|
|
75
|
-
clearTimeout(e);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region src/animation/internal/reduced-motion.ts
|
|
80
|
-
var g = "(prefers-reduced-motion: reduce)", _ = null, v;
|
|
81
|
-
function y() {
|
|
82
|
-
let e = typeof window > "u" ? void 0 : window.matchMedia;
|
|
83
|
-
return typeof e == "function" ? _ !== null && v === e ? _ : (v = e, _ = e.call(window, g), _) : (_ = null, v = e, null);
|
|
84
|
-
}
|
|
85
|
-
function b() {
|
|
86
|
-
return y()?.matches ?? !1;
|
|
87
|
-
}
|
|
88
|
-
function x(e, t, n) {
|
|
89
|
-
return e && b() ? t() : n();
|
|
90
|
-
}
|
|
91
|
-
//#endregion
|
|
92
|
-
//#region src/animation/playback.ts
|
|
93
|
-
var S = class {
|
|
94
|
-
_rafId = null;
|
|
95
|
-
_startTime = void 0;
|
|
96
|
-
_lastFrameT = 0;
|
|
97
|
-
_resolve = null;
|
|
98
|
-
_gen = 0;
|
|
99
|
-
get running() {
|
|
100
|
-
return this._rafId !== null;
|
|
101
|
-
}
|
|
102
|
-
_run(e) {
|
|
103
|
-
let t = ++this._gen, n = (e) => {
|
|
104
|
-
t === this._gen && (e ? this._rafId = m(r) : this._cleanup());
|
|
105
|
-
}, r = (t) => {
|
|
106
|
-
let r = e(t);
|
|
107
|
-
r && typeof r.then == "function" ? r.then(n) : n(r);
|
|
108
|
-
};
|
|
109
|
-
this._rafId = m(r);
|
|
110
|
-
}
|
|
111
|
-
play = (e, t, n) => {
|
|
112
|
-
if (e <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
|
|
113
|
-
return this.stop(), x(n?.respectReducedMotion, () => (t(1), Promise.resolve()), () => new Promise((n) => {
|
|
114
|
-
this._resolve = n, this._startTime = void 0, this._run((n) => {
|
|
115
|
-
this._startTime === void 0 && (this._startTime = n);
|
|
116
|
-
let r = d((n - this._startTime) / e, 0, 1);
|
|
117
|
-
return t(r), r < 1;
|
|
118
|
-
});
|
|
119
|
-
}));
|
|
120
|
-
};
|
|
121
|
-
drive = (e, t) => {
|
|
122
|
-
this._rafId === null && (this._lastFrameT = 0, this._run((n) => {
|
|
123
|
-
let r = this._lastFrameT ? n - this._lastFrameT : 16.667;
|
|
124
|
-
return this._lastFrameT = n, e.tickDt(r), t?.(), !e.settled;
|
|
125
|
-
}));
|
|
126
|
-
};
|
|
127
|
-
loop = (e) => {
|
|
128
|
-
this.stop(), this._run(e);
|
|
129
|
-
};
|
|
130
|
-
stop = () => {
|
|
131
|
-
this._gen++, this._rafId !== null && h(this._rafId), this._cleanup();
|
|
132
|
-
};
|
|
133
|
-
_cleanup() {
|
|
134
|
-
this._rafId = null, this._startTime = void 0, this._lastFrameT = 0;
|
|
135
|
-
let e = this._resolve;
|
|
136
|
-
this._resolve = null, e?.();
|
|
137
|
-
}
|
|
138
|
-
}, C = {
|
|
139
|
-
damping: .1,
|
|
140
|
-
snapThreshold: .001,
|
|
141
|
-
targetEpsilon: 0,
|
|
142
|
-
initial: 0,
|
|
143
|
-
clamp: !0,
|
|
144
|
-
respectReducedMotion: !1
|
|
145
|
-
}, w = class {
|
|
146
|
-
options;
|
|
147
|
-
targetValue;
|
|
148
|
-
currentValue;
|
|
149
|
-
isSettled;
|
|
150
|
-
_playback = new S();
|
|
151
|
-
_onFrame = void 0;
|
|
152
|
-
constructor(e) {
|
|
153
|
-
this.options = {
|
|
154
|
-
...C,
|
|
155
|
-
...e
|
|
156
|
-
}, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.isSettled = !0;
|
|
157
|
-
}
|
|
158
|
-
get target() {
|
|
159
|
-
return this.targetValue;
|
|
160
|
-
}
|
|
161
|
-
get current() {
|
|
162
|
-
return this.currentValue;
|
|
163
|
-
}
|
|
164
|
-
get settled() {
|
|
165
|
-
return this.isSettled;
|
|
166
|
-
}
|
|
167
|
-
setTarget(e) {
|
|
168
|
-
this.options.clamp && (e = d(e, 0, 1));
|
|
169
|
-
let t = Math.abs(e - this.targetValue);
|
|
170
|
-
t > 0 && t >= this.options.targetEpsilon && (this.targetValue = e, x(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
171
|
-
this.isSettled = !1, this._onFrame && this._startLoop();
|
|
172
|
-
}));
|
|
173
|
-
}
|
|
174
|
-
_snapSettled() {
|
|
175
|
-
this.currentValue = this.targetValue, this.isSettled = !0, this._onFrame?.(this.currentValue), this._playback.stop();
|
|
176
|
-
}
|
|
177
|
-
tickDt(e) {
|
|
178
|
-
if (this.isSettled) return this.currentValue;
|
|
179
|
-
let t = 1 - Math.exp(-this.options.damping * e / 16.667);
|
|
180
|
-
return this.currentValue += (this.targetValue - this.currentValue) * t, Math.abs(this.targetValue - this.currentValue) < this.options.snapThreshold && (this.currentValue = this.targetValue, this.isSettled = !0), this.options.clamp && (this.currentValue = d(this.currentValue, 0, 1)), this.currentValue;
|
|
181
|
-
}
|
|
182
|
-
snap() {
|
|
183
|
-
this.currentValue = this.targetValue, this.isSettled = !0, this._playback.stop();
|
|
184
|
-
}
|
|
185
|
-
reset(e) {
|
|
186
|
-
let t = e ?? 0;
|
|
187
|
-
this.targetValue = t, this.currentValue = t, this.isSettled = !0, this._playback.stop();
|
|
188
|
-
}
|
|
189
|
-
play(e) {
|
|
190
|
-
this._onFrame = e, x(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
191
|
-
if (this.isSettled) {
|
|
192
|
-
e?.(this.currentValue);
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
this._startLoop();
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
stop() {
|
|
199
|
-
this._onFrame = void 0, this._playback.stop();
|
|
200
|
-
}
|
|
201
|
-
_startLoop() {
|
|
202
|
-
this._playback.drive(this, () => this._onFrame?.(this.currentValue));
|
|
203
|
-
}
|
|
204
|
-
}, T = class {
|
|
205
|
-
smoother;
|
|
206
|
-
_easingFn;
|
|
207
|
-
currentProgress = 0;
|
|
208
|
-
boundaryEpsilon;
|
|
209
|
-
constructor(e) {
|
|
210
|
-
this.boundaryEpsilon = e?.boundaryEpsilon ?? .005;
|
|
211
|
-
let n = e?.easing;
|
|
212
|
-
if (typeof n == "string") throw new t("easing", n, "Timeline accepts a callable TimingFunction or a typed Easing; resolve a string name first via `await resolveEasing(name)`.");
|
|
213
|
-
this._easingFn = n == null ? (e) => e : i(n).fn, e?.smoothing === !1 ? this.smoother = null : this.smoother = new w(e?.smoothing);
|
|
214
|
-
}
|
|
215
|
-
applyPipeline() {
|
|
216
|
-
let e = d(this.sample(), 0, 1);
|
|
217
|
-
e = this._easingFn(e);
|
|
218
|
-
let t = this.boundaryEpsilon;
|
|
219
|
-
return e <= t ? e = 0 : e >= 1 - t && (e = 1), e;
|
|
220
|
-
}
|
|
221
|
-
_advance(e) {
|
|
222
|
-
let t = this.applyPipeline();
|
|
223
|
-
return this.smoother ? (this.smoother.setTarget(t), t <= 0 || t >= 1 ? this.smoother.snap() : this.smoother.tickDt(e), this.currentProgress = this.smoother.current) : this.currentProgress = t, this.currentProgress;
|
|
224
|
-
}
|
|
225
|
-
tick() {
|
|
226
|
-
return this._advance(16.667);
|
|
227
|
-
}
|
|
228
|
-
tickDt(e) {
|
|
229
|
-
return this._advance(e);
|
|
230
|
-
}
|
|
231
|
-
get progress() {
|
|
232
|
-
return this.currentProgress;
|
|
233
|
-
}
|
|
234
|
-
get settled() {
|
|
235
|
-
return this.smoother == null || this.smoother.settled;
|
|
236
|
-
}
|
|
237
|
-
snap() {
|
|
238
|
-
this.smoother?.snap(), this.smoother && (this.currentProgress = this.smoother.current);
|
|
239
|
-
}
|
|
240
|
-
reset(e) {
|
|
241
|
-
let t = e ?? 0;
|
|
242
|
-
this.smoother && this.smoother.reset(t), this.currentProgress = t;
|
|
243
|
-
}
|
|
244
|
-
}, E = class extends T {
|
|
245
|
-
threshold;
|
|
246
|
-
getScrollY;
|
|
247
|
-
getViewportHeight;
|
|
248
|
-
constructor(e) {
|
|
249
|
-
super(e), this.threshold = e?.threshold ?? .35, this.getScrollY = e?.getScrollY ?? (() => window.scrollY), this.getViewportHeight = e?.getViewportHeight ?? (() => window.innerHeight);
|
|
250
|
-
}
|
|
251
|
-
sample() {
|
|
252
|
-
let e = this.getViewportHeight() * this.threshold;
|
|
253
|
-
return e <= 0 ? 0 : this.getScrollY() / e;
|
|
254
|
-
}
|
|
255
|
-
}, D = class extends T {
|
|
256
|
-
value = 0;
|
|
257
|
-
constructor(e) {
|
|
258
|
-
super({
|
|
259
|
-
smoothing: !1,
|
|
260
|
-
...e
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
set(e) {
|
|
264
|
-
this.value = e;
|
|
265
|
-
}
|
|
266
|
-
sample() {
|
|
267
|
-
return this.value;
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
function O(e) {
|
|
271
|
-
if (typeof window > "u") return null;
|
|
272
|
-
if (e.kind === "scroll") {
|
|
273
|
-
if (globalThis.ScrollTimeline === void 0) return null;
|
|
274
|
-
let t = {};
|
|
275
|
-
return e.source !== void 0 && (t.source = e.source), e.axis !== void 0 && (t.axis = e.axis), new globalThis.ScrollTimeline(t);
|
|
276
|
-
}
|
|
277
|
-
if (globalThis.ViewTimeline === void 0) return null;
|
|
278
|
-
let t = { subject: e.subject };
|
|
279
|
-
return e.axis !== void 0 && (t.axis = e.axis), e.inset !== void 0 && (t.inset = e.inset), new globalThis.ViewTimeline(t);
|
|
280
|
-
}
|
|
281
|
-
//#endregion
|
|
282
|
-
export { r as _, w as a, d as c, l as d, s as f, n as g, t as h, O as i, p as l, i as m, E as n, S as o, c as p, T as r, x as s, D as t, f as u };
|