@motion.page/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +817 -0
- package/dist/core/Animation.d.ts +230 -0
- package/dist/core/AnimationBuilder.d.ts +125 -0
- package/dist/core/Engine.d.ts +140 -0
- package/dist/core/Motion.d.ts +56 -0
- package/dist/core/PropTween.d.ts +81 -0
- package/dist/core/Ticker.d.ts +107 -0
- package/dist/core/Timeline.d.ts +294 -0
- package/dist/easing/index.d.ts +65 -0
- package/dist/fit/FitResolver.d.ts +12 -0
- package/dist/index.cjs +34 -0
- package/dist/index.cjs.map +52 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +52 -0
- package/dist/memory/AnimationPool.d.ts +14 -0
- package/dist/memory/ObjectPool.d.ts +37 -0
- package/dist/memory/PropTweenPool.d.ts +14 -0
- package/dist/registries/SDKRegistry.d.ts +69 -0
- package/dist/render/CSSRenderer.d.ts +33 -0
- package/dist/render/PathRenderer.d.ts +24 -0
- package/dist/render/RenderBatch.d.ts +27 -0
- package/dist/render/TransformCache.d.ts +54 -0
- package/dist/stagger/StaggerResolver.d.ts +28 -0
- package/dist/triggers/BaseTrigger.d.ts +61 -0
- package/dist/triggers/CursorTrigger.d.ts +86 -0
- package/dist/triggers/EventTrigger.d.ts +48 -0
- package/dist/triggers/GestureTrigger.d.ts +137 -0
- package/dist/triggers/MarkerManager.d.ts +42 -0
- package/dist/triggers/MouseMoveTrigger.d.ts +49 -0
- package/dist/triggers/PageExitTrigger.d.ts +74 -0
- package/dist/triggers/PageLoadTrigger.d.ts +37 -0
- package/dist/triggers/PinManager.d.ts +131 -0
- package/dist/triggers/ScrollTrigger.d.ts +103 -0
- package/dist/triggers/TriggerManager.d.ts +133 -0
- package/dist/types/index.d.ts +355 -0
- package/dist/types/public.d.ts +7 -0
- package/dist/utils/ColorParser.d.ts +23 -0
- package/dist/utils/DrawSVGParser.d.ts +62 -0
- package/dist/utils/FilterParser.d.ts +49 -0
- package/dist/utils/MotionUtils.d.ts +136 -0
- package/dist/utils/PathParser.d.ts +89 -0
- package/dist/utils/PositionParser.d.ts +24 -0
- package/dist/utils/PropertyParser.d.ts +159 -0
- package/dist/utils/QuickSetter.d.ts +16 -0
- package/dist/utils/ScrollPositionParser.d.ts +19 -0
- package/dist/utils/StyleReset.d.ts +73 -0
- package/dist/utils/TargetResolver.d.ts +23 -0
- package/dist/utils/TextSplitter.d.ts +90 -0
- package/dist/utils/executeTimelineAction.d.ts +18 -0
- package/dist/utils/getLayoutRect.d.ts +10 -0
- package/package.json +56 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Animation - Individual animation unit
|
|
3
|
+
*
|
|
4
|
+
* Manages interpolation of properties over time with easing.
|
|
5
|
+
* Pooled for performance.
|
|
6
|
+
*/
|
|
7
|
+
import type { AnimationTarget, StaggerVars } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Internal animation configuration (not exported from SDK)
|
|
10
|
+
*/
|
|
11
|
+
export interface InternalAnimationConfig {
|
|
12
|
+
repeat?: number;
|
|
13
|
+
repeatDelay?: number;
|
|
14
|
+
yoyo?: boolean;
|
|
15
|
+
stagger?: number | StaggerVars;
|
|
16
|
+
onStart?: () => void;
|
|
17
|
+
onUpdate?: (progress: number) => void;
|
|
18
|
+
onComplete?: () => void;
|
|
19
|
+
onRepeat?: (repeatCount: number) => void;
|
|
20
|
+
onReverseComplete?: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* When true, Engine skips the immediate render(0) for FROM animations.
|
|
23
|
+
* Used by Timeline._addBuilder so it can capture initial values BEFORE
|
|
24
|
+
* FROM values are applied to the DOM, then render FROM itself afterward.
|
|
25
|
+
*/
|
|
26
|
+
_skipInitialRender?: boolean;
|
|
27
|
+
}
|
|
28
|
+
import { PropTween } from './PropTween';
|
|
29
|
+
import { PropTweenPool } from '../memory/PropTweenPool';
|
|
30
|
+
export declare class Animation {
|
|
31
|
+
private _id;
|
|
32
|
+
private _targets;
|
|
33
|
+
private _duration;
|
|
34
|
+
private _delay;
|
|
35
|
+
private _time;
|
|
36
|
+
private _progress;
|
|
37
|
+
private _timeScale;
|
|
38
|
+
private _isActive;
|
|
39
|
+
private _isReversed;
|
|
40
|
+
private _propTweens;
|
|
41
|
+
private _lastPropTween;
|
|
42
|
+
private _easingFn;
|
|
43
|
+
private _repeat;
|
|
44
|
+
private _repeatDelay;
|
|
45
|
+
private _yoyo;
|
|
46
|
+
private _currentRepeat;
|
|
47
|
+
private _onStart?;
|
|
48
|
+
private _onUpdate?;
|
|
49
|
+
private _onComplete?;
|
|
50
|
+
private _onRepeat?;
|
|
51
|
+
private _onReverseComplete?;
|
|
52
|
+
private _startFired;
|
|
53
|
+
private _completeFired;
|
|
54
|
+
private _timelineChild;
|
|
55
|
+
private _needsStartCapture;
|
|
56
|
+
private _startCaptured;
|
|
57
|
+
private _fitSetupFn;
|
|
58
|
+
private _pendingFitSetup;
|
|
59
|
+
private _unregisterCallback;
|
|
60
|
+
/**
|
|
61
|
+
* Initialize the animation
|
|
62
|
+
*/
|
|
63
|
+
init(id: number, targets: AnimationTarget[], duration: number, delay: number, ease: string, config?: InternalAnimationConfig): this;
|
|
64
|
+
/**
|
|
65
|
+
* Update animation by delta time
|
|
66
|
+
*/
|
|
67
|
+
update(deltaTime: number): void;
|
|
68
|
+
/**
|
|
69
|
+
* Render animation at specific progress (0-1)
|
|
70
|
+
*/
|
|
71
|
+
render(progress: number): void;
|
|
72
|
+
/**
|
|
73
|
+
* Render animation at an absolute time position (seconds)
|
|
74
|
+
* Handles repeat, repeatDelay, and yoyo for timeline-driven scrubbing.
|
|
75
|
+
* When driven by a Timeline (_isActive = true), also fires lifecycle callbacks.
|
|
76
|
+
*/
|
|
77
|
+
renderAtTime(totalTime: number): void;
|
|
78
|
+
/**
|
|
79
|
+
* Apply easing function to progress
|
|
80
|
+
*/
|
|
81
|
+
private applyEasing;
|
|
82
|
+
/**
|
|
83
|
+
* Handle animation completion
|
|
84
|
+
*/
|
|
85
|
+
private handleComplete;
|
|
86
|
+
/**
|
|
87
|
+
* Play the animation
|
|
88
|
+
* - If already playing forward, does nothing
|
|
89
|
+
* - If paused, resumes from current position
|
|
90
|
+
*/
|
|
91
|
+
play(from?: number): this;
|
|
92
|
+
/**
|
|
93
|
+
* Pause the animation
|
|
94
|
+
*/
|
|
95
|
+
pause(atTime?: number): this;
|
|
96
|
+
/**
|
|
97
|
+
* Reverse the animation
|
|
98
|
+
*/
|
|
99
|
+
reverse(from?: number): this;
|
|
100
|
+
/**
|
|
101
|
+
* Restart the animation
|
|
102
|
+
*/
|
|
103
|
+
restart(includeDelay?: boolean): this;
|
|
104
|
+
/**
|
|
105
|
+
* Seek to specific position
|
|
106
|
+
*/
|
|
107
|
+
seek(position: number): this;
|
|
108
|
+
/**
|
|
109
|
+
* Get/set progress (0-1)
|
|
110
|
+
*/
|
|
111
|
+
progress(): number;
|
|
112
|
+
progress(value: number): this;
|
|
113
|
+
/**
|
|
114
|
+
* Get/set time in seconds
|
|
115
|
+
*/
|
|
116
|
+
time(): number;
|
|
117
|
+
time(value: number): this;
|
|
118
|
+
/**
|
|
119
|
+
* Get/set timeScale multiplier
|
|
120
|
+
*/
|
|
121
|
+
timeScale(): number;
|
|
122
|
+
timeScale(value: number): this;
|
|
123
|
+
/**
|
|
124
|
+
* Get timeScale multiplier (typed getter)
|
|
125
|
+
*/
|
|
126
|
+
getTimeScale(): number;
|
|
127
|
+
/**
|
|
128
|
+
* Kill the animation
|
|
129
|
+
*/
|
|
130
|
+
kill(): void;
|
|
131
|
+
/**
|
|
132
|
+
* Check if animation is active
|
|
133
|
+
*/
|
|
134
|
+
isActive(): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Check if this animation is a child of a Timeline
|
|
137
|
+
* When true, Engine won't update or auto-pool this animation
|
|
138
|
+
*/
|
|
139
|
+
isTimelineChild(): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Set whether this animation is a child of a Timeline
|
|
142
|
+
* Timeline children are controlled by their parent timeline and
|
|
143
|
+
* won't be auto-pooled until the timeline is killed
|
|
144
|
+
*/
|
|
145
|
+
setTimelineChild(isChild: boolean): void;
|
|
146
|
+
/**
|
|
147
|
+
* Enable lazy start value capture (for timeline chaining)
|
|
148
|
+
* When enabled, start values are captured on first render instead of at creation
|
|
149
|
+
*/
|
|
150
|
+
setLazyStartCapture(enabled: boolean): void;
|
|
151
|
+
/**
|
|
152
|
+
* Register a Fit setup function to execute at play time.
|
|
153
|
+
* Stores both a persistent copy (_fitSetupFn) for replay and an active
|
|
154
|
+
* copy (_pendingFitSetup) that is consumed by captureStartValues().
|
|
155
|
+
*/
|
|
156
|
+
setPendingFitSetup(fn: (pool: typeof PropTweenPool) => void): void;
|
|
157
|
+
/**
|
|
158
|
+
* Reset for timeline replay
|
|
159
|
+
* Resets callback state for clean replay but KEEPS captured start values
|
|
160
|
+
* so TO-only animations replay from their original start position.
|
|
161
|
+
* Fit animations re-enable their setup so geometry is re-captured on the
|
|
162
|
+
* next play (picking up any intervening DOM changes).
|
|
163
|
+
*/
|
|
164
|
+
resetForReplay(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Check if this animation needs lazy start capture but hasn't captured yet
|
|
167
|
+
* Used by Timeline to trigger capture when animation starts
|
|
168
|
+
*/
|
|
169
|
+
needsStartCapture(): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Check if this animation uses lazy start capture (TO-only animation)
|
|
172
|
+
* These animations should NEVER render before their start time,
|
|
173
|
+
* even after values have been captured, to avoid overwriting earlier animations
|
|
174
|
+
*/
|
|
175
|
+
isLazyCapture(): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Fire the onReverseComplete callback and reset start/complete flags.
|
|
178
|
+
* Called by Timeline when an active animation exits the start boundary (going in reverse).
|
|
179
|
+
* Resetting flags allows onStart and onComplete to fire correctly on the next forward play.
|
|
180
|
+
*/
|
|
181
|
+
fireReverseComplete(): void;
|
|
182
|
+
/**
|
|
183
|
+
* Set callback for unregistering from Engine (called on kill)
|
|
184
|
+
* This avoids circular dependency with Engine
|
|
185
|
+
*/
|
|
186
|
+
setUnregisterCallback(callback: () => void): void;
|
|
187
|
+
/**
|
|
188
|
+
* Capture current element values as start values for all PropTweens
|
|
189
|
+
* This enables proper chaining in timelines
|
|
190
|
+
*/
|
|
191
|
+
captureStartValues(): void;
|
|
192
|
+
/**
|
|
193
|
+
* Get animation ID
|
|
194
|
+
*/
|
|
195
|
+
getId(): number;
|
|
196
|
+
/**
|
|
197
|
+
* Get animation targets
|
|
198
|
+
*/
|
|
199
|
+
getTargets(): AnimationTarget[];
|
|
200
|
+
/**
|
|
201
|
+
* Get duration
|
|
202
|
+
*/
|
|
203
|
+
getDuration(): number;
|
|
204
|
+
/**
|
|
205
|
+
* Get delay (used by Timeline for stagger positioning)
|
|
206
|
+
*/
|
|
207
|
+
getDelay(): number;
|
|
208
|
+
/**
|
|
209
|
+
* Clear delay (used by Timeline after extracting delay for positioning)
|
|
210
|
+
*/
|
|
211
|
+
clearDelay(): void;
|
|
212
|
+
/**
|
|
213
|
+
* Get the head of the PropTween linked list.
|
|
214
|
+
* @internal - Use only within sdk package for property inspection (e.g. captureStartValues).
|
|
215
|
+
*/
|
|
216
|
+
getFirstPropTween(): PropTween | null;
|
|
217
|
+
/**
|
|
218
|
+
* Add a property tween to the linked list
|
|
219
|
+
*/
|
|
220
|
+
addPropTween(propTween: PropTween): void;
|
|
221
|
+
/**
|
|
222
|
+
* Get animation duration (including delay and repeats)
|
|
223
|
+
* Returns Infinity for infinitely repeating animations (_repeat === -1).
|
|
224
|
+
*/
|
|
225
|
+
totalDuration(): number;
|
|
226
|
+
/**
|
|
227
|
+
* Reset for object pooling
|
|
228
|
+
*/
|
|
229
|
+
reset(): void;
|
|
230
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AnimationBuilder - Config-based animation creator
|
|
3
|
+
*
|
|
4
|
+
* Creates animations from configuration objects.
|
|
5
|
+
* Used internally by Motion() function.
|
|
6
|
+
*/
|
|
7
|
+
import type { AnimationVars, AnimationTarget, TargetInput, StaggerVars, SplitType, AnimationConfig, FitConfig } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Internal builder configuration for cloning (not exported from SDK)
|
|
10
|
+
*/
|
|
11
|
+
interface BuilderConfig {
|
|
12
|
+
fromVars?: AnimationVars;
|
|
13
|
+
toVars?: AnimationVars;
|
|
14
|
+
duration: number;
|
|
15
|
+
delay: number;
|
|
16
|
+
ease: string;
|
|
17
|
+
axis?: 'x' | 'y';
|
|
18
|
+
fit?: FitConfig;
|
|
19
|
+
split?: SplitType;
|
|
20
|
+
mask?: boolean;
|
|
21
|
+
stagger?: number | StaggerVars;
|
|
22
|
+
repeat?: number;
|
|
23
|
+
repeatDelay?: number;
|
|
24
|
+
yoyo?: boolean;
|
|
25
|
+
onStart?: () => void;
|
|
26
|
+
onUpdate?: (progress: number) => void;
|
|
27
|
+
onComplete?: () => void;
|
|
28
|
+
onRepeat?: (repeatCount: number) => void;
|
|
29
|
+
onReverseComplete?: () => void;
|
|
30
|
+
}
|
|
31
|
+
import { Animation } from './Animation';
|
|
32
|
+
export declare class AnimationBuilder {
|
|
33
|
+
/**
|
|
34
|
+
* Callback to create animations via Engine (set by Engine to avoid circular dependency)
|
|
35
|
+
* Engine→Timeline→AnimationBuilder→Engine cycle is broken by this callback.
|
|
36
|
+
*/
|
|
37
|
+
private static _createAnimationCallback;
|
|
38
|
+
static setCreateAnimationCallback(callback: typeof AnimationBuilder._createAnimationCallback): void;
|
|
39
|
+
private _targets;
|
|
40
|
+
private _originalTargets;
|
|
41
|
+
private _fromVars?;
|
|
42
|
+
private _toVars?;
|
|
43
|
+
private _duration;
|
|
44
|
+
private _delay;
|
|
45
|
+
private _ease;
|
|
46
|
+
private _animation;
|
|
47
|
+
private _animations;
|
|
48
|
+
private _built;
|
|
49
|
+
private _splitType?;
|
|
50
|
+
private _mask?;
|
|
51
|
+
private _repeat?;
|
|
52
|
+
private _repeatDelay?;
|
|
53
|
+
private _yoyo?;
|
|
54
|
+
private _stagger?;
|
|
55
|
+
private _axis?;
|
|
56
|
+
private _fitConfig?;
|
|
57
|
+
private _onStart?;
|
|
58
|
+
private _onUpdate?;
|
|
59
|
+
private _onComplete?;
|
|
60
|
+
private _onRepeat?;
|
|
61
|
+
private _onReverseComplete?;
|
|
62
|
+
private _skipInitialFromRender;
|
|
63
|
+
private _plainObjectInitialValues;
|
|
64
|
+
private _expectedAnimationIds;
|
|
65
|
+
private _propsToAnimate;
|
|
66
|
+
/**
|
|
67
|
+
* Create an animation builder
|
|
68
|
+
* @param targets - Elements or objects to animate
|
|
69
|
+
* @param config - Animation configuration
|
|
70
|
+
*/
|
|
71
|
+
constructor(targets: TargetInput, config?: AnimationConfig);
|
|
72
|
+
/**
|
|
73
|
+
* Apply animation config
|
|
74
|
+
*/
|
|
75
|
+
private _applyAnimationConfig;
|
|
76
|
+
/**
|
|
77
|
+
* Capture initial values from plain object targets
|
|
78
|
+
*/
|
|
79
|
+
private _capturePlainObjectValues;
|
|
80
|
+
/**
|
|
81
|
+
* Restore plain object targets to initial values
|
|
82
|
+
*/
|
|
83
|
+
private _restorePlainObjectValues;
|
|
84
|
+
private _ensureBuilt;
|
|
85
|
+
/**
|
|
86
|
+
* Check if animations have been invalidated (pooled or reused)
|
|
87
|
+
*/
|
|
88
|
+
private _isInvalidated;
|
|
89
|
+
/**
|
|
90
|
+
* Rebuild if animations were pooled
|
|
91
|
+
*/
|
|
92
|
+
rebuildIfPooled(): void;
|
|
93
|
+
private _build;
|
|
94
|
+
getAnimation(): Animation | null;
|
|
95
|
+
getAnimations(): Animation[];
|
|
96
|
+
getTargets(): AnimationTarget[];
|
|
97
|
+
/**
|
|
98
|
+
* Get the original (pre-split) targets. When text splitting is used,
|
|
99
|
+
* _targets holds the split fragments; _originalTargets holds the source elements.
|
|
100
|
+
*/
|
|
101
|
+
getOriginalTargets(): AnimationTarget[];
|
|
102
|
+
/**
|
|
103
|
+
* Whether this builder uses text splitting
|
|
104
|
+
*/
|
|
105
|
+
hasSplit(): boolean;
|
|
106
|
+
private _resetBuildState;
|
|
107
|
+
/**
|
|
108
|
+
* Get builder configuration for cloning (used by Timeline's each mode)
|
|
109
|
+
*/
|
|
110
|
+
getConfig(): BuilderConfig;
|
|
111
|
+
/**
|
|
112
|
+
* Set axis for mouse movement binding
|
|
113
|
+
*/
|
|
114
|
+
setAxis(axis: 'x' | 'y'): void;
|
|
115
|
+
/**
|
|
116
|
+
* Get axis binding
|
|
117
|
+
*/
|
|
118
|
+
getAxis(): 'x' | 'y' | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Tell Engine to skip the immediate FROM render (animation.render(0)).
|
|
121
|
+
* Used by Timeline so it can capture initial values BEFORE FROM is applied.
|
|
122
|
+
*/
|
|
123
|
+
setSkipInitialFromRender(skip: boolean): void;
|
|
124
|
+
}
|
|
125
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine Singleton - Central animation registry and coordinator
|
|
3
|
+
*
|
|
4
|
+
* Manages:
|
|
5
|
+
* - Global animation registry
|
|
6
|
+
* - Named timeline registry
|
|
7
|
+
* - Object pool coordination
|
|
8
|
+
* - Ticker integration
|
|
9
|
+
* - Render queue routing
|
|
10
|
+
*/
|
|
11
|
+
import { Ticker } from './Ticker';
|
|
12
|
+
import { Animation } from './Animation';
|
|
13
|
+
import { Timeline } from './Timeline';
|
|
14
|
+
import { AnimationPool } from '../memory/AnimationPool';
|
|
15
|
+
import { PropTweenPool } from '../memory/PropTweenPool';
|
|
16
|
+
import type { AnimationVars, AnimationTarget } from '../types';
|
|
17
|
+
import type { InternalAnimationConfig } from './Animation';
|
|
18
|
+
export declare class Engine {
|
|
19
|
+
private static instance;
|
|
20
|
+
private animations;
|
|
21
|
+
private animationIdToIndex;
|
|
22
|
+
private nextAnimationId;
|
|
23
|
+
private totalCreated;
|
|
24
|
+
private _animationSnapshot;
|
|
25
|
+
private timelines;
|
|
26
|
+
private ticker;
|
|
27
|
+
private animationPool;
|
|
28
|
+
private propTweenPool;
|
|
29
|
+
private constructor();
|
|
30
|
+
/**
|
|
31
|
+
* Get the singleton Engine instance
|
|
32
|
+
*/
|
|
33
|
+
static getInstance(): Engine;
|
|
34
|
+
/**
|
|
35
|
+
* Main update loop called by Ticker
|
|
36
|
+
*/
|
|
37
|
+
private update;
|
|
38
|
+
/**
|
|
39
|
+
* Create a new animation (called by AnimationBuilder)
|
|
40
|
+
* Returns either a single Animation or an array of Animations (for stagger)
|
|
41
|
+
*/
|
|
42
|
+
createAnimation(targets: AnimationTarget[], vars: AnimationVars, duration: number, delay: number, ease: string, isFrom: boolean, fromVars?: AnimationVars, config?: InternalAnimationConfig): Animation | Animation[];
|
|
43
|
+
/**
|
|
44
|
+
* Create staggered animations - one animation per target
|
|
45
|
+
*/
|
|
46
|
+
private createStaggeredAnimations;
|
|
47
|
+
/**
|
|
48
|
+
* Set up property tweens for an animation
|
|
49
|
+
*/
|
|
50
|
+
private setupPropertyTweens;
|
|
51
|
+
/**
|
|
52
|
+
* Register an animation with the engine
|
|
53
|
+
*/
|
|
54
|
+
registerAnimation(animation: Animation): number;
|
|
55
|
+
/**
|
|
56
|
+
* Unregister an animation from the engine
|
|
57
|
+
* Uses swap-and-pop for O(1) removal
|
|
58
|
+
*/
|
|
59
|
+
unregisterAnimation(id: number): void;
|
|
60
|
+
/**
|
|
61
|
+
* Get an animation by ID
|
|
62
|
+
*/
|
|
63
|
+
getAnimation(id: number): Animation | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Kill all animations
|
|
66
|
+
*/
|
|
67
|
+
killAll(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Kill all animations targeting specific elements
|
|
70
|
+
* Used by Motion.reset() to stop animations before clearing styles
|
|
71
|
+
*/
|
|
72
|
+
killAnimationsForTargets(targets: Element[]): void;
|
|
73
|
+
/**
|
|
74
|
+
* Get active animation count
|
|
75
|
+
*/
|
|
76
|
+
getActiveCount(): number;
|
|
77
|
+
/**
|
|
78
|
+
* Get total animations created
|
|
79
|
+
*/
|
|
80
|
+
getTotalCreated(): number;
|
|
81
|
+
/**
|
|
82
|
+
* Get or create a named timeline
|
|
83
|
+
*/
|
|
84
|
+
getTimeline(name: string): Timeline;
|
|
85
|
+
/**
|
|
86
|
+
* Check if timeline exists
|
|
87
|
+
*/
|
|
88
|
+
hasTimeline(name: string): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Register a timeline
|
|
91
|
+
*/
|
|
92
|
+
registerTimeline(name: string, timeline: Timeline): void;
|
|
93
|
+
/**
|
|
94
|
+
* Get timeline count
|
|
95
|
+
*/
|
|
96
|
+
getTimelineCount(): number;
|
|
97
|
+
/**
|
|
98
|
+
* Get all timeline names
|
|
99
|
+
*/
|
|
100
|
+
getTimelineNames(): string[];
|
|
101
|
+
/**
|
|
102
|
+
* Remove a timeline from registry (called after kill)
|
|
103
|
+
*/
|
|
104
|
+
removeTimeline(name: string): void;
|
|
105
|
+
/**
|
|
106
|
+
* Kill all timelines and their triggers
|
|
107
|
+
*/
|
|
108
|
+
killAllTimelines(): void;
|
|
109
|
+
/**
|
|
110
|
+
* Kill everything - all animations, all timelines, and cleanup resources
|
|
111
|
+
*/
|
|
112
|
+
killEverything(): void;
|
|
113
|
+
/**
|
|
114
|
+
* Get animation pool
|
|
115
|
+
*/
|
|
116
|
+
getAnimationPool(): AnimationPool;
|
|
117
|
+
/**
|
|
118
|
+
* Get PropTween pool
|
|
119
|
+
*/
|
|
120
|
+
getPropTweenPool(): PropTweenPool;
|
|
121
|
+
/**
|
|
122
|
+
* Get pool statistics
|
|
123
|
+
*/
|
|
124
|
+
getPoolStats(): {
|
|
125
|
+
animations: number;
|
|
126
|
+
propTweens: number;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Clear all pools (for debugging)
|
|
130
|
+
*/
|
|
131
|
+
clearPools(): void;
|
|
132
|
+
/**
|
|
133
|
+
* Get memory estimate in bytes
|
|
134
|
+
*/
|
|
135
|
+
getMemoryEstimate(): number;
|
|
136
|
+
/**
|
|
137
|
+
* Get ticker reference
|
|
138
|
+
*/
|
|
139
|
+
getTicker(): Ticker;
|
|
140
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Motion API - Unified entry point for animations
|
|
3
|
+
*
|
|
4
|
+
* All animations are named timelines. Config-based API for consistency.
|
|
5
|
+
*
|
|
6
|
+
* @example Single animation
|
|
7
|
+
* Motion('fadeIn', '.box', {
|
|
8
|
+
* from: { opacity: 0 },
|
|
9
|
+
* to: { opacity: 1 },
|
|
10
|
+
* duration: 0.5
|
|
11
|
+
* }).play()
|
|
12
|
+
*
|
|
13
|
+
* @example Multi-animation timeline
|
|
14
|
+
* Motion('hero', [
|
|
15
|
+
* { target: '.title', from: { y: 50 }, to: { y: 0 }, duration: 1 },
|
|
16
|
+
* { target: '.subtitle', from: { opacity: 0 }, to: { opacity: 1 }, position: 0.5 }
|
|
17
|
+
* ]).play()
|
|
18
|
+
*
|
|
19
|
+
* @example With trigger
|
|
20
|
+
* Motion('scroll', '.box', { from: { x: -100 }, to: { x: 0 } })
|
|
21
|
+
* .onScroll({ scrub: true })
|
|
22
|
+
*
|
|
23
|
+
* @example Replay
|
|
24
|
+
* Motion('fadeIn').play()
|
|
25
|
+
*/
|
|
26
|
+
import type { TargetInput, AnimationConfig, AnimationEntry, AnimationVars } from '../types';
|
|
27
|
+
import { Timeline } from './Timeline';
|
|
28
|
+
/**
|
|
29
|
+
* Motion function overloads
|
|
30
|
+
*/
|
|
31
|
+
declare function MotionFunction(name: string): Timeline;
|
|
32
|
+
declare function MotionFunction(name: string, target: TargetInput, config: AnimationConfig): Timeline;
|
|
33
|
+
declare function MotionFunction(name: string, animations: AnimationEntry[]): Timeline;
|
|
34
|
+
declare namespace MotionFunction {
|
|
35
|
+
var reset: (targets: TargetInput) => void;
|
|
36
|
+
var set: (target: TargetInput, vars: AnimationVars) => void;
|
|
37
|
+
var get: (name: string) => Timeline | undefined;
|
|
38
|
+
var has: (name: string) => boolean;
|
|
39
|
+
var getNames: () => string[];
|
|
40
|
+
var kill: (name: string) => void;
|
|
41
|
+
var killAll: () => void;
|
|
42
|
+
var refreshScrollTriggers: () => void;
|
|
43
|
+
var cleanup: () => void;
|
|
44
|
+
var utils: {
|
|
45
|
+
readonly toArray: typeof import("../utils/MotionUtils").toArray;
|
|
46
|
+
readonly clamp: typeof import("../utils/MotionUtils").clamp;
|
|
47
|
+
readonly random: typeof import("../utils/MotionUtils").random;
|
|
48
|
+
readonly snap: typeof import("../utils/MotionUtils").snap;
|
|
49
|
+
readonly interpolate: typeof import("../utils/MotionUtils").interpolate;
|
|
50
|
+
readonly mapRange: typeof import("../utils/MotionUtils").mapRange;
|
|
51
|
+
readonly normalize: typeof import("../utils/MotionUtils").normalize;
|
|
52
|
+
readonly wrap: typeof import("../utils/MotionUtils").wrap;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export declare const Motion: typeof MotionFunction;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PropTween - Individual property interpolation unit
|
|
3
|
+
*
|
|
4
|
+
* Linked list node for animating a single property.
|
|
5
|
+
* Pooled for performance.
|
|
6
|
+
* Supports scalar values, color (RGBA), and filter interpolation.
|
|
7
|
+
*/
|
|
8
|
+
import type { AnimationTarget } from '../types';
|
|
9
|
+
import type { ParsedFilterFunction } from '../utils/FilterParser';
|
|
10
|
+
import type { ParsedDrawSVG } from '../utils/DrawSVGParser';
|
|
11
|
+
import { type PathPoint } from '../utils/PathParser';
|
|
12
|
+
type PropTweenValueType = 'scalar' | 'color' | 'filter' | 'drawSVG' | 'path';
|
|
13
|
+
export declare class PropTween {
|
|
14
|
+
target: AnimationTarget | null;
|
|
15
|
+
property: string;
|
|
16
|
+
startValue: number;
|
|
17
|
+
endValue: number;
|
|
18
|
+
change: number;
|
|
19
|
+
unit: string;
|
|
20
|
+
next: PropTween | null;
|
|
21
|
+
valueType: PropTweenValueType;
|
|
22
|
+
startColor: Float32Array | null;
|
|
23
|
+
endColor: Float32Array | null;
|
|
24
|
+
changeColor: Float32Array;
|
|
25
|
+
startFilters: ParsedFilterFunction[] | null;
|
|
26
|
+
endFilters: ParsedFilterFunction[] | null;
|
|
27
|
+
startDraw: ParsedDrawSVG | null;
|
|
28
|
+
endDraw: ParsedDrawSVG | null;
|
|
29
|
+
pathLength: number;
|
|
30
|
+
pathData: string | null;
|
|
31
|
+
motionPathLength: number;
|
|
32
|
+
startProgress: number;
|
|
33
|
+
endProgress: number;
|
|
34
|
+
pathRotate: boolean;
|
|
35
|
+
alignOffset: {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
} | null;
|
|
39
|
+
pathOffset: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
} | null;
|
|
43
|
+
pathLUT: PathPoint[] | null;
|
|
44
|
+
private _isElement;
|
|
45
|
+
/**
|
|
46
|
+
* Initialize the PropTween with scalar values
|
|
47
|
+
*/
|
|
48
|
+
init(target: AnimationTarget, property: string, startValue: number, endValue: number, unit?: string): this;
|
|
49
|
+
/**
|
|
50
|
+
* Initialize the PropTween with color values
|
|
51
|
+
*/
|
|
52
|
+
initColor(target: AnimationTarget, property: string, startColor: Float32Array, endColor: Float32Array): this;
|
|
53
|
+
/**
|
|
54
|
+
* Initialize the PropTween with filter values
|
|
55
|
+
*/
|
|
56
|
+
initFilter(target: AnimationTarget, property: string, startFilters: ParsedFilterFunction[], endFilters: ParsedFilterFunction[]): this;
|
|
57
|
+
/**
|
|
58
|
+
* Initialize the PropTween with drawSVG values
|
|
59
|
+
*/
|
|
60
|
+
initDrawSVG(target: AnimationTarget, property: string, startDraw: ParsedDrawSVG, endDraw: ParsedDrawSVG, pathLength: number): this;
|
|
61
|
+
/**
|
|
62
|
+
* Initialize the PropTween with path (motion path) values
|
|
63
|
+
* Pre-samples the path into a lookup table for O(1) rendering
|
|
64
|
+
*/
|
|
65
|
+
initPath(target: AnimationTarget, property: string, pathData: string, pathLength: number, startProgress: number, endProgress: number, rotate: boolean, alignOffset: {
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
}, pathOffset: {
|
|
69
|
+
x: number;
|
|
70
|
+
y: number;
|
|
71
|
+
}): this;
|
|
72
|
+
/**
|
|
73
|
+
* Render the property at given progress (0-1)
|
|
74
|
+
*/
|
|
75
|
+
render(progress: number): void;
|
|
76
|
+
/**
|
|
77
|
+
* Reset for object pooling
|
|
78
|
+
*/
|
|
79
|
+
reset(): void;
|
|
80
|
+
}
|
|
81
|
+
export {};
|