@bquery/bquery 1.2.0 → 1.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 +127 -27
- package/dist/batch-x7b2eZST.js +13 -0
- package/dist/batch-x7b2eZST.js.map +1 -0
- package/dist/component/component.d.ts +69 -0
- package/dist/component/component.d.ts.map +1 -0
- package/dist/component/html.d.ts +35 -0
- package/dist/component/html.d.ts.map +1 -0
- package/dist/component/index.d.ts +3 -126
- package/dist/component/index.d.ts.map +1 -1
- package/dist/component/props.d.ts +18 -0
- package/dist/component/props.d.ts.map +1 -0
- package/dist/component/types.d.ts +77 -0
- package/dist/component/types.d.ts.map +1 -0
- package/dist/component.es.mjs +90 -59
- package/dist/component.es.mjs.map +1 -1
- package/dist/core/collection.d.ts +55 -3
- package/dist/core/collection.d.ts.map +1 -1
- package/dist/core/dom.d.ts +6 -0
- package/dist/core/dom.d.ts.map +1 -0
- package/dist/core/element.d.ts +31 -4
- package/dist/core/element.d.ts.map +1 -1
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/utils/array.d.ts +74 -0
- package/dist/core/utils/array.d.ts.map +1 -0
- package/dist/core/utils/function.d.ts +87 -0
- package/dist/core/utils/function.d.ts.map +1 -0
- package/dist/core/utils/index.d.ts +70 -0
- package/dist/core/utils/index.d.ts.map +1 -0
- package/dist/core/utils/misc.d.ts +63 -0
- package/dist/core/utils/misc.d.ts.map +1 -0
- package/dist/core/utils/number.d.ts +65 -0
- package/dist/core/utils/number.d.ts.map +1 -0
- package/dist/core/utils/object.d.ts +133 -0
- package/dist/core/utils/object.d.ts.map +1 -0
- package/dist/core/utils/string.d.ts +80 -0
- package/dist/core/utils/string.d.ts.map +1 -0
- package/dist/core/utils/type-guards.d.ts +79 -0
- package/dist/core/utils/type-guards.d.ts.map +1 -0
- package/dist/core-BhpuvPhy.js +170 -0
- package/dist/core-BhpuvPhy.js.map +1 -0
- package/dist/core.es.mjs +495 -489
- package/dist/core.es.mjs.map +1 -1
- package/dist/full.d.ts +2 -2
- package/dist/full.d.ts.map +1 -1
- package/dist/full.es.mjs +87 -64
- package/dist/full.es.mjs.map +1 -1
- package/dist/full.iife.js +2 -2
- package/dist/full.iife.js.map +1 -1
- package/dist/full.umd.js +2 -2
- package/dist/full.umd.js.map +1 -1
- package/dist/index.es.mjs +138 -68
- package/dist/index.es.mjs.map +1 -1
- package/dist/motion/animate.d.ts +25 -0
- package/dist/motion/animate.d.ts.map +1 -0
- package/dist/motion/easing.d.ts +30 -0
- package/dist/motion/easing.d.ts.map +1 -0
- package/dist/motion/flip.d.ts +55 -0
- package/dist/motion/flip.d.ts.map +1 -0
- package/dist/motion/index.d.ts +11 -138
- package/dist/motion/index.d.ts.map +1 -1
- package/dist/motion/keyframes.d.ts +21 -0
- package/dist/motion/keyframes.d.ts.map +1 -0
- package/dist/motion/reduced-motion.d.ts +12 -0
- package/dist/motion/reduced-motion.d.ts.map +1 -0
- package/dist/motion/scroll.d.ts +15 -0
- package/dist/motion/scroll.d.ts.map +1 -0
- package/dist/motion/spring.d.ts +42 -0
- package/dist/motion/spring.d.ts.map +1 -0
- package/dist/motion/stagger.d.ts +22 -0
- package/dist/motion/stagger.d.ts.map +1 -0
- package/dist/motion/timeline.d.ts +21 -0
- package/dist/motion/timeline.d.ts.map +1 -0
- package/dist/motion/transition.d.ts +22 -0
- package/dist/motion/transition.d.ts.map +1 -0
- package/dist/motion/types.d.ts +182 -0
- package/dist/motion/types.d.ts.map +1 -0
- package/dist/motion.es.mjs +320 -61
- package/dist/motion.es.mjs.map +1 -1
- package/dist/persisted-DHoi3uEs.js +278 -0
- package/dist/persisted-DHoi3uEs.js.map +1 -0
- package/dist/platform/storage.d.ts.map +1 -1
- package/dist/platform.es.mjs +12 -7
- package/dist/platform.es.mjs.map +1 -1
- package/dist/reactive/batch.d.ts +13 -0
- package/dist/reactive/batch.d.ts.map +1 -0
- package/dist/reactive/computed.d.ts +50 -0
- package/dist/reactive/computed.d.ts.map +1 -0
- package/dist/reactive/core.d.ts +72 -0
- package/dist/reactive/core.d.ts.map +1 -0
- package/dist/reactive/effect.d.ts +15 -0
- package/dist/reactive/effect.d.ts.map +1 -0
- package/dist/reactive/index.d.ts +2 -2
- package/dist/reactive/index.d.ts.map +1 -1
- package/dist/reactive/internals.d.ts +42 -0
- package/dist/reactive/internals.d.ts.map +1 -0
- package/dist/reactive/linked.d.ts +36 -0
- package/dist/reactive/linked.d.ts.map +1 -0
- package/dist/reactive/persisted.d.ts +14 -0
- package/dist/reactive/persisted.d.ts.map +1 -0
- package/dist/reactive/readonly.d.ts +26 -0
- package/dist/reactive/readonly.d.ts.map +1 -0
- package/dist/reactive/signal.d.ts +13 -312
- package/dist/reactive/signal.d.ts.map +1 -1
- package/dist/reactive/type-guards.d.ts +20 -0
- package/dist/reactive/type-guards.d.ts.map +1 -0
- package/dist/reactive/untrack.d.ts +29 -0
- package/dist/reactive/untrack.d.ts.map +1 -0
- package/dist/reactive/watch.d.ts +42 -0
- package/dist/reactive/watch.d.ts.map +1 -0
- package/dist/reactive.es.mjs +30 -163
- package/dist/reactive.es.mjs.map +1 -1
- package/dist/router/index.d.ts +6 -252
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/links.d.ts +44 -0
- package/dist/router/links.d.ts.map +1 -0
- package/dist/router/match.d.ts +20 -0
- package/dist/router/match.d.ts.map +1 -0
- package/dist/router/navigation.d.ts +45 -0
- package/dist/router/navigation.d.ts.map +1 -0
- package/dist/router/query.d.ts +16 -0
- package/dist/router/query.d.ts.map +1 -0
- package/dist/router/router.d.ts +34 -0
- package/dist/router/router.d.ts.map +1 -0
- package/dist/router/state.d.ts +27 -0
- package/dist/router/state.d.ts.map +1 -0
- package/dist/router/types.d.ts +88 -0
- package/dist/router/types.d.ts.map +1 -0
- package/dist/router/utils.d.ts +65 -0
- package/dist/router/utils.d.ts.map +1 -0
- package/dist/router.es.mjs +168 -132
- package/dist/router.es.mjs.map +1 -1
- package/dist/sanitize-Cxvxa-DX.js +283 -0
- package/dist/sanitize-Cxvxa-DX.js.map +1 -0
- package/dist/security/constants.d.ts +42 -0
- package/dist/security/constants.d.ts.map +1 -0
- package/dist/security/csp.d.ts +24 -0
- package/dist/security/csp.d.ts.map +1 -0
- package/dist/security/index.d.ts +4 -2
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/sanitize-core.d.ts +13 -0
- package/dist/security/sanitize-core.d.ts.map +1 -0
- package/dist/security/sanitize.d.ts +5 -57
- package/dist/security/sanitize.d.ts.map +1 -1
- package/dist/security/trusted-types.d.ts +25 -0
- package/dist/security/trusted-types.d.ts.map +1 -0
- package/dist/security/types.d.ts +36 -0
- package/dist/security/types.d.ts.map +1 -0
- package/dist/security.es.mjs +50 -277
- package/dist/security.es.mjs.map +1 -1
- package/dist/store/create-store.d.ts +15 -0
- package/dist/store/create-store.d.ts.map +1 -0
- package/dist/store/define-store.d.ts +28 -0
- package/dist/store/define-store.d.ts.map +1 -0
- package/dist/store/devtools.d.ts +22 -0
- package/dist/store/devtools.d.ts.map +1 -0
- package/dist/store/index.d.ts +10 -286
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/mapping.d.ts +28 -0
- package/dist/store/mapping.d.ts.map +1 -0
- package/dist/store/persisted.d.ts +13 -0
- package/dist/store/persisted.d.ts.map +1 -0
- package/dist/store/plugins.d.ts +13 -0
- package/dist/store/plugins.d.ts.map +1 -0
- package/dist/store/registry.d.ts +28 -0
- package/dist/store/registry.d.ts.map +1 -0
- package/dist/store/types.d.ts +71 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/utils.d.ts +28 -0
- package/dist/store/utils.d.ts.map +1 -0
- package/dist/store/watch.d.ts +23 -0
- package/dist/store/watch.d.ts.map +1 -0
- package/dist/store.es.mjs +22 -224
- package/dist/store.es.mjs.map +1 -1
- package/dist/type-guards-BdKlYYlS.js +32 -0
- package/dist/type-guards-BdKlYYlS.js.map +1 -0
- package/dist/untrack-DNnnqdlR.js +6 -0
- package/dist/untrack-DNnnqdlR.js.map +1 -0
- package/dist/view/directives/bind.d.ts +7 -0
- package/dist/view/directives/bind.d.ts.map +1 -0
- package/dist/view/directives/class.d.ts +8 -0
- package/dist/view/directives/class.d.ts.map +1 -0
- package/dist/view/directives/for.d.ts +23 -0
- package/dist/view/directives/for.d.ts.map +1 -0
- package/dist/view/directives/html.d.ts +7 -0
- package/dist/view/directives/html.d.ts.map +1 -0
- package/dist/view/directives/if.d.ts +7 -0
- package/dist/view/directives/if.d.ts.map +1 -0
- package/dist/view/directives/index.d.ts +12 -0
- package/dist/view/directives/index.d.ts.map +1 -0
- package/dist/view/directives/model.d.ts +7 -0
- package/dist/view/directives/model.d.ts.map +1 -0
- package/dist/view/directives/on.d.ts +7 -0
- package/dist/view/directives/on.d.ts.map +1 -0
- package/dist/view/directives/ref.d.ts +7 -0
- package/dist/view/directives/ref.d.ts.map +1 -0
- package/dist/view/directives/show.d.ts +7 -0
- package/dist/view/directives/show.d.ts.map +1 -0
- package/dist/view/directives/style.d.ts +7 -0
- package/dist/view/directives/style.d.ts.map +1 -0
- package/dist/view/directives/text.d.ts +7 -0
- package/dist/view/directives/text.d.ts.map +1 -0
- package/dist/view/evaluate.d.ts +43 -0
- package/dist/view/evaluate.d.ts.map +1 -0
- package/dist/view/index.d.ts +3 -93
- package/dist/view/index.d.ts.map +1 -1
- package/dist/view/mount.d.ts +69 -0
- package/dist/view/mount.d.ts.map +1 -0
- package/dist/view/process.d.ts +26 -0
- package/dist/view/process.d.ts.map +1 -0
- package/dist/view/types.d.ts +36 -0
- package/dist/view/types.d.ts.map +1 -0
- package/dist/view.es.mjs +358 -251
- package/dist/view.es.mjs.map +1 -1
- package/dist/watch-DXXv3iAI.js +58 -0
- package/dist/watch-DXXv3iAI.js.map +1 -0
- package/package.json +14 -14
- package/src/component/component.ts +289 -0
- package/src/component/html.ts +53 -0
- package/src/component/index.ts +40 -414
- package/src/component/props.ts +116 -0
- package/src/component/types.ts +85 -0
- package/src/core/collection.ts +181 -7
- package/src/core/dom.ts +38 -0
- package/src/core/element.ts +59 -25
- package/src/core/index.ts +48 -4
- package/src/core/utils/array.ts +102 -0
- package/src/core/utils/function.ts +151 -0
- package/src/core/utils/index.ts +83 -0
- package/src/core/utils/misc.ts +82 -0
- package/src/core/utils/number.ts +78 -0
- package/src/core/utils/object.ts +206 -0
- package/src/core/utils/string.ts +112 -0
- package/src/core/utils/type-guards.ts +112 -0
- package/src/full.ts +187 -150
- package/src/index.ts +36 -36
- package/src/motion/animate.ts +113 -0
- package/src/motion/easing.ts +40 -0
- package/src/motion/flip.ts +176 -0
- package/src/motion/index.ts +41 -358
- package/src/motion/keyframes.ts +46 -0
- package/src/motion/reduced-motion.ts +17 -0
- package/src/motion/scroll.ts +57 -0
- package/src/motion/spring.ts +150 -0
- package/src/motion/stagger.ts +43 -0
- package/src/motion/timeline.ts +246 -0
- package/src/motion/transition.ts +51 -0
- package/src/motion/types.ts +198 -0
- package/src/platform/storage.ts +215 -208
- package/src/reactive/batch.ts +22 -0
- package/src/reactive/computed.ts +92 -0
- package/src/reactive/core.ts +114 -0
- package/src/reactive/effect.ts +54 -0
- package/src/reactive/index.ts +23 -22
- package/src/reactive/internals.ts +122 -0
- package/src/reactive/linked.ts +56 -0
- package/src/reactive/persisted.ts +74 -0
- package/src/reactive/readonly.ts +35 -0
- package/src/reactive/signal.ts +20 -520
- package/src/reactive/type-guards.ts +22 -0
- package/src/reactive/untrack.ts +31 -0
- package/src/reactive/watch.ts +73 -0
- package/src/router/index.ts +41 -718
- package/src/router/links.ts +130 -0
- package/src/router/match.ts +106 -0
- package/src/router/navigation.ts +71 -0
- package/src/router/query.ts +35 -0
- package/src/router/router.ts +211 -0
- package/src/router/state.ts +46 -0
- package/src/router/types.ts +93 -0
- package/src/router/utils.ts +116 -0
- package/src/security/constants.ts +209 -0
- package/src/security/csp.ts +77 -0
- package/src/security/index.ts +4 -12
- package/src/security/sanitize-core.ts +364 -0
- package/src/security/sanitize.ts +66 -625
- package/src/security/trusted-types.ts +69 -0
- package/src/security/types.ts +40 -0
- package/src/store/create-store.ts +329 -0
- package/src/store/define-store.ts +48 -0
- package/src/store/devtools.ts +45 -0
- package/src/store/index.ts +22 -848
- package/src/store/mapping.ts +73 -0
- package/src/store/persisted.ts +61 -0
- package/src/store/plugins.ts +32 -0
- package/src/store/registry.ts +51 -0
- package/src/store/types.ts +94 -0
- package/src/store/utils.ts +141 -0
- package/src/store/watch.ts +52 -0
- package/src/view/directives/bind.ts +23 -0
- package/src/view/directives/class.ts +70 -0
- package/src/view/directives/for.ts +275 -0
- package/src/view/directives/html.ts +19 -0
- package/src/view/directives/if.ts +30 -0
- package/src/view/directives/index.ts +11 -0
- package/src/view/directives/model.ts +56 -0
- package/src/view/directives/on.ts +41 -0
- package/src/view/directives/ref.ts +41 -0
- package/src/view/directives/show.ts +26 -0
- package/src/view/directives/style.ts +47 -0
- package/src/view/directives/text.ts +15 -0
- package/src/view/evaluate.ts +290 -0
- package/src/view/index.ts +112 -1041
- package/src/view/mount.ts +200 -0
- package/src/view/process.ts +92 -0
- package/src/view/types.ts +44 -0
- package/dist/core/utils.d.ts +0 -313
- package/dist/core/utils.d.ts.map +0 -1
- package/src/core/utils.ts +0 -444
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeline and sequence helpers.
|
|
3
|
+
*
|
|
4
|
+
* @module bquery/motion
|
|
5
|
+
*/
|
|
6
|
+
import type { SequenceOptions, SequenceStep, TimelineConfig, TimelineControls, TimelineStep } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Run a list of animations sequentially.
|
|
9
|
+
*
|
|
10
|
+
* @param steps - Steps to run in order
|
|
11
|
+
* @param options - Sequence configuration
|
|
12
|
+
*/
|
|
13
|
+
export declare const sequence: (steps: SequenceStep[], options?: SequenceOptions) => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Create a timeline controller for multiple animations.
|
|
16
|
+
*
|
|
17
|
+
* @param initialSteps - Steps for the timeline
|
|
18
|
+
* @param config - Timeline configuration
|
|
19
|
+
*/
|
|
20
|
+
export declare const timeline: (initialSteps?: TimelineStep[], config?: TimelineConfig) => TimelineControls;
|
|
21
|
+
//# sourceMappingURL=timeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/motion/timeline.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,YAAY,EACb,MAAM,SAAS,CAAC;AAoEjB;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GACnB,OAAO,YAAY,EAAE,EACrB,UAAS,eAAoB,KAC5B,OAAO,CAAC,IAAI,CAcd,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GACnB,eAAc,YAAY,EAAO,EACjC,SAAQ,cAAmB,KAC1B,gBAiIF,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* View transition helpers.
|
|
3
|
+
*
|
|
4
|
+
* @module bquery/motion
|
|
5
|
+
*/
|
|
6
|
+
import type { TransitionOptions } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Execute a DOM update with view transition animation.
|
|
9
|
+
* Falls back to immediate update when View Transitions API is unavailable.
|
|
10
|
+
*
|
|
11
|
+
* @param updateOrOptions - Update function or options object
|
|
12
|
+
* @returns Promise that resolves when transition completes
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* await transition(() => {
|
|
17
|
+
* $('#content').text('Updated');
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare const transition: (updateOrOptions: (() => void) | TransitionOptions) => Promise<void>;
|
|
22
|
+
//# sourceMappingURL=transition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../src/motion/transition.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAWjD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,GACrB,iBAAiB,CAAC,MAAM,IAAI,CAAC,GAAG,iBAAiB,KAChD,OAAO,CAAC,IAAI,CAiBd,CAAC"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Motion module types.
|
|
3
|
+
*
|
|
4
|
+
* @module bquery/motion
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Options for view transitions.
|
|
8
|
+
*/
|
|
9
|
+
export interface TransitionOptions {
|
|
10
|
+
/** The DOM update function to execute during transition */
|
|
11
|
+
update: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Captured element bounds for FLIP animations.
|
|
15
|
+
*/
|
|
16
|
+
export interface ElementBounds {
|
|
17
|
+
top: number;
|
|
18
|
+
left: number;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* FLIP animation configuration options.
|
|
24
|
+
*/
|
|
25
|
+
export interface FlipOptions {
|
|
26
|
+
/** Animation duration in milliseconds */
|
|
27
|
+
duration?: number;
|
|
28
|
+
/** CSS easing function */
|
|
29
|
+
easing?: string;
|
|
30
|
+
/** Callback when animation completes */
|
|
31
|
+
onComplete?: () => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Stagger delay function signature.
|
|
35
|
+
*/
|
|
36
|
+
export type StaggerFunction = (index: number, total: number) => number;
|
|
37
|
+
/**
|
|
38
|
+
* Extended options for group FLIP animations.
|
|
39
|
+
*/
|
|
40
|
+
export interface FlipGroupOptions extends FlipOptions {
|
|
41
|
+
/** Optional stagger delay function */
|
|
42
|
+
stagger?: StaggerFunction;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Spring physics configuration.
|
|
46
|
+
*/
|
|
47
|
+
export interface SpringConfig {
|
|
48
|
+
/** Spring stiffness (default: 100) */
|
|
49
|
+
stiffness?: number;
|
|
50
|
+
/** Damping coefficient (default: 10) */
|
|
51
|
+
damping?: number;
|
|
52
|
+
/** Mass of the object (default: 1) */
|
|
53
|
+
mass?: number;
|
|
54
|
+
/** Velocity threshold for completion (default: 0.01) */
|
|
55
|
+
precision?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Spring instance for animating values.
|
|
59
|
+
*/
|
|
60
|
+
export interface Spring {
|
|
61
|
+
/** Start animating to target value */
|
|
62
|
+
to(target: number): Promise<void>;
|
|
63
|
+
/** Get current animated value */
|
|
64
|
+
current(): number;
|
|
65
|
+
/** Stop the animation */
|
|
66
|
+
stop(): void;
|
|
67
|
+
/** Subscribe to value changes */
|
|
68
|
+
onChange(callback: (value: number) => void): () => void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Web Animations helper configuration.
|
|
72
|
+
*/
|
|
73
|
+
export interface AnimateOptions {
|
|
74
|
+
/** Keyframes to animate */
|
|
75
|
+
keyframes: Keyframe[] | PropertyIndexedKeyframes;
|
|
76
|
+
/** Animation options (duration, easing, etc.) */
|
|
77
|
+
options?: KeyframeAnimationOptions;
|
|
78
|
+
/** Commit final styles to the element (default: true) */
|
|
79
|
+
commitStyles?: boolean;
|
|
80
|
+
/** Respect prefers-reduced-motion (default: true) */
|
|
81
|
+
respectReducedMotion?: boolean;
|
|
82
|
+
/** Callback when animation completes */
|
|
83
|
+
onFinish?: () => void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Stagger helper configuration.
|
|
87
|
+
*/
|
|
88
|
+
export interface StaggerOptions {
|
|
89
|
+
/** Start delay in milliseconds (default: 0) */
|
|
90
|
+
start?: number;
|
|
91
|
+
/** Origin index or keyword (default: 'start') */
|
|
92
|
+
from?: 'start' | 'center' | 'end' | number;
|
|
93
|
+
/** Optional easing function for normalized distance */
|
|
94
|
+
easing?: EasingFunction;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Easing function signature.
|
|
98
|
+
*/
|
|
99
|
+
export type EasingFunction = (t: number) => number;
|
|
100
|
+
/**
|
|
101
|
+
* Sequence step configuration.
|
|
102
|
+
*/
|
|
103
|
+
export interface SequenceStep extends AnimateOptions {
|
|
104
|
+
/** Target element to animate */
|
|
105
|
+
target: Element;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Sequence run configuration.
|
|
109
|
+
*/
|
|
110
|
+
export interface SequenceOptions {
|
|
111
|
+
/** Optional stagger delay between steps */
|
|
112
|
+
stagger?: StaggerFunction;
|
|
113
|
+
/** Callback when sequence completes */
|
|
114
|
+
onFinish?: () => void;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Timeline step configuration.
|
|
118
|
+
*/
|
|
119
|
+
export interface TimelineStep {
|
|
120
|
+
/** Target element to animate */
|
|
121
|
+
target: Element;
|
|
122
|
+
/** Keyframes to animate */
|
|
123
|
+
keyframes: Keyframe[] | PropertyIndexedKeyframes;
|
|
124
|
+
/** Animation options for this step */
|
|
125
|
+
options?: KeyframeAnimationOptions;
|
|
126
|
+
/** Absolute or relative start time in milliseconds */
|
|
127
|
+
at?: number | `+=${number}` | `-=${number}`;
|
|
128
|
+
/** Optional label for debugging */
|
|
129
|
+
label?: string;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Timeline configuration.
|
|
133
|
+
*/
|
|
134
|
+
export interface TimelineConfig {
|
|
135
|
+
/** Commit final styles when timeline completes (default: true) */
|
|
136
|
+
commitStyles?: boolean;
|
|
137
|
+
/** Respect prefers-reduced-motion (default: true) */
|
|
138
|
+
respectReducedMotion?: boolean;
|
|
139
|
+
/** Callback when timeline completes */
|
|
140
|
+
onFinish?: () => void;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Timeline controls.
|
|
144
|
+
*/
|
|
145
|
+
export interface TimelineControls {
|
|
146
|
+
/** Play all steps */
|
|
147
|
+
play(): Promise<void>;
|
|
148
|
+
/** Pause animations */
|
|
149
|
+
pause(): void;
|
|
150
|
+
/** Resume animations */
|
|
151
|
+
resume(): void;
|
|
152
|
+
/** Stop and cancel animations */
|
|
153
|
+
stop(): void;
|
|
154
|
+
/** Seek to a specific time in milliseconds */
|
|
155
|
+
seek(time: number): void;
|
|
156
|
+
/** Add a step to the timeline */
|
|
157
|
+
add(step: TimelineStep): void;
|
|
158
|
+
/** Total timeline duration in milliseconds */
|
|
159
|
+
duration(): number;
|
|
160
|
+
/** Subscribe to finish events */
|
|
161
|
+
onFinish(callback: () => void): () => void;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Scroll animation configuration.
|
|
165
|
+
*/
|
|
166
|
+
export interface ScrollAnimateOptions extends AnimateOptions {
|
|
167
|
+
/** IntersectionObserver root */
|
|
168
|
+
root?: Element | Document | null;
|
|
169
|
+
/** Root margin for observer */
|
|
170
|
+
rootMargin?: string;
|
|
171
|
+
/** Intersection thresholds */
|
|
172
|
+
threshold?: number | number[];
|
|
173
|
+
/** Trigger only once (default: true) */
|
|
174
|
+
once?: boolean;
|
|
175
|
+
/** Callback when element enters the viewport */
|
|
176
|
+
onEnter?: (element: Element) => void;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Cleanup function for scroll animations.
|
|
180
|
+
*/
|
|
181
|
+
export type ScrollAnimateCleanup = () => void;
|
|
182
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/motion/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,2DAA2D;IAC3D,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED;;GAEG;AACH,MAA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? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches, $ = (t) => typeof t == "string" || typeof t == "number", v = (t) => t.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), w = (t, e) => {
|
|
2
|
+
const r = t.style;
|
|
3
|
+
if (Array.isArray(e)) {
|
|
4
|
+
const o = e[e.length - 1];
|
|
5
|
+
if (!o) return;
|
|
6
|
+
for (const [i, s] of Object.entries(o))
|
|
7
|
+
if (!(i === "offset" || i === "easing" || i === "composite") && $(s)) {
|
|
8
|
+
const a = i.startsWith("--") ? i : v(i);
|
|
9
|
+
r.setProperty(a, String(s));
|
|
10
|
+
}
|
|
5
11
|
return;
|
|
6
12
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
13
|
+
for (const [o, i] of Object.entries(e)) {
|
|
14
|
+
if (o === "offset" || o === "easing" || o === "composite") continue;
|
|
15
|
+
const s = Array.isArray(i) ? i[i.length - 1] : i;
|
|
16
|
+
if ($(s)) {
|
|
17
|
+
const a = o.startsWith("--") ? o : v(o);
|
|
18
|
+
r.setProperty(a, String(s));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}, P = (t, e) => {
|
|
22
|
+
const { keyframes: n, options: r, commitStyles: o = !0, respectReducedMotion: i = !0, onFinish: s } = e;
|
|
23
|
+
if (i && A())
|
|
24
|
+
return o && w(t, n), s?.(), Promise.resolve();
|
|
25
|
+
const a = t;
|
|
26
|
+
return typeof a.animate != "function" ? (o && w(t, n), s?.(), Promise.resolve()) : new Promise((m) => {
|
|
27
|
+
const f = a.animate(n, r);
|
|
28
|
+
let u = !1;
|
|
29
|
+
const p = () => {
|
|
30
|
+
u || (u = !0, o && (typeof f.commitStyles == "function" ? f.commitStyles() : w(t, n)), f.cancel(), s?.(), m());
|
|
31
|
+
};
|
|
32
|
+
f.onfinish = p, f.finished && f.finished.then(p).catch(p);
|
|
33
|
+
});
|
|
34
|
+
}, y = (t) => Math.min(1, Math.max(0, t)), C = (t) => y(t), D = (t) => y(t * t), T = (t) => y(1 - (1 - t) * (1 - t)), z = (t) => y(t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2), R = (t) => y(t * t * t), X = (t) => y(1 - Math.pow(1 - t, 3)), L = (t) => y(t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2), W = (t) => y(1 + 2.70158 * Math.pow(t - 1, 3) + 1.70158 * Math.pow(t - 1, 2)), Y = (t) => y(t === 1 ? 1 : 1 - Math.pow(2, -10 * t)), G = {
|
|
35
|
+
linear: C,
|
|
36
|
+
easeInQuad: D,
|
|
37
|
+
easeOutQuad: T,
|
|
38
|
+
easeInOutQuad: z,
|
|
39
|
+
easeInCubic: R,
|
|
40
|
+
easeOutCubic: X,
|
|
41
|
+
easeInOutCubic: L,
|
|
42
|
+
easeOutBack: W,
|
|
43
|
+
easeOutExpo: Y
|
|
44
|
+
}, S = (t) => {
|
|
45
|
+
const e = t.getBoundingClientRect();
|
|
10
46
|
return {
|
|
11
|
-
top:
|
|
12
|
-
left:
|
|
13
|
-
width:
|
|
14
|
-
height:
|
|
47
|
+
top: e.top,
|
|
48
|
+
left: e.left,
|
|
49
|
+
width: e.width,
|
|
50
|
+
height: e.height
|
|
15
51
|
};
|
|
16
|
-
},
|
|
17
|
-
const { duration:
|
|
18
|
-
if (
|
|
19
|
-
return Promise.resolve();
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
return Promise.resolve();
|
|
23
|
-
const
|
|
24
|
-
return
|
|
25
|
-
const
|
|
52
|
+
}, x = (t, e, n = {}) => {
|
|
53
|
+
const { duration: r = 300, easing: o = "ease-out", onComplete: i } = n, s = S(t);
|
|
54
|
+
if (s.width === 0 || s.height === 0)
|
|
55
|
+
return i?.(), Promise.resolve();
|
|
56
|
+
const a = e.left - s.left, m = e.top - s.top, f = e.width / s.width, u = e.height / s.height;
|
|
57
|
+
if (a === 0 && m === 0 && f === 1 && u === 1)
|
|
58
|
+
return i?.(), Promise.resolve();
|
|
59
|
+
const p = t;
|
|
60
|
+
return typeof p.animate != "function" ? (i?.(), Promise.resolve()) : (p.style.transform = `translate(${a}px, ${m}px) scale(${f}, ${u})`, p.style.transformOrigin = "top left", p.offsetHeight, new Promise((h) => {
|
|
61
|
+
const c = p.animate(
|
|
26
62
|
[
|
|
27
63
|
{
|
|
28
|
-
transform: `translate(${
|
|
64
|
+
transform: `translate(${a}px, ${m}px) scale(${f}, ${u})`
|
|
29
65
|
},
|
|
30
66
|
{ transform: "translate(0, 0) scale(1, 1)" }
|
|
31
67
|
],
|
|
32
|
-
{ duration:
|
|
68
|
+
{ duration: r, easing: o, fill: "forwards" }
|
|
33
69
|
);
|
|
34
|
-
d
|
|
35
|
-
|
|
70
|
+
let d = !1;
|
|
71
|
+
const l = () => {
|
|
72
|
+
d || (d = !0, p.style.transform = "", p.style.transformOrigin = "", i?.(), h());
|
|
36
73
|
};
|
|
74
|
+
c.onfinish = l, c.finished && c.finished.then(l).catch(l);
|
|
75
|
+
}));
|
|
76
|
+
}, Q = async (t, e, n = {}) => {
|
|
77
|
+
await _(t, e, n);
|
|
78
|
+
}, _ = async (t, e, n = {}) => {
|
|
79
|
+
const { stagger: r, ...o } = n, i = /* @__PURE__ */ new Map();
|
|
80
|
+
for (const m of t)
|
|
81
|
+
i.set(m, S(m));
|
|
82
|
+
e();
|
|
83
|
+
const s = t.length, a = t.map((m, f) => {
|
|
84
|
+
const u = i.get(m);
|
|
85
|
+
if (!u) return Promise.resolve();
|
|
86
|
+
const p = r ? r(f, s) : 0;
|
|
87
|
+
return p > 0 ? new Promise((h) => setTimeout(h, p)).then(
|
|
88
|
+
() => x(m, u, o)
|
|
89
|
+
) : x(m, u, o);
|
|
37
90
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
t
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
91
|
+
await Promise.all(a);
|
|
92
|
+
}, j = {
|
|
93
|
+
fadeIn: (t = 0, e = 1) => [{ opacity: t }, { opacity: e }],
|
|
94
|
+
fadeOut: (t = 1, e = 0) => [{ opacity: t }, { opacity: e }],
|
|
95
|
+
slideInUp: (t = 16) => [
|
|
96
|
+
{ opacity: 0, transform: `translateY(${t}px)` },
|
|
97
|
+
{ opacity: 1, transform: "translateY(0)" }
|
|
98
|
+
],
|
|
99
|
+
slideInDown: (t = 16) => [
|
|
100
|
+
{ opacity: 0, transform: `translateY(-${t}px)` },
|
|
101
|
+
{ opacity: 1, transform: "translateY(0)" }
|
|
102
|
+
],
|
|
103
|
+
slideInLeft: (t = 16) => [
|
|
104
|
+
{ opacity: 0, transform: `translateX(${t}px)` },
|
|
105
|
+
{ opacity: 1, transform: "translateX(0)" }
|
|
106
|
+
],
|
|
107
|
+
slideInRight: (t = 16) => [
|
|
108
|
+
{ opacity: 0, transform: `translateX(-${t}px)` },
|
|
109
|
+
{ opacity: 1, transform: "translateX(0)" }
|
|
110
|
+
],
|
|
111
|
+
scaleIn: (t = 0.95, e = 1) => [
|
|
112
|
+
{ opacity: 0, transform: `scale(${t})` },
|
|
113
|
+
{ opacity: 1, transform: `scale(${e})` }
|
|
114
|
+
],
|
|
115
|
+
scaleOut: (t = 1, e = 0.95) => [
|
|
116
|
+
{ opacity: 1, transform: `scale(${t})` },
|
|
117
|
+
{ opacity: 0, transform: `scale(${e})` }
|
|
118
|
+
],
|
|
119
|
+
pop: (t = 0.9, e = 1.02, n = 1) => [
|
|
120
|
+
{ opacity: 0, transform: `scale(${t})` },
|
|
121
|
+
{ opacity: 1, transform: `scale(${e})`, offset: 0.6 },
|
|
122
|
+
{ opacity: 1, transform: `scale(${n})` }
|
|
123
|
+
],
|
|
124
|
+
rotateIn: (t = 6) => [
|
|
125
|
+
{ opacity: 0, transform: `rotate(${t}deg) scale(0.98)` },
|
|
126
|
+
{ opacity: 1, transform: "rotate(0deg) scale(1)" }
|
|
127
|
+
]
|
|
128
|
+
}, U = (t) => typeof Element < "u" && t instanceof Element ? [t] : Array.from(t), H = (t, e) => {
|
|
129
|
+
const n = U(t);
|
|
130
|
+
if (!n.length) return () => {
|
|
131
|
+
};
|
|
132
|
+
const { root: r = null, rootMargin: o, threshold: i, once: s = !0, onEnter: a, ...m } = e;
|
|
133
|
+
if (typeof IntersectionObserver > "u")
|
|
134
|
+
return n.forEach((u) => {
|
|
135
|
+
a?.(u), P(u, m);
|
|
136
|
+
}), () => {
|
|
137
|
+
};
|
|
138
|
+
const f = new IntersectionObserver(
|
|
139
|
+
(u) => {
|
|
140
|
+
u.forEach((p) => {
|
|
141
|
+
if (!p.isIntersecting) return;
|
|
142
|
+
const h = p.target;
|
|
143
|
+
a?.(h), P(h, m), s && f.unobserve(h);
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
{ root: r, rootMargin: o, threshold: i }
|
|
147
|
+
);
|
|
148
|
+
return n.forEach((u) => f.observe(u)), () => f.disconnect();
|
|
149
|
+
}, V = {
|
|
49
150
|
stiffness: 100,
|
|
50
151
|
damping: 10,
|
|
51
152
|
mass: 1,
|
|
52
153
|
precision: 0.01
|
|
53
|
-
},
|
|
54
|
-
const { stiffness:
|
|
55
|
-
...
|
|
56
|
-
...
|
|
154
|
+
}, K = (t, e = {}) => {
|
|
155
|
+
const { stiffness: n, damping: r, mass: o, precision: i } = {
|
|
156
|
+
...V,
|
|
157
|
+
...e
|
|
57
158
|
};
|
|
58
|
-
let
|
|
59
|
-
const
|
|
60
|
-
for (const l of
|
|
61
|
-
l(
|
|
62
|
-
}, d = () => {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
159
|
+
let s = t, a = 0, m = t, f = null, u = null, p = null;
|
|
160
|
+
const h = /* @__PURE__ */ new Set(), c = () => {
|
|
161
|
+
for (const l of h)
|
|
162
|
+
l(s);
|
|
163
|
+
}, d = (l) => {
|
|
164
|
+
const g = p !== null ? (l - p) / 1e3 : 0.016666666666666666, M = Math.min(g, 1 / 30);
|
|
165
|
+
p = l;
|
|
166
|
+
const b = s - m, F = -n * b, N = -r * a, O = (F + N) / o;
|
|
167
|
+
if (a += O * M, s += a * M, c(), Math.abs(a) < i && Math.abs(b) < i) {
|
|
168
|
+
s = m, a = 0, f = null, c(), u?.(), u = null;
|
|
66
169
|
return;
|
|
67
170
|
}
|
|
68
|
-
|
|
171
|
+
f = requestAnimationFrame(d);
|
|
69
172
|
};
|
|
70
173
|
return {
|
|
71
174
|
to(l) {
|
|
72
|
-
return
|
|
73
|
-
|
|
175
|
+
return m = l, f !== null && cancelAnimationFrame(f), u?.(), p = null, new Promise((g) => {
|
|
176
|
+
u = g, f = requestAnimationFrame(d);
|
|
74
177
|
});
|
|
75
178
|
},
|
|
76
179
|
current() {
|
|
77
|
-
return
|
|
180
|
+
return s;
|
|
78
181
|
},
|
|
79
182
|
stop() {
|
|
80
|
-
|
|
183
|
+
f !== null && (cancelAnimationFrame(f), f = null), a = 0, p = null, u?.(), u = null;
|
|
81
184
|
},
|
|
82
185
|
onChange(l) {
|
|
83
|
-
return
|
|
186
|
+
return h.add(l), () => h.delete(l);
|
|
84
187
|
}
|
|
85
188
|
};
|
|
86
|
-
},
|
|
189
|
+
}, Z = {
|
|
87
190
|
/** Gentle, slow-settling spring */
|
|
88
191
|
gentle: { stiffness: 80, damping: 15 },
|
|
89
192
|
/** Responsive, snappy spring */
|
|
@@ -92,13 +195,169 @@ const $ = async (e) => {
|
|
|
92
195
|
bouncy: { stiffness: 300, damping: 8 },
|
|
93
196
|
/** Stiff, quick spring with minimal overshoot */
|
|
94
197
|
stiff: { stiffness: 400, damping: 30 }
|
|
198
|
+
}, B = (t, e = {}) => {
|
|
199
|
+
const { start: n = 0, from: r = "start", easing: o } = e;
|
|
200
|
+
return (i, s = 0) => {
|
|
201
|
+
const a = typeof r == "number" ? r : r === "center" ? (s - 1) / 2 : r === "end" ? s - 1 : 0, m = Math.abs(i - a), f = s > 1 ? Math.max(a, s - 1 - a) : 1, u = f === 0 ? 0 : m / f, p = o ? o(u) * f : m;
|
|
202
|
+
return n + p * t;
|
|
203
|
+
};
|
|
204
|
+
}, E = (t) => {
|
|
205
|
+
if (typeof t == "number") return t;
|
|
206
|
+
if (typeof t == "string") {
|
|
207
|
+
const e = t.trim();
|
|
208
|
+
if (e.endsWith("ms")) {
|
|
209
|
+
const r = Number.parseFloat(e.slice(0, -2));
|
|
210
|
+
return Number.isFinite(r) ? r : 0;
|
|
211
|
+
}
|
|
212
|
+
if (e.endsWith("s")) {
|
|
213
|
+
const r = Number.parseFloat(e.slice(0, -1));
|
|
214
|
+
return Number.isFinite(r) ? r * 1e3 : 0;
|
|
215
|
+
}
|
|
216
|
+
const n = Number.parseFloat(e);
|
|
217
|
+
return Number.isFinite(n) ? n : 0;
|
|
218
|
+
}
|
|
219
|
+
return 0;
|
|
220
|
+
}, k = (t, e) => {
|
|
221
|
+
if (typeof t == "number") return t;
|
|
222
|
+
if (typeof t == "string") {
|
|
223
|
+
const n = /^([+-])=(\d+(?:\.\d+)?)$/.exec(t);
|
|
224
|
+
if (n) {
|
|
225
|
+
const r = Number.parseFloat(n[2]);
|
|
226
|
+
return Number.isFinite(r) ? n[1] === "+" ? e + r : e - r : e;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return e;
|
|
230
|
+
}, q = (t) => {
|
|
231
|
+
const e = E(t?.duration), n = E(t?.endDelay), r = t?.iterations ?? 1;
|
|
232
|
+
if (r === 1 / 0)
|
|
233
|
+
return Number.MAX_SAFE_INTEGER;
|
|
234
|
+
const o = Math.max(0, r);
|
|
235
|
+
return e * o + n;
|
|
236
|
+
}, I = (t) => {
|
|
237
|
+
let e = 0;
|
|
238
|
+
return t.map((n) => {
|
|
239
|
+
const r = k(n.at, e), o = E(n.options?.delay), i = Math.max(0, r + o), s = q(n.options), a = i + s;
|
|
240
|
+
return e = Math.max(e, a), { step: n, start: i, end: a, duration: s };
|
|
241
|
+
});
|
|
242
|
+
}, J = async (t, e = {}) => {
|
|
243
|
+
const { stagger: n, onFinish: r } = e, o = t.length;
|
|
244
|
+
for (let i = 0; i < t.length; i += 1) {
|
|
245
|
+
const s = t[i], a = n ? n(i, o) : 0;
|
|
246
|
+
a > 0 && await new Promise((m) => setTimeout(m, a)), await P(s.target, s);
|
|
247
|
+
}
|
|
248
|
+
r?.();
|
|
249
|
+
}, tt = (t = [], e = {}) => {
|
|
250
|
+
const n = [...t], r = /* @__PURE__ */ new Set();
|
|
251
|
+
let o = [], i = 0, s = !1, a = !1;
|
|
252
|
+
const { commitStyles: m = !0, respectReducedMotion: f = !0, onFinish: u } = e, p = () => {
|
|
253
|
+
if (!a) {
|
|
254
|
+
if (a = !0, m)
|
|
255
|
+
for (const c of o) {
|
|
256
|
+
const { animation: d, step: l } = c;
|
|
257
|
+
typeof d.commitStyles == "function" ? d.commitStyles() : w(l.target, l.keyframes), d.cancel();
|
|
258
|
+
}
|
|
259
|
+
r.forEach((c) => c()), u?.();
|
|
260
|
+
}
|
|
261
|
+
}, h = () => {
|
|
262
|
+
o.forEach(({ animation: l }) => l.cancel()), o = [], a = !1;
|
|
263
|
+
const c = I(n);
|
|
264
|
+
if (i = c.length ? Math.max(...c.map((l) => l.end)) : 0, f && A()) {
|
|
265
|
+
m && c.forEach(({ step: l }) => w(l.target, l.keyframes)), s = !0;
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (c.some(
|
|
269
|
+
({ step: l }) => typeof l.target.animate != "function"
|
|
270
|
+
)) {
|
|
271
|
+
m && c.forEach(({ step: l }) => w(l.target, l.keyframes)), s = !0;
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
s = !1, o = c.map(({ step: l, start: g }) => {
|
|
275
|
+
const { delay: M, ...b } = l.options ?? {};
|
|
276
|
+
return { animation: l.target.animate(l.keyframes, {
|
|
277
|
+
...b,
|
|
278
|
+
delay: g,
|
|
279
|
+
fill: b.fill ?? "both"
|
|
280
|
+
}), step: l, start: g };
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
return {
|
|
284
|
+
add(c) {
|
|
285
|
+
n.push(c);
|
|
286
|
+
},
|
|
287
|
+
duration() {
|
|
288
|
+
if (!n.length) return 0;
|
|
289
|
+
if (!o.length) {
|
|
290
|
+
const c = I(n);
|
|
291
|
+
return Math.max(...c.map((d) => d.end));
|
|
292
|
+
}
|
|
293
|
+
return i;
|
|
294
|
+
},
|
|
295
|
+
async play() {
|
|
296
|
+
if (h(), s || o.length === 0) {
|
|
297
|
+
p();
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const c = o.map(
|
|
301
|
+
(d) => d.animation.finished.catch(() => {
|
|
302
|
+
})
|
|
303
|
+
);
|
|
304
|
+
await Promise.all(c), p();
|
|
305
|
+
},
|
|
306
|
+
pause() {
|
|
307
|
+
s || o.forEach(({ animation: c }) => c.pause());
|
|
308
|
+
},
|
|
309
|
+
resume() {
|
|
310
|
+
s || o.forEach(({ animation: c }) => c.play());
|
|
311
|
+
},
|
|
312
|
+
stop() {
|
|
313
|
+
o.forEach(({ animation: c }) => c.cancel()), o = [], s = !1;
|
|
314
|
+
},
|
|
315
|
+
seek(c) {
|
|
316
|
+
s || o.forEach(({ animation: d }) => {
|
|
317
|
+
d.currentTime = c;
|
|
318
|
+
});
|
|
319
|
+
},
|
|
320
|
+
onFinish(c) {
|
|
321
|
+
return r.add(c), () => r.delete(c);
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
}, et = async (t) => {
|
|
325
|
+
const e = typeof t == "function" ? t : t.update;
|
|
326
|
+
if (typeof document > "u") {
|
|
327
|
+
e();
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
const n = document;
|
|
331
|
+
if (n.startViewTransition) {
|
|
332
|
+
await n.startViewTransition(() => e()).finished;
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
e();
|
|
95
336
|
};
|
|
96
337
|
export {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
338
|
+
P as animate,
|
|
339
|
+
S as capturePosition,
|
|
340
|
+
R as easeInCubic,
|
|
341
|
+
L as easeInOutCubic,
|
|
342
|
+
z as easeInOutQuad,
|
|
343
|
+
D as easeInQuad,
|
|
344
|
+
W as easeOutBack,
|
|
345
|
+
X as easeOutCubic,
|
|
346
|
+
Y as easeOutExpo,
|
|
347
|
+
T as easeOutQuad,
|
|
348
|
+
G as easingPresets,
|
|
349
|
+
x as flip,
|
|
350
|
+
_ as flipElements,
|
|
351
|
+
Q as flipList,
|
|
352
|
+
j as keyframePresets,
|
|
353
|
+
C as linear,
|
|
354
|
+
A as prefersReducedMotion,
|
|
355
|
+
H as scrollAnimate,
|
|
356
|
+
J as sequence,
|
|
357
|
+
K as spring,
|
|
358
|
+
Z as springPresets,
|
|
359
|
+
B as stagger,
|
|
360
|
+
tt as timeline,
|
|
361
|
+
et as transition
|
|
103
362
|
};
|
|
104
363
|
//# sourceMappingURL=motion.es.mjs.map
|