@ssgoi/core 6.6.8 → 6.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/animation.d.ts +2 -2
- package/dist/animation/frame-scheduler.d.ts +36 -0
- package/dist/animation/frame-scheduler.d.ts.map +1 -0
- package/dist/animation/multi-animation.d.ts +3 -2
- package/dist/animation/multi-animation.d.ts.map +1 -1
- package/dist/animation/web-animation.d.ts +14 -3
- package/dist/animation/web-animation.d.ts.map +1 -1
- package/dist/index.cjs +11 -11
- package/dist/index.js +1165 -958
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +2 -2
- package/dist/multi-animation-6124HEke.cjs +1 -0
- package/dist/multi-animation-ZFZBDBGr.js +439 -0
- package/dist/transitions/hero/fit.d.ts +5 -0
- package/dist/transitions/hero/fit.d.ts.map +1 -0
- package/dist/transitions/hero/transition.d.ts +12 -1
- package/dist/transitions/hero/transition.d.ts.map +1 -1
- package/dist/transitions/hero/types.d.ts +2 -1
- package/dist/transitions/hero/types.d.ts.map +1 -1
- package/dist/transitions/media-geometry.d.ts +55 -0
- package/dist/transitions/media-geometry.d.ts.map +1 -0
- package/dist/transitions/zoom/transition.d.ts +5 -1
- package/dist/transitions/zoom/transition.d.ts.map +1 -1
- package/dist/transitions/zoom/types.d.ts +5 -0
- package/dist/transitions/zoom/types.d.ts.map +1 -1
- package/dist/transitions/zoom/zoom-element.d.ts +2 -2
- package/dist/transitions/zoom/zoom-element.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/multi-animation-BC5ihz8S.js +0 -367
- package/dist/multi-animation-CE9yYIGJ.cjs +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type MediaFit = "contain" | "cover";
|
|
2
|
+
export interface MediaRect {
|
|
3
|
+
left: number;
|
|
4
|
+
top: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
export interface MediaInsets {
|
|
9
|
+
top: number;
|
|
10
|
+
right: number;
|
|
11
|
+
bottom: number;
|
|
12
|
+
left: number;
|
|
13
|
+
}
|
|
14
|
+
type RadiusSource = "computed" | "legacy" | "none" | "unsupported";
|
|
15
|
+
export interface MediaGeometry {
|
|
16
|
+
bbox: MediaRect;
|
|
17
|
+
content: MediaRect;
|
|
18
|
+
window: MediaRect;
|
|
19
|
+
clipInset: MediaInsets;
|
|
20
|
+
aspectRatio: number | null;
|
|
21
|
+
fit: MediaFit | null;
|
|
22
|
+
radius: number;
|
|
23
|
+
radiusSource: RadiusSource;
|
|
24
|
+
bboxRadius: number;
|
|
25
|
+
bboxRadiusSource: RadiusSource;
|
|
26
|
+
contentAware: boolean;
|
|
27
|
+
mediaElement: HTMLElement | null;
|
|
28
|
+
}
|
|
29
|
+
export interface ElementMediaGeometryOptions {
|
|
30
|
+
/** Compatibility fit used only when a legacy aspect-ratio hint is present. */
|
|
31
|
+
fallbackFit?: MediaFit;
|
|
32
|
+
/** @deprecated Compatibility only. Intrinsic media dimensions are inferred. */
|
|
33
|
+
legacyAspectRatioAttribute?: string;
|
|
34
|
+
/** @deprecated Compatibility only. Border radius is inferred from CSS. */
|
|
35
|
+
legacyRadiusAttribute?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolve only an unambiguous local image target. We intentionally avoid a
|
|
39
|
+
* deep descendant query: cards commonly contain icons, avatars, pictures,
|
|
40
|
+
* videos, and multiple images that must not be mistaken for the shared visual.
|
|
41
|
+
*/
|
|
42
|
+
export declare function findMediaElement(keyedEl: HTMLElement): HTMLElement | null;
|
|
43
|
+
export declare function readIntrinsicAspectRatio(el: HTMLElement): number | null;
|
|
44
|
+
export declare function centerX(rect: MediaRect): number;
|
|
45
|
+
export declare function centerY(rect: MediaRect): number;
|
|
46
|
+
export declare function insetWithin(outer: MediaRect, inner: MediaRect): MediaInsets;
|
|
47
|
+
export declare function fittedContentRect(bbox: MediaRect, aspectRatio: number, fit: MediaFit): MediaRect;
|
|
48
|
+
export declare function createMediaGeometry(bbox: MediaRect, aspectRatio: number | null, fit: MediaFit | null): MediaGeometry;
|
|
49
|
+
export declare function isCompatibleMediaGeometryPair(from: MediaGeometry, to: MediaGeometry): boolean;
|
|
50
|
+
export declare function normalizeMediaGeometryPair(from: MediaGeometry, to: MediaGeometry): [MediaGeometry, MediaGeometry];
|
|
51
|
+
export declare function resolveElementMediaGeometry(keyedEl: HTMLElement, keyedBox: MediaRect, measure: (el: HTMLElement) => MediaRect, options: ElementMediaGeometryOptions): MediaGeometry;
|
|
52
|
+
/** Inverse-project `targetWindow` into `baseContent` before its transform. */
|
|
53
|
+
export declare function projectedWindowRect(baseContent: MediaRect, targetContent: MediaRect, targetWindow: MediaRect, scaleX: number, scaleY: number): MediaRect;
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=media-geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-geometry.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/media-geometry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAE3C,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,KAAK,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,GAAG,aAAa,CAAC;AAEnE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,EAAE,WAAW,CAAC;IACvB,WAAW,E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AI,EAAE,aAAa,EACnB,EAAE,EAAE,aAAa,GAChB,CAAC,aAAa,EAAE,aAAa,CAAC,CAIhC;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,SAAS,EACvC,OAAO,EAAE,2BAA2B,GACnC,aAAa,CAsFf;AAED,8EAA8E;AAC9E,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,SAAS,EACtB,aAAa,EAAE,SAAS,EACxB,YAAY,EAAE,SAAS,EACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,SAAS,CAeX"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { TransitionConfig } from '../../types/index.ts';
|
|
2
|
-
import { NormalizedZoomOptions, ZoomExtras } from './types';
|
|
2
|
+
import { NormalizedZoomOptions, ZoomAnimationInput, ZoomExtras, ZoomResolved } from './types';
|
|
3
3
|
export type { ZoomType, ZoomVariant, NormalizedZoomOptions } from './types';
|
|
4
|
+
export declare function buildInput(resolved: ZoomResolved, fromNode: HTMLElement, toNode: HTMLElement, scrollOffset: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}): ZoomAnimationInput;
|
|
4
8
|
export declare const zoom: (options: NormalizedZoomOptions) => TransitionConfig<ZoomExtras>;
|
|
5
9
|
//# sourceMappingURL=transition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../../src/lib/transitions/zoom/transition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,gBAAgB,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../../src/lib/transitions/zoom/transition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAe/D,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAElB,UAAU,EAEV,YAAY,EAGb,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAuF5E,wBAAgB,UAAU,CACxB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,WAAW,EACrB,MAAM,EAAE,WAAW,EACnB,YAAY,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACrC,kBAAkB,CAuDpB;AA+MD,eAAO,MAAM,IAAI,GACf,SAAS,qBAAqB,KAC7B,gBAAgB,CAAC,UAAU,CAsG7B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PhysicsOptions, SsgoiTransitionContext } from '../../types/index.ts';
|
|
2
2
|
import { Animation } from '../../animation';
|
|
3
|
+
import { MediaGeometry } from '../media-geometry';
|
|
3
4
|
export type ZoomType = "expand" | "static" | "blur";
|
|
4
5
|
export type ZoomVariant = "default" | "fade";
|
|
5
6
|
export interface NormalizedZoomOptions {
|
|
@@ -15,6 +16,10 @@ export interface ZoomAnimationConfig {
|
|
|
15
16
|
export interface ZoomAnimationInput {
|
|
16
17
|
enterRect: DOMRect;
|
|
17
18
|
exitRect: DOMRect;
|
|
19
|
+
/** Optional content-aware geometry used only by the foreground tile. */
|
|
20
|
+
enterMedia?: MediaGeometry;
|
|
21
|
+
/** Optional content-aware geometry used only by the foreground tile. */
|
|
22
|
+
exitMedia?: MediaGeometry;
|
|
18
23
|
pageRect: DOMRect;
|
|
19
24
|
scrollOffset: {
|
|
20
25
|
x: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/transitions/zoom/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AACrE,O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CAAC,SAAS,MAAM,qBAAqB,GACtC,qBAAqB,CAAC,CAAC,CAAC,GACxB,cAAc,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,EAAE,EAAE,WAAW,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,kBAAkB,CAAC;IAC1B,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,UAAU,CAAC;IACnB;;;OAGG;IACH,OAAO,EAAE,sBAAsB,CAAC;IAChC;;;;OAIG;IACH,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;CACtC;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAE9D;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,SAAS,EAAE,CAAC;CACtD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ZoomAnimationConfig, ZoomAnimationInput } from './types';
|
|
2
|
-
export declare function createZoomIn(
|
|
3
|
-
export declare function createZoomOut(
|
|
2
|
+
export declare function createZoomIn(input: ZoomAnimationInput): ZoomAnimationConfig;
|
|
3
|
+
export declare function createZoomOut(input: ZoomAnimationInput): ZoomAnimationConfig;
|
|
4
4
|
//# sourceMappingURL=zoom-element.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zoom-element.d.ts","sourceRoot":"","sources":["../../../src/lib/transitions/zoom/zoom-element.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"zoom-element.d.ts","sourceRoot":"","sources":["../../../src/lib/transitions/zoom/zoom-element.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAiGvE,wBAAgB,YAAY,CAAC,KAAK,EAAE,kBAAkB,GAAG,mBAAmB,CAgC3E;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,mBAAmB,CAgC5E"}
|
package/package.json
CHANGED
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
var g = Object.defineProperty;
|
|
2
|
-
var y = (n, r, t) => r in n ? g(n, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[r] = t;
|
|
3
|
-
var s = (n, r, t) => y(n, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
-
class m {
|
|
5
|
-
constructor() {
|
|
6
|
-
/** Current playback rate (1 = realtime, 0 = paused, negative = backwards) */
|
|
7
|
-
s(this, "_playbackRate", 1);
|
|
8
|
-
/** Fired every frame with the most recent value. Optional. */
|
|
9
|
-
s(this, "onUpdate");
|
|
10
|
-
/** Fired once when the animation settles. */
|
|
11
|
-
s(this, "onComplete");
|
|
12
|
-
}
|
|
13
|
-
get playbackRate() {
|
|
14
|
-
return this._playbackRate;
|
|
15
|
-
}
|
|
16
|
-
set playbackRate(r) {
|
|
17
|
-
this._playbackRate = r;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const b = 0.01, C = 0.01, v = 0.05;
|
|
21
|
-
function w(n) {
|
|
22
|
-
return new Promise((r) => {
|
|
23
|
-
requestAnimationFrame(() => {
|
|
24
|
-
requestAnimationFrame(() => {
|
|
25
|
-
r();
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
const p = 1e3 / 60;
|
|
31
|
-
class k extends m {
|
|
32
|
-
constructor(t) {
|
|
33
|
-
super();
|
|
34
|
-
s(this, "element");
|
|
35
|
-
s(this, "integrator");
|
|
36
|
-
s(this, "styleFn");
|
|
37
|
-
s(this, "lowerBound");
|
|
38
|
-
s(this, "upperBound");
|
|
39
|
-
s(this, "currentValue");
|
|
40
|
-
s(this, "currentVelocity", 0);
|
|
41
|
-
s(this, "frames", []);
|
|
42
|
-
s(this, "waapi", null);
|
|
43
|
-
s(this, "runId", 0);
|
|
44
|
-
s(this, "waitingForStart", !1);
|
|
45
|
-
s(this, "startReady", !1);
|
|
46
|
-
s(this, "pendingFirstFrame");
|
|
47
|
-
s(this, "running", !1);
|
|
48
|
-
s(this, "paused", !1);
|
|
49
|
-
s(this, "settled", !1);
|
|
50
|
-
s(this, "reversing", !1);
|
|
51
|
-
this.element = t.element, this.integrator = t.integrator, this.styleFn = t.style, this.lowerBound = t.lowerBound ?? 0, this.upperBound = t.upperBound ?? 1, this.currentValue = this.lowerBound, this.onUpdate = t.onUpdate, this.onComplete = t.onComplete;
|
|
52
|
-
}
|
|
53
|
-
play() {
|
|
54
|
-
if (this.reversing = !1, this.paused && this.waapi) {
|
|
55
|
-
if (this.paused = !1, this.running = !0, this.waitingForStart) {
|
|
56
|
-
this.startReady && this.playPreparedWaapi(this.waapi);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
this.waapi.play();
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
this.runToward(this.upperBound);
|
|
63
|
-
}
|
|
64
|
-
reverse() {
|
|
65
|
-
this.reversing = !0, this.runToward(this.lowerBound);
|
|
66
|
-
}
|
|
67
|
-
pause() {
|
|
68
|
-
var t;
|
|
69
|
-
this.running && (this.captureLiveState(), (t = this.waapi) == null || t.pause(), this.running = !1, this.paused = !0);
|
|
70
|
-
}
|
|
71
|
-
complete() {
|
|
72
|
-
var t;
|
|
73
|
-
this.clearWaapi(), this.running = !1, this.paused = !1, this.currentValue = this.upperBound, this.currentVelocity = 0, this.applyStyleAt(this.currentValue), this.settled = !0, (t = this.onComplete) == null || t.call(this);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Drop the WAAPI forwards-fill after the run has settled, letting inline
|
|
77
|
-
* styles govern the resting visual. Call only from `onComplete` (the run is
|
|
78
|
-
* already finished) — otherwise it cancels mid-flight. Unlike `complete()`,
|
|
79
|
-
* it writes no final frame, so a caller can reset the element to its natural
|
|
80
|
-
* state without the lingering fill clobbering it.
|
|
81
|
-
*/
|
|
82
|
-
releaseFill() {
|
|
83
|
-
this.clearWaapi();
|
|
84
|
-
}
|
|
85
|
-
get isAnimating() {
|
|
86
|
-
return this.running;
|
|
87
|
-
}
|
|
88
|
-
get isPaused() {
|
|
89
|
-
return this.paused;
|
|
90
|
-
}
|
|
91
|
-
get isComplete() {
|
|
92
|
-
return this.settled;
|
|
93
|
-
}
|
|
94
|
-
get isReversing() {
|
|
95
|
-
return this.reversing;
|
|
96
|
-
}
|
|
97
|
-
get progress() {
|
|
98
|
-
this.running && this.captureLiveState();
|
|
99
|
-
const t = this.upperBound - this.lowerBound;
|
|
100
|
-
if (t === 0) return 0;
|
|
101
|
-
const e = (this.currentValue - this.lowerBound) / t;
|
|
102
|
-
return e < 0 ? 0 : e > 1 ? 1 : e;
|
|
103
|
-
}
|
|
104
|
-
findTimeForProgress(t) {
|
|
105
|
-
if (this.frames.length < 2) return null;
|
|
106
|
-
const e = this.upperBound - this.lowerBound;
|
|
107
|
-
if (e === 0) return 0;
|
|
108
|
-
for (const i of this.frames)
|
|
109
|
-
if ((i.position - this.lowerBound) / e >= t) return i.time;
|
|
110
|
-
return this.frames[this.frames.length - 1].time;
|
|
111
|
-
}
|
|
112
|
-
get playbackRate() {
|
|
113
|
-
return super.playbackRate;
|
|
114
|
-
}
|
|
115
|
-
set playbackRate(t) {
|
|
116
|
-
super.playbackRate = t, this.waapi && (this.waapi.playbackRate = t);
|
|
117
|
-
}
|
|
118
|
-
getPose() {
|
|
119
|
-
return this.running && this.captureLiveState(), [
|
|
120
|
-
{
|
|
121
|
-
element: this.element,
|
|
122
|
-
value: this.currentValue,
|
|
123
|
-
velocity: this.currentVelocity
|
|
124
|
-
}
|
|
125
|
-
];
|
|
126
|
-
}
|
|
127
|
-
getTimeline() {
|
|
128
|
-
const t = this.frames.map((e) => {
|
|
129
|
-
const i = e.position, a = this.lowerBound + this.upperBound - i;
|
|
130
|
-
return {
|
|
131
|
-
time: e.time,
|
|
132
|
-
value: e.position,
|
|
133
|
-
velocity: e.velocity,
|
|
134
|
-
style: this.styleFn(i, a)
|
|
135
|
-
};
|
|
136
|
-
});
|
|
137
|
-
return [{ element: this.element, frames: t }];
|
|
138
|
-
}
|
|
139
|
-
matchInto(t) {
|
|
140
|
-
const e = t.find((i) => i.element === this.element);
|
|
141
|
-
e && (this.currentValue = e.value, this.currentVelocity = e.velocity);
|
|
142
|
-
}
|
|
143
|
-
/* ───────────────────────────────────────────────────────── private */
|
|
144
|
-
runToward(t) {
|
|
145
|
-
var u;
|
|
146
|
-
if (this.running && this.captureLiveState(), this.clearWaapi(), this.running = !1, this.paused = !1, this.settled = !1, this.frames = F(
|
|
147
|
-
this.integrator,
|
|
148
|
-
this.currentValue,
|
|
149
|
-
t,
|
|
150
|
-
this.currentVelocity
|
|
151
|
-
), this.frames.length === 0) {
|
|
152
|
-
this.currentValue = t, this.currentVelocity = 0, this.applyStyleAt(t), this.settled = !0, (u = this.onComplete) == null || u.call(this);
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const e = this.frames.map((c) => {
|
|
156
|
-
const d = c.position, f = this.lowerBound + this.upperBound - d;
|
|
157
|
-
return this.styleFn(d, f);
|
|
158
|
-
}), i = e[0], a = this.frames[this.frames.length - 1], l = a.time, o = ++this.runId, h = this.element.animate(e, {
|
|
159
|
-
duration: l,
|
|
160
|
-
fill: "both",
|
|
161
|
-
easing: "linear",
|
|
162
|
-
composite: "replace"
|
|
163
|
-
});
|
|
164
|
-
h.playbackRate = this.playbackRate, h.currentTime = 0, h.pause(), this.waapi = h, this.waitingForStart = !0, this.startReady = !1, this.pendingFirstFrame = i, this.running = !0, h.onfinish = () => {
|
|
165
|
-
var c;
|
|
166
|
-
!this.running || this.waapi !== h || (this.running = !1, this.settled = !0, this.currentValue = a.position, this.currentVelocity = 0, (c = this.onComplete) == null || c.call(this));
|
|
167
|
-
}, this.startWhenReady(h, o);
|
|
168
|
-
}
|
|
169
|
-
clearWaapi() {
|
|
170
|
-
var t;
|
|
171
|
-
this.runId++, (t = this.waapi) == null || t.cancel(), this.waapi = null, this.waitingForStart = !1, this.startReady = !1, this.pendingFirstFrame = void 0;
|
|
172
|
-
}
|
|
173
|
-
captureLiveState() {
|
|
174
|
-
if (this.frames.length === 0) return;
|
|
175
|
-
const t = S(this.waapi);
|
|
176
|
-
if (t === null) return;
|
|
177
|
-
const { position: e, velocity: i } = R(this.frames, t);
|
|
178
|
-
this.currentValue = e, this.currentVelocity = i;
|
|
179
|
-
}
|
|
180
|
-
async startWhenReady(t, e) {
|
|
181
|
-
try {
|
|
182
|
-
await t.ready, typeof requestAnimationFrame < "u" && await w(this.element);
|
|
183
|
-
} catch {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
this.runId !== e || this.waapi !== t || (this.startReady = !0, !(!this.running || this.paused) && this.playPreparedWaapi(t));
|
|
187
|
-
}
|
|
188
|
-
playPreparedWaapi(t) {
|
|
189
|
-
if (!(this.waapi !== t || !this.waitingForStart || !this.startReady)) {
|
|
190
|
-
if (this.pendingFirstFrame)
|
|
191
|
-
for (const e of Object.keys(this.pendingFirstFrame))
|
|
192
|
-
this.element.style[e] = "";
|
|
193
|
-
this.waitingForStart = !1, this.startReady = !1, this.pendingFirstFrame = void 0, t.play();
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
applyStyleAt(t) {
|
|
197
|
-
const e = this.lowerBound + this.upperBound - t, i = this.styleFn(t, e);
|
|
198
|
-
for (const [a, l] of Object.entries(i))
|
|
199
|
-
this.element.style[a] = typeof l == "number" ? String(l) : l;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
function F(n, r, t, e) {
|
|
203
|
-
if (r === t && e === 0) return [];
|
|
204
|
-
const i = 600;
|
|
205
|
-
let a = { position: r, velocity: e }, l = 0;
|
|
206
|
-
const o = [];
|
|
207
|
-
for (let h = 0; h < i; h++) {
|
|
208
|
-
const u = h * p;
|
|
209
|
-
if (o.push({ time: u, position: a.position, velocity: a.velocity }), a = n.step(a, t, p / 1e3), n.isSettled(a, t)) {
|
|
210
|
-
if (l += p / 1e3, l >= v) {
|
|
211
|
-
o.push({
|
|
212
|
-
time: (h + 1) * p,
|
|
213
|
-
position: t,
|
|
214
|
-
velocity: 0
|
|
215
|
-
});
|
|
216
|
-
break;
|
|
217
|
-
}
|
|
218
|
-
} else
|
|
219
|
-
l = 0;
|
|
220
|
-
}
|
|
221
|
-
return o;
|
|
222
|
-
}
|
|
223
|
-
function R(n, r) {
|
|
224
|
-
if (n.length === 0) return { position: 0, velocity: 0 };
|
|
225
|
-
const t = n[0], e = n[n.length - 1];
|
|
226
|
-
if (r <= 0)
|
|
227
|
-
return { position: t.position, velocity: t.velocity };
|
|
228
|
-
if (r >= e.time)
|
|
229
|
-
return { position: e.position, velocity: e.velocity };
|
|
230
|
-
let i = 0, a = n.length - 1;
|
|
231
|
-
for (; i < a - 1; ) {
|
|
232
|
-
const u = i + a >> 1;
|
|
233
|
-
n[u].time <= r ? i = u : a = u;
|
|
234
|
-
}
|
|
235
|
-
const l = n[i], o = n[a], h = (r - l.time) / (o.time - l.time);
|
|
236
|
-
return {
|
|
237
|
-
position: l.position + (o.position - l.position) * h,
|
|
238
|
-
velocity: l.velocity + (o.velocity - l.velocity) * h
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
function S(n) {
|
|
242
|
-
const r = n == null ? void 0 : n.currentTime;
|
|
243
|
-
return typeof r == "number" ? r : null;
|
|
244
|
-
}
|
|
245
|
-
class A extends m {
|
|
246
|
-
constructor(t, e = {}) {
|
|
247
|
-
super();
|
|
248
|
-
s(this, "children");
|
|
249
|
-
s(this, "startAt");
|
|
250
|
-
s(this, "pendingComplete", 0);
|
|
251
|
-
s(this, "running", !1);
|
|
252
|
-
s(this, "pendingStartTimers", []);
|
|
253
|
-
this.children = t, (e.mode ?? "parallel") === "sequence" ? this.startAt = t.map((i, a) => a === 0 ? 0 : 1) : this.startAt = e.startAt ?? [];
|
|
254
|
-
}
|
|
255
|
-
play() {
|
|
256
|
-
this.startRun("play");
|
|
257
|
-
}
|
|
258
|
-
reverse() {
|
|
259
|
-
this.startRun("reverse");
|
|
260
|
-
}
|
|
261
|
-
pause() {
|
|
262
|
-
this.running = !1, this.clearPendingStartTimers();
|
|
263
|
-
for (const t of this.children) t.pause();
|
|
264
|
-
}
|
|
265
|
-
complete() {
|
|
266
|
-
var t;
|
|
267
|
-
this.running = !1, this.clearPendingStartTimers();
|
|
268
|
-
for (const e of this.children) e.complete();
|
|
269
|
-
(t = this.onComplete) == null || t.call(this);
|
|
270
|
-
}
|
|
271
|
-
get progress() {
|
|
272
|
-
if (this.children.length === 0) return 0;
|
|
273
|
-
let t = 0;
|
|
274
|
-
for (const e of this.children) t += e.progress;
|
|
275
|
-
return t / this.children.length;
|
|
276
|
-
}
|
|
277
|
-
getPose() {
|
|
278
|
-
return this.children.flatMap((t) => t.getPose());
|
|
279
|
-
}
|
|
280
|
-
getTimeline() {
|
|
281
|
-
return this.children.flatMap((t) => t.getTimeline());
|
|
282
|
-
}
|
|
283
|
-
matchInto(t) {
|
|
284
|
-
}
|
|
285
|
-
get isAnimating() {
|
|
286
|
-
return this.children.some((t) => t.isAnimating);
|
|
287
|
-
}
|
|
288
|
-
get isPaused() {
|
|
289
|
-
return this.children.some((t) => t.isPaused) && this.children.every((t) => t.isPaused || t.isComplete);
|
|
290
|
-
}
|
|
291
|
-
get isComplete() {
|
|
292
|
-
return this.children.every((t) => t.isComplete);
|
|
293
|
-
}
|
|
294
|
-
get isReversing() {
|
|
295
|
-
return this.children.some((t) => t.isReversing);
|
|
296
|
-
}
|
|
297
|
-
get playbackRate() {
|
|
298
|
-
return super.playbackRate;
|
|
299
|
-
}
|
|
300
|
-
set playbackRate(t) {
|
|
301
|
-
super.playbackRate = t;
|
|
302
|
-
for (const e of this.children) e.playbackRate = t;
|
|
303
|
-
}
|
|
304
|
-
/* ───────────────────────────────────────────────────────── private */
|
|
305
|
-
startRun(t) {
|
|
306
|
-
if (this.running && this.pause(), this.running = !0, this.pendingComplete = this.children.length, this.pendingComplete === 0) {
|
|
307
|
-
this.handleFinished();
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
for (const e of this.children) {
|
|
311
|
-
const i = e.onComplete;
|
|
312
|
-
e.onComplete = () => {
|
|
313
|
-
i == null || i(), this.handleChildComplete();
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
this.scheduleStart(0, t);
|
|
317
|
-
}
|
|
318
|
-
// Chained start: play child `index`, then schedule the next one based on
|
|
319
|
-
// *this* child's freshly computed timeline. Doing this lazily (rather than
|
|
320
|
-
// up-front for the whole chain) is what makes it correct for >2 children —
|
|
321
|
-
// child[i+1]'s trigger ms is only knowable after child[i].play() has run
|
|
322
|
-
// `simulate()`. Single setTimeout per gap, no polling.
|
|
323
|
-
scheduleStart(t, e) {
|
|
324
|
-
if (!this.running || t >= this.children.length) return;
|
|
325
|
-
this.children[t][e]();
|
|
326
|
-
const i = t + 1;
|
|
327
|
-
if (i >= this.children.length) return;
|
|
328
|
-
const a = this.startAt[i];
|
|
329
|
-
if (a === void 0 || a <= 0) {
|
|
330
|
-
this.scheduleStart(i, e);
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
const l = this.children[t].findTimeForProgress(a);
|
|
334
|
-
if (l === null || l <= 0) {
|
|
335
|
-
this.scheduleStart(i, e);
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
const o = Math.abs(this.playbackRate) || 1, h = l / o, u = setTimeout(() => {
|
|
339
|
-
this.pendingStartTimers = this.pendingStartTimers.filter(
|
|
340
|
-
(c) => c !== u
|
|
341
|
-
), this.running && this.scheduleStart(i, e);
|
|
342
|
-
}, h);
|
|
343
|
-
this.pendingStartTimers.push(u);
|
|
344
|
-
}
|
|
345
|
-
clearPendingStartTimers() {
|
|
346
|
-
for (const t of this.pendingStartTimers) clearTimeout(t);
|
|
347
|
-
this.pendingStartTimers = [];
|
|
348
|
-
}
|
|
349
|
-
handleChildComplete() {
|
|
350
|
-
this.pendingComplete--, this.pendingComplete <= 0 && this.handleFinished();
|
|
351
|
-
}
|
|
352
|
-
handleFinished() {
|
|
353
|
-
var t;
|
|
354
|
-
this.running = !1, this.clearPendingStartTimers(), (t = this.onComplete) == null || t.call(this);
|
|
355
|
-
}
|
|
356
|
-
findTimeForProgress(t) {
|
|
357
|
-
return null;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
export {
|
|
361
|
-
m as A,
|
|
362
|
-
A as M,
|
|
363
|
-
b as P,
|
|
364
|
-
v as S,
|
|
365
|
-
C as V,
|
|
366
|
-
k as W
|
|
367
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var y=Object.defineProperty;var S=(n,r,t)=>r in n?y(n,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[r]=t;var s=(n,r,t)=>S(n,typeof r!="symbol"?r+"":r,t);class d{constructor(){s(this,"_playbackRate",1);s(this,"onUpdate");s(this,"onComplete")}get playbackRate(){return this._playbackRate}set playbackRate(r){this._playbackRate=r}}const v=.01,R=.01,f=.05;function T(n){return new Promise(r=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{r()})})})}const p=1e3/60;class w extends d{constructor(t){super();s(this,"element");s(this,"integrator");s(this,"styleFn");s(this,"lowerBound");s(this,"upperBound");s(this,"currentValue");s(this,"currentVelocity",0);s(this,"frames",[]);s(this,"waapi",null);s(this,"runId",0);s(this,"waitingForStart",!1);s(this,"startReady",!1);s(this,"pendingFirstFrame");s(this,"running",!1);s(this,"paused",!1);s(this,"settled",!1);s(this,"reversing",!1);this.element=t.element,this.integrator=t.integrator,this.styleFn=t.style,this.lowerBound=t.lowerBound??0,this.upperBound=t.upperBound??1,this.currentValue=this.lowerBound,this.onUpdate=t.onUpdate,this.onComplete=t.onComplete}play(){if(this.reversing=!1,this.paused&&this.waapi){if(this.paused=!1,this.running=!0,this.waitingForStart){this.startReady&&this.playPreparedWaapi(this.waapi);return}this.waapi.play();return}this.runToward(this.upperBound)}reverse(){this.reversing=!0,this.runToward(this.lowerBound)}pause(){var t;this.running&&(this.captureLiveState(),(t=this.waapi)==null||t.pause(),this.running=!1,this.paused=!0)}complete(){var t;this.clearWaapi(),this.running=!1,this.paused=!1,this.currentValue=this.upperBound,this.currentVelocity=0,this.applyStyleAt(this.currentValue),this.settled=!0,(t=this.onComplete)==null||t.call(this)}releaseFill(){this.clearWaapi()}get isAnimating(){return this.running}get isPaused(){return this.paused}get isComplete(){return this.settled}get isReversing(){return this.reversing}get progress(){this.running&&this.captureLiveState();const t=this.upperBound-this.lowerBound;if(t===0)return 0;const e=(this.currentValue-this.lowerBound)/t;return e<0?0:e>1?1:e}findTimeForProgress(t){if(this.frames.length<2)return null;const e=this.upperBound-this.lowerBound;if(e===0)return 0;for(const i of this.frames)if((i.position-this.lowerBound)/e>=t)return i.time;return this.frames[this.frames.length-1].time}get playbackRate(){return super.playbackRate}set playbackRate(t){super.playbackRate=t,this.waapi&&(this.waapi.playbackRate=t)}getPose(){return this.running&&this.captureLiveState(),[{element:this.element,value:this.currentValue,velocity:this.currentVelocity}]}getTimeline(){const t=this.frames.map(e=>{const i=e.position,a=this.lowerBound+this.upperBound-i;return{time:e.time,value:e.position,velocity:e.velocity,style:this.styleFn(i,a)}});return[{element:this.element,frames:t}]}matchInto(t){const e=t.find(i=>i.element===this.element);e&&(this.currentValue=e.value,this.currentVelocity=e.velocity)}runToward(t){var u;if(this.running&&this.captureLiveState(),this.clearWaapi(),this.running=!1,this.paused=!1,this.settled=!1,this.frames=F(this.integrator,this.currentValue,t,this.currentVelocity),this.frames.length===0){this.currentValue=t,this.currentVelocity=0,this.applyStyleAt(t),this.settled=!0,(u=this.onComplete)==null||u.call(this);return}const e=this.frames.map(c=>{const m=c.position,g=this.lowerBound+this.upperBound-m;return this.styleFn(m,g)}),i=e[0],a=this.frames[this.frames.length-1],l=a.time,o=++this.runId,h=this.element.animate(e,{duration:l,fill:"both",easing:"linear",composite:"replace"});h.playbackRate=this.playbackRate,h.currentTime=0,h.pause(),this.waapi=h,this.waitingForStart=!0,this.startReady=!1,this.pendingFirstFrame=i,this.running=!0,h.onfinish=()=>{var c;!this.running||this.waapi!==h||(this.running=!1,this.settled=!0,this.currentValue=a.position,this.currentVelocity=0,(c=this.onComplete)==null||c.call(this))},this.startWhenReady(h,o)}clearWaapi(){var t;this.runId++,(t=this.waapi)==null||t.cancel(),this.waapi=null,this.waitingForStart=!1,this.startReady=!1,this.pendingFirstFrame=void 0}captureLiveState(){if(this.frames.length===0)return;const t=A(this.waapi);if(t===null)return;const{position:e,velocity:i}=b(this.frames,t);this.currentValue=e,this.currentVelocity=i}async startWhenReady(t,e){try{await t.ready,typeof requestAnimationFrame<"u"&&await T(this.element)}catch{return}this.runId!==e||this.waapi!==t||(this.startReady=!0,!(!this.running||this.paused)&&this.playPreparedWaapi(t))}playPreparedWaapi(t){if(!(this.waapi!==t||!this.waitingForStart||!this.startReady)){if(this.pendingFirstFrame)for(const e of Object.keys(this.pendingFirstFrame))this.element.style[e]="";this.waitingForStart=!1,this.startReady=!1,this.pendingFirstFrame=void 0,t.play()}}applyStyleAt(t){const e=this.lowerBound+this.upperBound-t,i=this.styleFn(t,e);for(const[a,l]of Object.entries(i))this.element.style[a]=typeof l=="number"?String(l):l}}function F(n,r,t,e){if(r===t&&e===0)return[];const i=600;let a={position:r,velocity:e},l=0;const o=[];for(let h=0;h<i;h++){const u=h*p;if(o.push({time:u,position:a.position,velocity:a.velocity}),a=n.step(a,t,p/1e3),n.isSettled(a,t)){if(l+=p/1e3,l>=f){o.push({time:(h+1)*p,position:t,velocity:0});break}}else l=0}return o}function b(n,r){if(n.length===0)return{position:0,velocity:0};const t=n[0],e=n[n.length-1];if(r<=0)return{position:t.position,velocity:t.velocity};if(r>=e.time)return{position:e.position,velocity:e.velocity};let i=0,a=n.length-1;for(;i<a-1;){const u=i+a>>1;n[u].time<=r?i=u:a=u}const l=n[i],o=n[a],h=(r-l.time)/(o.time-l.time);return{position:l.position+(o.position-l.position)*h,velocity:l.velocity+(o.velocity-l.velocity)*h}}function A(n){const r=n==null?void 0:n.currentTime;return typeof r=="number"?r:null}class C extends d{constructor(t,e={}){super();s(this,"children");s(this,"startAt");s(this,"pendingComplete",0);s(this,"running",!1);s(this,"pendingStartTimers",[]);this.children=t,(e.mode??"parallel")==="sequence"?this.startAt=t.map((i,a)=>a===0?0:1):this.startAt=e.startAt??[]}play(){this.startRun("play")}reverse(){this.startRun("reverse")}pause(){this.running=!1,this.clearPendingStartTimers();for(const t of this.children)t.pause()}complete(){var t;this.running=!1,this.clearPendingStartTimers();for(const e of this.children)e.complete();(t=this.onComplete)==null||t.call(this)}get progress(){if(this.children.length===0)return 0;let t=0;for(const e of this.children)t+=e.progress;return t/this.children.length}getPose(){return this.children.flatMap(t=>t.getPose())}getTimeline(){return this.children.flatMap(t=>t.getTimeline())}matchInto(t){}get isAnimating(){return this.children.some(t=>t.isAnimating)}get isPaused(){return this.children.some(t=>t.isPaused)&&this.children.every(t=>t.isPaused||t.isComplete)}get isComplete(){return this.children.every(t=>t.isComplete)}get isReversing(){return this.children.some(t=>t.isReversing)}get playbackRate(){return super.playbackRate}set playbackRate(t){super.playbackRate=t;for(const e of this.children)e.playbackRate=t}startRun(t){if(this.running&&this.pause(),this.running=!0,this.pendingComplete=this.children.length,this.pendingComplete===0){this.handleFinished();return}for(const e of this.children){const i=e.onComplete;e.onComplete=()=>{i==null||i(),this.handleChildComplete()}}this.scheduleStart(0,t)}scheduleStart(t,e){if(!this.running||t>=this.children.length)return;this.children[t][e]();const i=t+1;if(i>=this.children.length)return;const a=this.startAt[i];if(a===void 0||a<=0){this.scheduleStart(i,e);return}const l=this.children[t].findTimeForProgress(a);if(l===null||l<=0){this.scheduleStart(i,e);return}const o=Math.abs(this.playbackRate)||1,h=l/o,u=setTimeout(()=>{this.pendingStartTimers=this.pendingStartTimers.filter(c=>c!==u),this.running&&this.scheduleStart(i,e)},h);this.pendingStartTimers.push(u)}clearPendingStartTimers(){for(const t of this.pendingStartTimers)clearTimeout(t);this.pendingStartTimers=[]}handleChildComplete(){this.pendingComplete--,this.pendingComplete<=0&&this.handleFinished()}handleFinished(){var t;this.running=!1,this.clearPendingStartTimers(),(t=this.onComplete)==null||t.call(this)}findTimeForProgress(t){return null}}exports.Animation=d;exports.MultiAnimation=C;exports.POSITION_THRESHOLD=v;exports.SETTLE_THRESHOLD=f;exports.VELOCITY_THRESHOLD=R;exports.WebAnimation=w;
|