@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.
Files changed (52) hide show
  1. package/README.md +817 -0
  2. package/dist/core/Animation.d.ts +230 -0
  3. package/dist/core/AnimationBuilder.d.ts +125 -0
  4. package/dist/core/Engine.d.ts +140 -0
  5. package/dist/core/Motion.d.ts +56 -0
  6. package/dist/core/PropTween.d.ts +81 -0
  7. package/dist/core/Ticker.d.ts +107 -0
  8. package/dist/core/Timeline.d.ts +294 -0
  9. package/dist/easing/index.d.ts +65 -0
  10. package/dist/fit/FitResolver.d.ts +12 -0
  11. package/dist/index.cjs +34 -0
  12. package/dist/index.cjs.map +52 -0
  13. package/dist/index.d.ts +25 -0
  14. package/dist/index.js +34 -0
  15. package/dist/index.js.map +52 -0
  16. package/dist/memory/AnimationPool.d.ts +14 -0
  17. package/dist/memory/ObjectPool.d.ts +37 -0
  18. package/dist/memory/PropTweenPool.d.ts +14 -0
  19. package/dist/registries/SDKRegistry.d.ts +69 -0
  20. package/dist/render/CSSRenderer.d.ts +33 -0
  21. package/dist/render/PathRenderer.d.ts +24 -0
  22. package/dist/render/RenderBatch.d.ts +27 -0
  23. package/dist/render/TransformCache.d.ts +54 -0
  24. package/dist/stagger/StaggerResolver.d.ts +28 -0
  25. package/dist/triggers/BaseTrigger.d.ts +61 -0
  26. package/dist/triggers/CursorTrigger.d.ts +86 -0
  27. package/dist/triggers/EventTrigger.d.ts +48 -0
  28. package/dist/triggers/GestureTrigger.d.ts +137 -0
  29. package/dist/triggers/MarkerManager.d.ts +42 -0
  30. package/dist/triggers/MouseMoveTrigger.d.ts +49 -0
  31. package/dist/triggers/PageExitTrigger.d.ts +74 -0
  32. package/dist/triggers/PageLoadTrigger.d.ts +37 -0
  33. package/dist/triggers/PinManager.d.ts +131 -0
  34. package/dist/triggers/ScrollTrigger.d.ts +103 -0
  35. package/dist/triggers/TriggerManager.d.ts +133 -0
  36. package/dist/types/index.d.ts +355 -0
  37. package/dist/types/public.d.ts +7 -0
  38. package/dist/utils/ColorParser.d.ts +23 -0
  39. package/dist/utils/DrawSVGParser.d.ts +62 -0
  40. package/dist/utils/FilterParser.d.ts +49 -0
  41. package/dist/utils/MotionUtils.d.ts +136 -0
  42. package/dist/utils/PathParser.d.ts +89 -0
  43. package/dist/utils/PositionParser.d.ts +24 -0
  44. package/dist/utils/PropertyParser.d.ts +159 -0
  45. package/dist/utils/QuickSetter.d.ts +16 -0
  46. package/dist/utils/ScrollPositionParser.d.ts +19 -0
  47. package/dist/utils/StyleReset.d.ts +73 -0
  48. package/dist/utils/TargetResolver.d.ts +23 -0
  49. package/dist/utils/TextSplitter.d.ts +90 -0
  50. package/dist/utils/executeTimelineAction.d.ts +18 -0
  51. package/dist/utils/getLayoutRect.d.ts +10 -0
  52. package/package.json +56 -0
