@mkbabb/keyframes.js 3.0.0 → 4.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 +8 -3
- package/dist/animate-12YQKwyY.js +21 -0
- package/dist/animations-CcAWdZlW.js +224 -0
- package/dist/draw-svg-DwAa5cbU.js +41 -0
- package/dist/engine-Cj0T6OIH.js +1051 -0
- package/dist/keyframes.d.ts +1793 -184
- package/dist/keyframes.js +347 -391
- package/dist/motion-path-683GcEZK.js +31 -0
- package/dist/springTimingFunction-cMJnhbug.js +178 -0
- package/dist/timeline-BHz0o8dZ.js +281 -0
- package/package.json +146 -106
- package/dist/css-easing-DoPNckiS.js +0 -55
- package/dist/engine-B7JGZTdU.js +0 -742
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CSSKeyframesAnimation as e } from "./engine-Cj0T6OIH.js";
|
|
2
|
+
//#region src/animation/motion-path.ts
|
|
3
|
+
var t = (e) => typeof e == "number" ? `${e}%` : e;
|
|
4
|
+
function n(n, r) {
|
|
5
|
+
let { path: i, from: a = "0%", to: o = "100%", rotate: s, autoPlay: c = !0, ...l } = r;
|
|
6
|
+
if (typeof i != "string" || i.length === 0) throw Error("fromMotionPath(): `path` is required — pass an offset-path value (a path()/ray()/url(#id) string).");
|
|
7
|
+
let u = Array.isArray(n) ? n : [n];
|
|
8
|
+
for (let e of u) e.style.offsetPath = i, s !== void 0 && (e.style.offsetRotate = s);
|
|
9
|
+
let d = {
|
|
10
|
+
"0%": { "offset-distance": t(a) },
|
|
11
|
+
"100%": { "offset-distance": t(o) }
|
|
12
|
+
}, f = new e(l).fromKeyframes(d);
|
|
13
|
+
return f.setTargets(...u), c && f.play(), f;
|
|
14
|
+
}
|
|
15
|
+
var r = class {
|
|
16
|
+
animation;
|
|
17
|
+
constructor(e, t) {
|
|
18
|
+
this.animation = n(e, t);
|
|
19
|
+
}
|
|
20
|
+
play() {
|
|
21
|
+
return this.animation.play();
|
|
22
|
+
}
|
|
23
|
+
pause() {
|
|
24
|
+
return this.animation.pause(), this;
|
|
25
|
+
}
|
|
26
|
+
stop() {
|
|
27
|
+
return this.animation.stop(), this;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { r as MotionPath, n as fromMotionPath };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { c as e, o as t, s as n } from "./timeline-BHz0o8dZ.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 };
|
|
@@ -0,0 +1,281 @@
|
|
|
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
|
+
constructor(t, n, r) {
|
|
6
|
+
super(`Invalid value for animation option "${t}": ${e(n)} — ${r}`), this.name = "AnimationOptionError", this.option = t, this.value = n;
|
|
7
|
+
}
|
|
8
|
+
}, n = class extends Error {
|
|
9
|
+
easingName;
|
|
10
|
+
constructor(t) {
|
|
11
|
+
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;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
function r(e, n, r, i) {
|
|
15
|
+
let a = r(n);
|
|
16
|
+
if (a === void 0) throw new t(e, n, i);
|
|
17
|
+
return a;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/animation/easing.ts
|
|
21
|
+
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) => {
|
|
22
|
+
let t = e.trim();
|
|
23
|
+
if (a.test(t) || o.test(t)) return t;
|
|
24
|
+
};
|
|
25
|
+
async function c(e) {
|
|
26
|
+
let t;
|
|
27
|
+
try {
|
|
28
|
+
t = await import("./engine-Cj0T6OIH.js");
|
|
29
|
+
} catch (t) {
|
|
30
|
+
throw Error(`keyframes: the engine chunk failed to load while resolving easing "${e}" — the easing registry is unreachable.`, { cause: t });
|
|
31
|
+
}
|
|
32
|
+
let r = t.getTimingFunction(e);
|
|
33
|
+
if (!r) throw new n(e);
|
|
34
|
+
let i = { fn: r }, a = s(e);
|
|
35
|
+
return a && (i.css = a), i;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/animation/internal/binarySearch.ts
|
|
39
|
+
function l(e, t, n, r) {
|
|
40
|
+
let i = 0, a = e.length - 1;
|
|
41
|
+
for (; i <= a;) {
|
|
42
|
+
let o = i + a >> 1, s = e[o];
|
|
43
|
+
if (t < n(s)) a = o - 1;
|
|
44
|
+
else if (t > r(s)) i = o + 1;
|
|
45
|
+
else return o;
|
|
46
|
+
}
|
|
47
|
+
return -1;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/animation/internal/leaves.ts
|
|
51
|
+
var u = 1e3 / 60;
|
|
52
|
+
function d(e, t, n) {
|
|
53
|
+
return Math.min(Math.max(e, t), n);
|
|
54
|
+
}
|
|
55
|
+
function f(e, t, n, r = 0, i = 1) {
|
|
56
|
+
if (n === t) throw Error("fromMax and fromMin cannot be equal");
|
|
57
|
+
let a = (i - r) / (n - t);
|
|
58
|
+
return (e - t) * a + r;
|
|
59
|
+
}
|
|
60
|
+
function p(e, t, n) {
|
|
61
|
+
return (1 - n) * e + n * t;
|
|
62
|
+
}
|
|
63
|
+
function m(e) {
|
|
64
|
+
if (typeof window < "u" && window.requestAnimationFrame) return window.requestAnimationFrame(e);
|
|
65
|
+
let t = u, n = Date.now();
|
|
66
|
+
return setTimeout(() => {
|
|
67
|
+
let r = Date.now(), i = r - n;
|
|
68
|
+
n = r, t = Math.max(0, u - i), e(r);
|
|
69
|
+
}, t);
|
|
70
|
+
}
|
|
71
|
+
function h(e) {
|
|
72
|
+
if (e != null) {
|
|
73
|
+
if (typeof e == "number" && typeof window < "u" && window.cancelAnimationFrame) return window.cancelAnimationFrame(e);
|
|
74
|
+
clearTimeout(e);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/animation/internal/reduced-motion.ts
|
|
79
|
+
var g = "(prefers-reduced-motion: reduce)", _ = null, v;
|
|
80
|
+
function y() {
|
|
81
|
+
let e = typeof window > "u" ? void 0 : window.matchMedia;
|
|
82
|
+
return typeof e == "function" ? _ !== null && v === e ? _ : (v = e, _ = e.call(window, g), _) : (_ = null, v = e, null);
|
|
83
|
+
}
|
|
84
|
+
function b() {
|
|
85
|
+
return y()?.matches ?? !1;
|
|
86
|
+
}
|
|
87
|
+
function x(e, t, n) {
|
|
88
|
+
return e && b() ? t() : n();
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/animation/playback.ts
|
|
92
|
+
var S = class {
|
|
93
|
+
_rafId = null;
|
|
94
|
+
_startTime = void 0;
|
|
95
|
+
_lastFrameT = 0;
|
|
96
|
+
_resolve = null;
|
|
97
|
+
_gen = 0;
|
|
98
|
+
get running() {
|
|
99
|
+
return this._rafId !== null;
|
|
100
|
+
}
|
|
101
|
+
_run(e) {
|
|
102
|
+
let t = ++this._gen, n = (e) => {
|
|
103
|
+
t === this._gen && (e ? this._rafId = m(r) : this._cleanup());
|
|
104
|
+
}, r = (t) => {
|
|
105
|
+
let r = e(t);
|
|
106
|
+
r && typeof r.then == "function" ? r.then(n) : n(r);
|
|
107
|
+
};
|
|
108
|
+
this._rafId = m(r);
|
|
109
|
+
}
|
|
110
|
+
play(e, t, n) {
|
|
111
|
+
if (e <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
|
|
112
|
+
return this.stop(), x(n?.respectReducedMotion, () => (t(1), Promise.resolve()), () => new Promise((n) => {
|
|
113
|
+
this._resolve = n, this._startTime = void 0, this._run((n) => {
|
|
114
|
+
this._startTime === void 0 && (this._startTime = n);
|
|
115
|
+
let r = d((n - this._startTime) / e, 0, 1);
|
|
116
|
+
return t(r), r < 1;
|
|
117
|
+
});
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
drive(e, t) {
|
|
121
|
+
this._rafId === null && (this._lastFrameT = 0, this._run((n) => {
|
|
122
|
+
let r = this._lastFrameT ? n - this._lastFrameT : 16.667;
|
|
123
|
+
return this._lastFrameT = n, e.tickDt(r), t?.(), !e.settled;
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
loop(e) {
|
|
127
|
+
this.stop(), this._run(e);
|
|
128
|
+
}
|
|
129
|
+
stop() {
|
|
130
|
+
this._gen++, this._rafId !== null && h(this._rafId), this._cleanup();
|
|
131
|
+
}
|
|
132
|
+
_cleanup() {
|
|
133
|
+
this._rafId = null, this._startTime = void 0, this._lastFrameT = 0;
|
|
134
|
+
let e = this._resolve;
|
|
135
|
+
this._resolve = null, e?.();
|
|
136
|
+
}
|
|
137
|
+
}, C = {
|
|
138
|
+
damping: .1,
|
|
139
|
+
snapThreshold: .001,
|
|
140
|
+
targetEpsilon: 0,
|
|
141
|
+
initial: 0,
|
|
142
|
+
clamp: !0,
|
|
143
|
+
respectReducedMotion: !1
|
|
144
|
+
}, w = class {
|
|
145
|
+
options;
|
|
146
|
+
targetValue;
|
|
147
|
+
currentValue;
|
|
148
|
+
isSettled;
|
|
149
|
+
_playback = new S();
|
|
150
|
+
_onFrame = void 0;
|
|
151
|
+
constructor(e) {
|
|
152
|
+
this.options = {
|
|
153
|
+
...C,
|
|
154
|
+
...e
|
|
155
|
+
}, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.isSettled = !0;
|
|
156
|
+
}
|
|
157
|
+
get target() {
|
|
158
|
+
return this.targetValue;
|
|
159
|
+
}
|
|
160
|
+
get current() {
|
|
161
|
+
return this.currentValue;
|
|
162
|
+
}
|
|
163
|
+
get settled() {
|
|
164
|
+
return this.isSettled;
|
|
165
|
+
}
|
|
166
|
+
setTarget(e) {
|
|
167
|
+
this.options.clamp && (e = d(e, 0, 1));
|
|
168
|
+
let t = Math.abs(e - this.targetValue);
|
|
169
|
+
t > 0 && t >= this.options.targetEpsilon && (this.targetValue = e, x(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
170
|
+
this.isSettled = !1, this._onFrame && this._startLoop();
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
_snapSettled() {
|
|
174
|
+
this.currentValue = this.targetValue, this.isSettled = !0, this._onFrame?.(this.currentValue), this._playback.stop();
|
|
175
|
+
}
|
|
176
|
+
tickDt(e) {
|
|
177
|
+
if (this.isSettled) return this.currentValue;
|
|
178
|
+
let t = 1 - Math.exp(-this.options.damping * e / 16.667);
|
|
179
|
+
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;
|
|
180
|
+
}
|
|
181
|
+
snap() {
|
|
182
|
+
this.currentValue = this.targetValue, this.isSettled = !0, this._playback.stop();
|
|
183
|
+
}
|
|
184
|
+
reset(e) {
|
|
185
|
+
let t = e ?? 0;
|
|
186
|
+
this.targetValue = t, this.currentValue = t, this.isSettled = !0, this._playback.stop();
|
|
187
|
+
}
|
|
188
|
+
play(e) {
|
|
189
|
+
this._onFrame = e, x(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
190
|
+
if (this.isSettled) {
|
|
191
|
+
e?.(this.currentValue);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
this._startLoop();
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
stop() {
|
|
198
|
+
this._onFrame = void 0, this._playback.stop();
|
|
199
|
+
}
|
|
200
|
+
_startLoop() {
|
|
201
|
+
this._playback.drive(this, () => this._onFrame?.(this.currentValue));
|
|
202
|
+
}
|
|
203
|
+
}, T = class {
|
|
204
|
+
smoother;
|
|
205
|
+
_easingFn;
|
|
206
|
+
currentProgress = 0;
|
|
207
|
+
boundaryEpsilon;
|
|
208
|
+
constructor(e) {
|
|
209
|
+
this.boundaryEpsilon = e?.boundaryEpsilon ?? .005;
|
|
210
|
+
let n = e?.easing;
|
|
211
|
+
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)`.");
|
|
212
|
+
this._easingFn = n == null ? (e) => e : i(n).fn, e?.smoothing === !1 ? this.smoother = null : this.smoother = new w(e?.smoothing);
|
|
213
|
+
}
|
|
214
|
+
applyPipeline() {
|
|
215
|
+
let e = d(this.sample(), 0, 1);
|
|
216
|
+
e = this._easingFn(e);
|
|
217
|
+
let t = this.boundaryEpsilon;
|
|
218
|
+
return e <= t ? e = 0 : e >= 1 - t && (e = 1), e;
|
|
219
|
+
}
|
|
220
|
+
_advance(e) {
|
|
221
|
+
let t = this.applyPipeline();
|
|
222
|
+
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;
|
|
223
|
+
}
|
|
224
|
+
tick() {
|
|
225
|
+
return this._advance(16.667);
|
|
226
|
+
}
|
|
227
|
+
tickDt(e) {
|
|
228
|
+
return this._advance(e);
|
|
229
|
+
}
|
|
230
|
+
get progress() {
|
|
231
|
+
return this.currentProgress;
|
|
232
|
+
}
|
|
233
|
+
get settled() {
|
|
234
|
+
return this.smoother == null || this.smoother.settled;
|
|
235
|
+
}
|
|
236
|
+
snap() {
|
|
237
|
+
this.smoother?.snap(), this.smoother && (this.currentProgress = this.smoother.current);
|
|
238
|
+
}
|
|
239
|
+
reset(e) {
|
|
240
|
+
let t = e ?? 0;
|
|
241
|
+
this.smoother && this.smoother.reset(t), this.currentProgress = t;
|
|
242
|
+
}
|
|
243
|
+
}, E = class extends T {
|
|
244
|
+
threshold;
|
|
245
|
+
getScrollY;
|
|
246
|
+
getViewportHeight;
|
|
247
|
+
constructor(e) {
|
|
248
|
+
super(e), this.threshold = e?.threshold ?? .35, this.getScrollY = e?.getScrollY ?? (() => window.scrollY), this.getViewportHeight = e?.getViewportHeight ?? (() => window.innerHeight);
|
|
249
|
+
}
|
|
250
|
+
sample() {
|
|
251
|
+
let e = this.getViewportHeight() * this.threshold;
|
|
252
|
+
return e <= 0 ? 0 : this.getScrollY() / e;
|
|
253
|
+
}
|
|
254
|
+
}, D = class extends T {
|
|
255
|
+
value = 0;
|
|
256
|
+
constructor(e) {
|
|
257
|
+
super({
|
|
258
|
+
smoothing: !1,
|
|
259
|
+
...e
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
set(e) {
|
|
263
|
+
this.value = e;
|
|
264
|
+
}
|
|
265
|
+
sample() {
|
|
266
|
+
return this.value;
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
function O(e) {
|
|
270
|
+
if (typeof window > "u") return null;
|
|
271
|
+
if (e.kind === "scroll") {
|
|
272
|
+
if (globalThis.ScrollTimeline === void 0) return null;
|
|
273
|
+
let t = {};
|
|
274
|
+
return e.source !== void 0 && (t.source = e.source), e.axis !== void 0 && (t.axis = e.axis), new globalThis.ScrollTimeline(t);
|
|
275
|
+
}
|
|
276
|
+
if (globalThis.ViewTimeline === void 0) return null;
|
|
277
|
+
let t = { subject: e.subject };
|
|
278
|
+
return e.axis !== void 0 && (t.axis = e.axis), e.inset !== void 0 && (t.inset = e.inset), new globalThis.ViewTimeline(t);
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
281
|
+
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 };
|