@mkbabb/keyframes.js 3.0.0 → 4.0.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-DjKYCuyH.js +21 -0
- package/dist/animations-CK1FLX_G.js +224 -0
- package/dist/engine-BZeJ58xD.js +1031 -0
- package/dist/keyframes.d.ts +1639 -178
- package/dist/keyframes.js +341 -391
- package/dist/motion-path-723lMAlR.js +31 -0
- package/dist/springTimingFunction-BgkJPP-_.js +178 -0
- package/dist/timeline-5rnU0j6r.js +281 -0
- package/package.json +43 -18
- 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-BZeJ58xD.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-5rnU0j6r.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-BZeJ58xD.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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mkbabb/keyframes.js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Create keyframe animations for anything in JavaScript; specify your keyframes in standards-complaint CSS.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -39,6 +39,29 @@
|
|
|
39
39
|
"build:watch": "vite build --watch --mode production",
|
|
40
40
|
"gh-pages": "vite build --mode gh-pages",
|
|
41
41
|
"proof:boundary": "node scripts/proof-boundary.mjs",
|
|
42
|
+
"proof:dogfood": "node scripts/proof-dogfood.mjs",
|
|
43
|
+
"proof:engine": "node scripts/proof-engine.mjs",
|
|
44
|
+
"proof:decomposition": "node scripts/proof-decomposition.mjs",
|
|
45
|
+
"proof:idioms": "node scripts/proof-idioms.mjs",
|
|
46
|
+
"proof:brittleness": "node scripts/proof-brittleness.mjs",
|
|
47
|
+
"proof:modern-web": "node scripts/proof-modern-web.mjs",
|
|
48
|
+
"proof:lighthouse-mobile": "node scripts/proof-lighthouse-mobile.mjs",
|
|
49
|
+
"proof:demo-elevate": "node scripts/proof-demo-elevate.mjs",
|
|
50
|
+
"proof:platform-adopt": "node scripts/proof-platform-adopt.mjs && vitest run test/platform-adopt.test.ts",
|
|
51
|
+
"proof:zero-alloc": "vitest run test/zero-alloc.test.ts test/snap-symmetry.test.ts test/frame-compiler.test.ts",
|
|
52
|
+
"proof:engine-correctness": "vitest run test/engine-correctness.test.ts",
|
|
53
|
+
"proof:standalone-zero-alloc": "vitest run test/standalone-zero-alloc.test.ts",
|
|
54
|
+
"proof:compile-deterministic": "vitest run test/compile-deterministic.test.ts",
|
|
55
|
+
"proof:bench-runs": "node scripts/proof-bench-runs.mjs",
|
|
56
|
+
"proof:orchestration": "node scripts/proof-orchestration.mjs",
|
|
57
|
+
"proof:interp-fastprops": "node --allow-natives-syntax scripts/proof-interp-fastprops.mjs && vitest run test/interp-fastprops.test.ts",
|
|
58
|
+
"proof:sync-step": "vitest run test/sync-step.test.ts",
|
|
59
|
+
"proof:roundtrip-easing": "vitest run test/roundtrip-easing.test.ts",
|
|
60
|
+
"proof:adapter-capture": "vitest run test/adapter-capture.test.ts",
|
|
61
|
+
"proof:motion-path": "node scripts/proof-motion-path.mjs && vitest run test/motion-path.test.ts",
|
|
62
|
+
"proof:cohesion": "vitest run test/boundary-cohesion.test.ts",
|
|
63
|
+
"proof:ci-coverage": "node scripts/proof-ci-coverage.mjs",
|
|
64
|
+
"proof:all": "npm run proof:boundary && npm run proof:dogfood && npm run proof:engine && npm run proof:decomposition && npm run proof:idioms && npm run proof:brittleness && npm run proof:demo-elevate && npm run proof:modern-web && npm run proof:zero-alloc && npm run proof:engine-correctness && npm run proof:standalone-zero-alloc && npm run proof:compile-deterministic && npm run proof:platform-adopt && npm run proof:orchestration && npm run proof:interp-fastprops && npm run proof:sync-step && npm run proof:roundtrip-easing && npm run proof:adapter-capture && npm run proof:motion-path && npm run proof:cohesion && npm run proof:bench-runs && npm run proof:ci-coverage && vitest run",
|
|
42
65
|
"test": "vitest",
|
|
43
66
|
"bench": "vitest bench"
|
|
44
67
|
},
|
|
@@ -66,11 +89,12 @@
|
|
|
66
89
|
},
|
|
67
90
|
"devDependencies": {
|
|
68
91
|
"@iconify-json/radix-icons": "^1.2.6",
|
|
69
|
-
"@iconify/vue": "^
|
|
70
|
-
"@lucide/vue": "^1.
|
|
92
|
+
"@iconify/vue": "^5.0.1",
|
|
93
|
+
"@lucide/vue": "^1.17.0",
|
|
94
|
+
"@microsoft/api-extractor": "^7.58.7",
|
|
71
95
|
"@tailwindcss/postcss": "^4.3.0",
|
|
72
|
-
"@types/node": "^
|
|
73
|
-
"@types/three": "^0.
|
|
96
|
+
"@types/node": "^25.9.1",
|
|
97
|
+
"@types/three": "^0.184.1",
|
|
74
98
|
"@unovis/ts": "^1.6.5",
|
|
75
99
|
"@unovis/vue": "^1.6.5",
|
|
76
100
|
"@vee-validate/zod": "^4.15.1",
|
|
@@ -81,29 +105,30 @@
|
|
|
81
105
|
"embla-carousel-vue": "^8.6.0",
|
|
82
106
|
"highlight.js": "^11.11.1",
|
|
83
107
|
"html2canvas": "^1.4.1",
|
|
84
|
-
"jsdom": "^
|
|
85
|
-
"monaco-editor": "^0.
|
|
108
|
+
"jsdom": "^29.1.1",
|
|
109
|
+
"monaco-editor": "^0.55.1",
|
|
86
110
|
"monaco-themes": "^0.4.8",
|
|
87
111
|
"prettier": "^3.8.3",
|
|
88
|
-
"prettier-plugin-classnames": "^0.10.
|
|
112
|
+
"prettier-plugin-classnames": "^0.10.2",
|
|
89
113
|
"prettier-plugin-merge": "^0.10.1",
|
|
90
114
|
"prettier-plugin-organize-imports": "^4.3.0",
|
|
91
115
|
"prettier-plugin-tailwindcss": "^0.8.0",
|
|
92
|
-
"reka-ui": "^2.9.
|
|
116
|
+
"reka-ui": "^2.9.9",
|
|
117
|
+
"rolldown": "^1.0.0",
|
|
93
118
|
"tailwind-merge": "^3.6.0",
|
|
94
119
|
"tailwindcss": "^4.3.0",
|
|
95
|
-
"three": "^0.
|
|
120
|
+
"three": "^0.184.0",
|
|
96
121
|
"tw-animate-css": "^1.4.0",
|
|
97
122
|
"typescript": "^6.0.3",
|
|
98
123
|
"v-calendar": "^3.1.2",
|
|
99
|
-
"vaul-vue": "^0.4.
|
|
124
|
+
"vaul-vue": "^0.4.1",
|
|
100
125
|
"vee-validate": "^4.15.1",
|
|
101
|
-
"vite": "^8.0.
|
|
102
|
-
"vite-plugin-dts": "^
|
|
103
|
-
"vitest": "^4.1.
|
|
104
|
-
"vue": "^3.5.
|
|
105
|
-
"vue-router": "^5.0
|
|
106
|
-
"vue-sonner": "^
|
|
107
|
-
"zod": "^3.
|
|
126
|
+
"vite": "^8.0.16",
|
|
127
|
+
"vite-plugin-dts": "^5.0.2",
|
|
128
|
+
"vitest": "^4.1.8",
|
|
129
|
+
"vue": "^3.5.35",
|
|
130
|
+
"vue-router": "^5.1.0",
|
|
131
|
+
"vue-sonner": "^2.0.9",
|
|
132
|
+
"zod": "^3.25.76"
|
|
108
133
|
}
|
|
109
134
|
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
//#region src/animation/internal/binarySearch.ts
|
|
2
|
-
function e(e, t, n, r) {
|
|
3
|
-
let i = 0, a = e.length - 1;
|
|
4
|
-
for (; i <= a;) {
|
|
5
|
-
let o = i + a >> 1, s = e[o];
|
|
6
|
-
if (t < n(s)) a = o - 1;
|
|
7
|
-
else if (t > r(s)) i = o + 1;
|
|
8
|
-
else return o;
|
|
9
|
-
}
|
|
10
|
-
return -1;
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/animation/internal/leaves.ts
|
|
14
|
-
var t = 1e3 / 60;
|
|
15
|
-
function n(e, t, n) {
|
|
16
|
-
return Math.min(Math.max(e, t), n);
|
|
17
|
-
}
|
|
18
|
-
function r(e, t, n, r = 0, i = 1) {
|
|
19
|
-
if (n === t) throw Error("fromMax and fromMin cannot be equal");
|
|
20
|
-
let a = (i - r) / (n - t);
|
|
21
|
-
return (e - t) * a + r;
|
|
22
|
-
}
|
|
23
|
-
function i(e, t, n) {
|
|
24
|
-
return (1 - n) * e + n * t;
|
|
25
|
-
}
|
|
26
|
-
function a(e) {
|
|
27
|
-
if (typeof window < "u" && window.requestAnimationFrame) return window.requestAnimationFrame(e);
|
|
28
|
-
let n = t, r = Date.now();
|
|
29
|
-
return setTimeout(() => {
|
|
30
|
-
let i = Date.now(), a = i - r;
|
|
31
|
-
r = i, n = Math.max(0, t - a), e(i);
|
|
32
|
-
}, n);
|
|
33
|
-
}
|
|
34
|
-
function o(e) {
|
|
35
|
-
if (typeof window < "u" && window.cancelAnimationFrame) return window.cancelAnimationFrame(e);
|
|
36
|
-
clearTimeout(e);
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/animation/internal/reduced-motion.ts
|
|
40
|
-
function s() {
|
|
41
|
-
return typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/animation/internal/css-easing.ts
|
|
45
|
-
var c = Symbol.for("keyframes.cssEasing");
|
|
46
|
-
function l(e, t) {
|
|
47
|
-
return e[c] = t, e;
|
|
48
|
-
}
|
|
49
|
-
function u(e) {
|
|
50
|
-
if (typeof e != "function") return;
|
|
51
|
-
let t = e[c];
|
|
52
|
-
return typeof t == "string" ? t : void 0;
|
|
53
|
-
}
|
|
54
|
-
//#endregion
|
|
55
|
-
export { n as a, r as c, o as i, e as l, l as n, i as o, s as r, a as s, u as t };
|