@@ -0,0 +1,14 @@
1
+ /**
2
+ * AnimationPool - Singleton object pool for Animation instances
3
+ *
4
+ * Reuses Animation objects to minimize garbage collection overhead
5
+ */
6
+ import { Animation } from '../core/Animation';
7
+ export declare const AnimationPool: {
8
+ acquire: () => Animation;
9
+ release: (animation: Animation) => void;
10
+ getPoolSize: () => number;
11
+ getTotalCreated: () => number;
12
+ clear: () => void;
13
+ };
14
+ export type AnimationPool = typeof AnimationPool;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * ObjectPool<T> - Generic object pool for reusable instances
3
+ *
4
+ * Reuses objects that implement a `reset()` method to minimize
5
+ * garbage collection overhead.
6
+ */
7
+ /** Constraint: pooled objects must be resettable */
8
+ export interface Poolable {
9
+ reset(): void;
10
+ }
11
+ export declare class ObjectPool<T extends Poolable> {
12
+ private pool;
13
+ private totalCreated;
14
+ private readonly factory;
15
+ private readonly maxSize;
16
+ constructor(factory: () => T, maxSize?: number);
17
+ /**
18
+ * Acquire an object from the pool or create a new one
19
+ */
20
+ acquire(): T;
21
+ /**
22
+ * Release an object back to the pool
23
+ */
24
+ release(obj: T): void;
25
+ /**
26
+ * Get count of pooled objects
27
+ */
28
+ getPoolSize(): number;
29
+ /**
30
+ * Get total objects created (for stats)
31
+ */
32
+ getTotalCreated(): number;
33
+ /**
34
+ * Clear the pool (for testing/debugging)
35
+ */
36
+ clear(): void;
37
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * PropTweenPool - Singleton object pool for PropTween instances
3
+ *
4
+ * Reuses PropTween objects to minimize garbage collection overhead
5
+ */
6
+ import { PropTween } from '../core/PropTween';
7
+ export declare const PropTweenPool: {
8
+ acquire: () => PropTween;
9
+ release: (propTween: PropTween) => void;
10
+ getPoolSize: () => number;
11
+ getTotalCreated: () => number;
12
+ clear: () => void;
13
+ };
14
+ export type PropTweenPool = typeof PropTweenPool;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * SDKRegistry - Central registry for all optional SDK modules
3
+ *
4
+ * Optional modules register themselves here when loaded.
5
+ * Core modules access features through this registry with optional chaining.
6
+ * This enables tree-shaking: unused modules aren't bundled.
7
+ */
8
+ import type { ParsedFilterFunction } from '../utils/FilterParser';
9
+ import type { ParsedDrawSVG } from '../utils/DrawSVGParser';
10
+ import type { AnimationTarget, StaggerVars, SplitType } from '../types';
11
+ import type { TriggerManager } from '../triggers/TriggerManager';
12
+ interface ColorParserFunctions {
13
+ parseColor: (color: string, element?: Element) => Float32Array | null;
14
+ getCurrentColor: (element: Element, property: string) => Float32Array;
15
+ }
16
+ interface FilterParserFunctions {
17
+ parseFilter: (filter: string) => ParsedFilterFunction[] | null;
18
+ getCurrentFilter: (element: Element) => ParsedFilterFunction[];
19
+ mergeFilterArrays: (start: ParsedFilterFunction[], end: ParsedFilterFunction[]) => {
20
+ start: ParsedFilterFunction[];
21
+ end: ParsedFilterFunction[];
22
+ };
23
+ interpolateFilters: (start: ParsedFilterFunction[], end: ParsedFilterFunction[], progress: number) => ParsedFilterFunction[];
24
+ filterToString: (filters: ParsedFilterFunction[]) => string;
25
+ }
26
+ interface DrawSVGParserFunctions {
27
+ parseDrawSVG: (value: string | {
28
+ start?: number;
29
+ end?: number;
30
+ }, element?: Element) => ParsedDrawSVG | null;
31
+ getCurrentDrawSVG: (element: Element) => ParsedDrawSVG;
32
+ getPathLength: (element: Element) => number;
33
+ applyDrawSVG: (element: Element, start: number, end: number, length: number) => void;
34
+ }
35
+ interface TextSplitterFunctions {
36
+ split: (element: Element, type: SplitType, options?: {
37
+ mask?: boolean;
38
+ }) => HTMLElement[];
39
+ revert: (element: Element) => boolean;
40
+ isSplit: (element: Element) => boolean;
41
+ }
42
+ interface StyleResetFunctions {
43
+ registerAnimatedProps: (element: Element, props: string[]) => void;
44
+ clearAnimationStylesForProps: (element: Element, props: string[]) => void;
45
+ clearAnimationStylesAndUnregister: (element: Element) => void;
46
+ clearPinStylesAndUnregister: (element: Element) => void;
47
+ }
48
+ interface FitResolverFunctions {
49
+ registerPendingSetup(animation: import('../core/Animation').Animation, element: Element, fitConfig: import('../types').FitConfig, propTweenPool: typeof import('../memory/PropTweenPool').PropTweenPool): void;
50
+ }
51
+ /**
52
+ * Unified registry for all optional SDK features.
53
+ * Each slot is null until the corresponding module loads and self-registers.
54
+ */
55
+ export declare const SDKRegistry: {
56
+ color: ColorParserFunctions | null;
57
+ filter: FilterParserFunctions | null;
58
+ drawSVG: DrawSVGParserFunctions | null;
59
+ stagger: {
60
+ resolve: (targets: AnimationTarget[], stagger: number | StaggerVars) => number[];
61
+ } | null;
62
+ textSplitter: TextSplitterFunctions | null;
63
+ triggerManager: {
64
+ getInstance: () => TriggerManager;
65
+ } | null;
66
+ styleReset: StyleResetFunctions | null;
67
+ fit: FitResolverFunctions | null;
68
+ };
69
+ export {};
@@ -0,0 +1,33 @@
1
+ /**
2
+ * CSSRenderer - Render CSS properties to DOM elements
3
+ *
4
+ * Handles:
5
+ * - Transform properties (x, y, rotate, scale, etc.)
6
+ * - Standard CSS properties (opacity, backgroundColor, etc.)
7
+ * - Unit handling (px, %, deg, etc.)
8
+ * - Auto-batching: queues during animation tick, writes immediately otherwise
9
+ *
10
+ * The render system automatically detects context:
11
+ * - Inside Ticker tick → queue for batch flush at end of frame (performance)
12
+ * - Outside tick → write immediately to DOM (responsiveness for seek/progress/etc.)
13
+ */
14
+ import type { ParsedFilterFunction } from '../utils/FilterParser';
15
+ /**
16
+ * Set a CSS property value on an element
17
+ * Automatically batches during animation tick, writes immediately otherwise
18
+ */
19
+ export declare function setCSSProperty(element: Element, property: string, value: number, unit: string): void;
20
+ /**
21
+ * Set a CSS color property value on an element
22
+ * Takes RGBA values directly for performance (avoids string formatting in hot path)
23
+ */
24
+ export declare function setCSSColorProperty(element: Element, property: string, r: number, g: number, b: number, a: number): void;
25
+ /**
26
+ * Get computed value of a CSS property
27
+ */
28
+ export declare function getCSSProperty(element: Element, property: string): string;
29
+ /**
30
+ * Set a CSS filter property value on an element
31
+ * Interpolates between start and end filter arrays at given progress
32
+ */
33
+ export declare function setCSSFilterProperty(element: Element, startFilters: ParsedFilterFunction[], endFilters: ParsedFilterFunction[], progress: number): void;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * PathRenderer - Encapsulates motion path rendering logic
3
+ *
4
+ * Extracted from PropTween to improve code organization.
5
+ * PropTween still holds the data (for pooling), but rendering is delegated here.
6
+ */
7
+ import type { PathPoint } from '../utils/PathParser';
8
+ interface PathRenderState {
9
+ pathLUT: PathPoint[];
10
+ alignOffset: {
11
+ x: number;
12
+ y: number;
13
+ };
14
+ pathOffset: {
15
+ x: number;
16
+ y: number;
17
+ };
18
+ pathRotate: boolean;
19
+ }
20
+ /**
21
+ * Render path position at given progress
22
+ */
23
+ export declare function renderPath(target: Element, progress: number, state: PathRenderState): void;
24
+ export {};
@@ -0,0 +1,27 @@
1
+ /**
2
+ * RenderBatch - Batched DOM write system
3
+ *
4
+ * Collects all property changes during a frame and flushes them
5
+ * in a single batch at frame end. This eliminates layout thrashing
6
+ * and reduces DOM writes from O(properties) to O(elements).
7
+ *
8
+ * Key optimizations:
9
+ * - One transform string build per element (not per property)
10
+ * - One DOM write per element for transforms
11
+ * - Batched CSS property writes
12
+ * - Zero allocations during animation (uses Sets/Maps)
13
+ */
14
+ /**
15
+ * Queue a transform update for an element
16
+ * Called after setTransformValue updates the cache
17
+ */
18
+ export declare function queueTransform(element: Element): void;
19
+ /**
20
+ * Queue a CSS property update for an element
21
+ */
22
+ export declare function queueStyle(element: Element, property: string, value: string): void;
23
+ /**
24
+ * Flush all pending DOM writes
25
+ * Called once at end of each animation frame
26
+ */
27
+ export declare function flush(): void;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * TransformCache - Optimized transform value storage
3
+ *
4
+ * Uses Float32Array for fast transform value storage per element.
5
+ * Separate array for units (string per property).
6
+ * Dirty flag bitmask to skip unchanged properties.
7
+ * Cached transform string to avoid rebuilding.
8
+ */
9
+ interface TransformData {
10
+ values: Float32Array;
11
+ units: string[];
12
+ dirty: number;
13
+ used: number;
14
+ cachedString: string;
15
+ pinDirty: boolean;
16
+ }
17
+ /**
18
+ * Get or create transform data for an element
19
+ */
20
+ export declare function getTransformData(element: Element): TransformData;
21
+ /**
22
+ * Set a transform value and unit, mark as dirty
23
+ */
24
+ export declare function setTransformValue(element: Element, property: string, value: number, unit?: string): void;
25
+ /**
26
+ * Get a transform value
27
+ */
28
+ export declare function getTransformValue(element: Element, property: string): number;
29
+ /**
30
+ * Get a transform unit
31
+ */
32
+ export declare function getTransformUnit(element: Element, property: string): string;
33
+ /**
34
+ * Register a pin offset for an element.
35
+ * The pin offset is prepended to the animation transform in buildTransformString().
36
+ * Call this instead of writing directly to element.style.transform from PinManager
37
+ * so that both pin position and animation values are composed into a single write.
38
+ */
39
+ export declare function setPinOffset(element: Element, x: number, y: number, z: number): void;
40
+ /**
41
+ * Remove the pin offset for an element (call when element exits pin zone).
42
+ * Marks the cached transform string as stale so the next build omits the offset.
43
+ */
44
+ export declare function clearPinOffset(element: Element): void;
45
+ /**
46
+ * Build the CSS transform string from cached values
47
+ */
48
+ export declare function buildTransformString(element: Element): string;
49
+ /**
50
+ * Clear transform cache for an element
51
+ * @param clearInlineStyle - If true, also clears element's inline transform to prevent hydration from reading stale values
52
+ */
53
+ export declare function clearTransformCache(element: Element, clearInlineStyle?: boolean): void;
54
+ export {};
@@ -0,0 +1,28 @@
1
+ /**
2
+ * StaggerResolver - Calculates stagger delays for multiple targets
3
+ */
4
+ import type { StaggerVars, AnimationTarget } from '../types';
5
+ export declare class StaggerResolver {
6
+ /**
7
+ * Calculate stagger delays for an array of targets
8
+ * Works with both DOM elements and plain objects
9
+ */
10
+ static resolve(targets: AnimationTarget[], stagger: number | StaggerVars): number[];
11
+ /**
12
+ * Resolve complex stagger configuration with from, grid, etc.
13
+ */
14
+ private static resolveComplexStagger;
15
+ /**
16
+ * Get target ordering based on 'from' parameter
17
+ */
18
+ private static getOrdering;
19
+ /**
20
+ * Get ordering for grid-based stagger
21
+ */
22
+ private static getGridOrdering;
23
+ /**
24
+ * Auto-detect grid dimensions from element positions
25
+ * Only works with DOM elements. For plain objects, falls back to linear arrangement.
26
+ */
27
+ private static detectGrid;
28
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * BaseTrigger - Abstract base class for all standard trigger types
3
+ *
4
+ * Extracts the common enable/disable lifecycle pattern shared by
5
+ * ScrollTrigger, EventTrigger, MouseMoveTrigger, GestureTrigger, and CursorTrigger.
6
+ *
7
+ * Provides:
8
+ * - enable/disable guards with _enabled flag
9
+ * - DOM-ready gating via whenDOMReady
10
+ * - Shared helper methods for selector resolution and listener cleanup
11
+ *
12
+ * NOT used by PageLoadTrigger (which has a different lifecycle pattern).
13
+ */
14
+ import type { Timeline } from '../core/Timeline';
15
+ export declare abstract class BaseTrigger<TConfig> {
16
+ protected _timeline: Timeline;
17
+ protected _config: TConfig;
18
+ protected _enabled: boolean;
19
+ constructor(timeline: Timeline, config: TConfig);
20
+ /**
21
+ * Enable the trigger. Guards against double-enable and waits for DOM ready.
22
+ * Calls _onEnable() once the DOM is ready (or immediately if already ready).
23
+ */
24
+ enable(): void;
25
+ /**
26
+ * Disable the trigger. Guards against double-disable.
27
+ * Calls _onDisable() immediately (no DOM-ready gating needed for teardown).
28
+ */
29
+ disable(): void;
30
+ /**
31
+ * Subclass: set up event listeners, resolve targets, start ticker loops, etc.
32
+ * Called once per enable cycle after DOM is ready.
33
+ */
34
+ protected abstract _onEnable(): void;
35
+ /**
36
+ * Subclass: remove event listeners, clear state, stop ticker loops, etc.
37
+ * Called once per disable cycle.
38
+ */
39
+ protected abstract _onDisable(): void;
40
+ /**
41
+ * Resolve a single element from a string selector or Element reference.
42
+ * Returns the fallback (defaults to null) if selector is undefined, not found, or invalid.
43
+ *
44
+ * Note: non-string values are treated as direct element references without an instanceof
45
+ * check, so this works with both real DOM elements and mock objects in tests.
46
+ */
47
+ protected _resolveElement(selector: string | Element | undefined, fallback?: EventTarget | null): HTMLElement | EventTarget | null;
48
+ /**
49
+ * Resolve multiple elements from a string selector or single Element reference.
50
+ * Returns an empty array if selector is undefined, not found, or invalid.
51
+ *
52
+ * Note: non-string values are treated as direct element references without an instanceof
53
+ * check, so this works with both real DOM elements and mock objects in tests.
54
+ */
55
+ protected _resolveElements(selector: string | Element | undefined): Element[];
56
+ /**
57
+ * Remove all event listeners tracked in a nested listener map and clear the map.
58
+ * Accepts Map<EventTarget, Map<eventName, listener>>.
59
+ */
60
+ protected _cleanupListenerMap(listeners: Map<EventTarget, Map<string, EventListener>>): void;
61
+ }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * CursorTrigger - Custom cursor controller
3
+ *
4
+ * Features:
5
+ * - Smooth position tracking with configurable lag
6
+ * - State-based animations (default, hover, click)
7
+ * - Velocity-based squeeze effect
8
+ * - Text and media cursor variants
9
+ */
10
+ import type { CursorConfig } from '../types';
11
+ import { Timeline } from '../core/Timeline';
12
+ import { BaseTrigger } from './BaseTrigger';
13
+ type CursorState = 'default' | 'hover' | 'click';
14
+ export declare class CursorTrigger extends BaseTrigger<CursorConfig> {
15
+ private _element;
16
+ private _innerElement;
17
+ private _mousePos;
18
+ private _cursorPos;
19
+ private _xSetter;
20
+ private _ySetter;
21
+ private _squeezeSetter;
22
+ private _squeezeConfig;
23
+ private _state;
24
+ private _stateTimelines;
25
+ private _parsedStates;
26
+ private _textElement;
27
+ private _mediaElement;
28
+ private _tickerCallback?;
29
+ private _boundMouseMove?;
30
+ private _boundMouseDown?;
31
+ private _boundMouseUp?;
32
+ private _hoverFrozenRects;
33
+ private _isHoveringCursorTarget;
34
+ private _boundHoverTargetMoveHandler;
35
+ private _hoverListeners;
36
+ private _attributeListeners;
37
+ constructor(timeline: Timeline, config: CursorConfig);
38
+ private _parseStateConfig;
39
+ /**
40
+ * Set up the cursor: resolve element, create setters, attach listeners, start ticker.
41
+ *
42
+ * Architecture (mirrors original GSAP cursor):
43
+ * - Container (_element): position:fixed, zero-size, moved via x/y QuickSetters
44
+ * - Inner element (_innerElement): centered via translate(-50%, -50%),
45
+ * receives all visual CSS properties and state transitions
46
+ */
47
+ protected _onEnable(): void;
48
+ /**
49
+ * Tear down the cursor: remove ticker, restore native cursor, remove listeners.
50
+ */
51
+ protected _onDisable(): void;
52
+ private _getTargetElement;
53
+ private _applyProperties;
54
+ private _createStateTimelines;
55
+ /**
56
+ * Expand CSS transform shorthand in state properties into individual
57
+ * SDK transform properties that the animation system can interpolate.
58
+ * E.g., {transform: 'scale(2)', width: '80px'} → {scale: 2, width: '80px'}
59
+ */
60
+ private static _expandStateProperties;
61
+ /**
62
+ * Parse CSS transform shorthand string into individual SDK transform properties.
63
+ * Handles: scale, scaleX/Y, rotate, rotateX/Y/Z, skewX/Y
64
+ * E.g., "scale(2)" → {scale: 2}
65
+ * "scale(2, 3)" → {scaleX: 2, scaleY: 3}
66
+ * "scale(2) rotate(45deg)" → {scale: 2, rotate: 45}
67
+ */
68
+ private static _expandTransformShorthand;
69
+ private _setupEventListeners;
70
+ private _setupHoverTargets;
71
+ private _setupTextCursor;
72
+ private _setupMediaCursor;
73
+ private _removeEventListeners;
74
+ private _setState;
75
+ private _tick;
76
+ private _calculateSqueeze;
77
+ /**
78
+ * Get the cursor element
79
+ */
80
+ getElement(): HTMLElement | null;
81
+ /**
82
+ * Get current state
83
+ */
84
+ getState(): CursorState;
85
+ }
86
+ export {};
@@ -0,0 +1,48 @@
1
+ /**
2
+ * EventTrigger
3
+ *
4
+ * Triggers timelines based on DOM events:
5
+ * - hover: plays on mouseenter, reverses on mouseleave
6
+ * - click: plays on click with optional toggle behavior (reverse/restart on 2nd click)
7
+ */
8
+ import type { Timeline } from '../core/Timeline';
9
+ import { BaseTrigger } from './BaseTrigger';
10
+ /** Internal config for EventTrigger */
11
+ export interface EventTriggerConfig {
12
+ type: 'hover' | 'click';
13
+ target?: string | Element;
14
+ secondTarget?: string | Element;
15
+ toggle?: 'reverse' | 'restart' | 'play';
16
+ preventDefault?: boolean;
17
+ onLeave?: 'reverse' | 'pause' | 'stop' | 'restart' | 'none';
18
+ leaveDelay?: number;
19
+ }
20
+ export declare class EventTrigger extends BaseTrigger<EventTriggerConfig> {
21
+ private _targets;
22
+ private _secondTargets;
23
+ private _listeners;
24
+ private _isForward;
25
+ private _frozenRects;
26
+ private _wasHovering;
27
+ private _hoverLeaveTimeout;
28
+ private _boundMouseMoveHandler;
29
+ constructor(timeline: Timeline, config: EventTriggerConfig);
30
+ /**
31
+ * Set up event listeners once DOM is ready.
32
+ */
33
+ protected _onEnable(): void;
34
+ /**
35
+ * Remove all event listeners and cancel pending timers.
36
+ */
37
+ protected _onDisable(): void;
38
+ /**
39
+ * Re-snapshot frozen rects after layout changes (e.g. window resize).
40
+ * Called by TriggerManager.refreshScrollTriggers() on resize.
41
+ */
42
+ refresh(): void;
43
+ private _resolveTargets;
44
+ private _addHoverListeners;
45
+ private _handleLeaveAction;
46
+ private _addClickListeners;
47
+ private _handleSecondClick;
48
+ }
@@ -0,0 +1,137 @@
1
+ /**
2
+ * GestureTrigger
3
+ *
4
+ * Detects user gestures (pointer, touch, wheel, scroll) and triggers
5
+ * timeline actions based on directional movement and interaction events.
6
+ *
7
+ * Performance optimizations:
8
+ * - RAF synchronization for callback execution
9
+ * - Throttled scroll/wheel event processing
10
+ * - Cached config values
11
+ * - Minimal allocations in hot paths
12
+ */
13
+ import type { GestureConfig } from '../types';
14
+ import type { Timeline } from '../core/Timeline';
15
+ import { BaseTrigger } from './BaseTrigger';
16
+ export declare class GestureTrigger extends BaseTrigger<GestureConfig> {
17
+ private _target;
18
+ private _tolerance;
19
+ private _dragMinimum;
20
+ private _dragMinimumSquared;
21
+ private _wheelSpeed;
22
+ private _scrollSpeed;
23
+ private _stopDelay;
24
+ private _preventDefault;
25
+ private _lockAxis;
26
+ private _animationStep;
27
+ private _smooth;
28
+ private _startX;
29
+ private _startY;
30
+ private _deltaX;
31
+ private _deltaY;
32
+ private _lockedAxis;
33
+ private _isPressed;
34
+ private _isDragging;
35
+ private _lastDirectionX;
36
+ private _lastDirectionY;
37
+ private _lastScrollX;
38
+ private _lastScrollY;
39
+ private _stopTimeout;
40
+ private _isMoving;
41
+ private _lastActivityTime;
42
+ private _pendingActions;
43
+ private _rafScheduled;
44
+ private _rafId;
45
+ private _wheelAccumulatorX;
46
+ private _wheelAccumulatorY;
47
+ private _wheelRafId;
48
+ private _scrollRafId;
49
+ private _lastPointerX;
50
+ private _lastPointerY;
51
+ private _activatedDirections;
52
+ private _targetProgress;
53
+ private _currentProgress;
54
+ private _interpolationRafId;
55
+ private _siblings;
56
+ private _index;
57
+ private static _sequenceStates;
58
+ private _boundHandlers;
59
+ private _frozenHoverRect;
60
+ private _gestureHoverActive;
61
+ private _boundHoverMoveHandler;
62
+ constructor(timeline: Timeline, config: GestureConfig);
63
+ /**
64
+ * Resolve target and attach gesture listeners once DOM is ready.
65
+ */
66
+ protected _onEnable(): void;
67
+ /**
68
+ * Cancel all pending timers/RAF and remove all event listeners.
69
+ */
70
+ protected _onDisable(): void;
71
+ private _addPointerListeners;
72
+ private _handlePointerDown;
73
+ private _handlePointerMove;
74
+ private _handlePointerUp;
75
+ private _addTouchListeners;
76
+ private _handleTouchStart;
77
+ private _handleTouchMove;
78
+ private _handleTouchEnd;
79
+ /**
80
+ * Shared start logic for pointer and touch input.
81
+ */
82
+ private _handleInputStart;
83
+ /**
84
+ * Shared move logic for pointer and touch input.
85
+ * Returns true if movement was processed (caller should preventDefault if needed).
86
+ */
87
+ private _handleInputMove;
88
+ /**
89
+ * Shared end logic for pointer and touch input.
90
+ */
91
+ private _handleInputEnd;
92
+ private _addWheelListener;
93
+ private _handleWheel;
94
+ private _addScrollListener;
95
+ private _handleScroll;
96
+ private _processScroll;
97
+ private _addHoverListeners;
98
+ /**
99
+ * Re-snapshot frozen hover rect after layout changes (e.g. window resize).
100
+ * Called by TriggerManager on resize.
101
+ */
102
+ refresh(): void;
103
+ private _updateDeltas;
104
+ /**
105
+ * Check and fire directional callbacks.
106
+ * @param instant - If true (wheel/scroll), skips axis-lock checks and direction tracking.
107
+ * If false (pointer/touch), respects axis locking and tracks activated directions.
108
+ */
109
+ private _checkDirectionAndFire;
110
+ /**
111
+ * Check for direction toggle (reversal)
112
+ */
113
+ private _checkToggle;
114
+ private _checkDragStart;
115
+ private _scheduleStopCheck;
116
+ private _fireEvent;
117
+ private _scheduleRAF;
118
+ private _getStepForEvent;
119
+ private _executeAction;
120
+ /**
121
+ * Play next or previous item in sequence (for each mode)
122
+ * @param direction 1 for next, -1 for previous
123
+ */
124
+ private _playSequenceItem;
125
+ /**
126
+ * Smoothly interpolate progress by the given delta.
127
+ * Uses lerp for continuous scrolling (responsive) with natural ease-out when stopping.
128
+ */
129
+ private _interpolateProgress;
130
+ private _startInterpolationLoop;
131
+ /**
132
+ * Fire directional Complete callbacks for any directions that were activated
133
+ * during this gesture, then clear the tracking set.
134
+ */
135
+ private _fireCompleteCallbacks;
136
+ private _resetGestureState;
137
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * MarkerManager
3
+ *
4
+ * Manages debug markers for ScrollTrigger visualization.
5
+ * Shows 4 markers:
6
+ * - scroller-start/end: Fixed position lines showing where triggers fire
7
+ * - start/end: Element-relative lines showing trigger points on the element
8
+ */
9
+ import type { MarkerConfig } from '../types';
10
+ interface MarkerSetupConfig {
11
+ scroller: Element | Window;
12
+ triggerElement: HTMLElement | null;
13
+ startConfig: string;
14
+ endConfig: string;
15
+ markerConfig: MarkerConfig | boolean;
16
+ viewportHeight: number;
17
+ }
18
+ export declare class MarkerManager {
19
+ private _id;
20
+ private _markers?;
21
+ private _markerContainer?;
22
+ private _triggerElement?;
23
+ private _scrollerStartOffset;
24
+ private _scrollerEndOffset;
25
+ private _scroller;
26
+ private _startConfig;
27
+ private _endConfig;
28
+ constructor(triggerId: number);
29
+ /**
30
+ * Create debug markers showing trigger positions
31
+ */
32
+ setup(config: MarkerSetupConfig): void;
33
+ /**
34
+ * Update marker positions on scroll
35
+ */
36
+ update(scrollTop: number, triggerElement: HTMLElement | null, viewportHeight: number): void;
37
+ /**
38
+ * Remove all markers
39
+ */
40
+ cleanup(): void;
41
+ }
42
+ export {};