@motion.page/sdk 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/Animation.d.ts +2 -2
- package/dist/core/PropTween.d.ts +6 -1
- package/dist/core/Timeline.d.ts +6 -1
- package/dist/index.cjs +10 -10
- package/dist/index.js +10 -10
- package/dist/render/CSSRenderer.d.ts +6 -0
- package/dist/triggers/CursorTrigger.d.ts +27 -0
- package/dist/triggers/MouseMoveTrigger.d.ts +14 -0
- package/dist/triggers/PinManager.d.ts +1 -0
- package/dist/utils/ColorParser.d.ts +1 -1
- package/dist/utils/PathParser.d.ts +25 -1
- package/dist/utils/PropertyParser/types.d.ts +6 -0
- package/package.json +1 -1
|
@@ -18,6 +18,12 @@ import type { ParsedClipPath } from '../utils/ClipPathParser';
|
|
|
18
18
|
* Automatically batches during animation tick, writes immediately otherwise
|
|
19
19
|
*/
|
|
20
20
|
export declare function setCSSProperty(element: Element, property: string, value: number, unit: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Set a regular CSS property whose explicit start/end values use different
|
|
23
|
+
* units. Endpoints are emitted as authored; intermediate frames use CSS calc()
|
|
24
|
+
* so the browser resolves mixed units natively.
|
|
25
|
+
*/
|
|
26
|
+
export declare function setCSSMixedUnitProperty(element: Element, property: string, startValue: number, startUnit: string, endValue: number, endUnit: string, progress: number): void;
|
|
21
27
|
/**
|
|
22
28
|
* Set a CSS color property value on an element
|
|
23
29
|
* Takes RGBA values directly for performance (avoids string formatting in hot path)
|
|
@@ -34,6 +34,12 @@ export declare class CursorTrigger extends BaseTrigger<CursorConfig> {
|
|
|
34
34
|
private _isHoveringCursorTarget;
|
|
35
35
|
private _boundHoverTargetMoveHandler;
|
|
36
36
|
private _hoverPointerMoveTarget;
|
|
37
|
+
private _boundTextAttributeMoveHandler;
|
|
38
|
+
private _textPointerMoveTarget;
|
|
39
|
+
private _activeTextAttributeElement;
|
|
40
|
+
private _hasTextAttributeElements;
|
|
41
|
+
private _textAttributeObserver;
|
|
42
|
+
private _textAttributeObserverActive;
|
|
37
43
|
private _cursorStyleTag;
|
|
38
44
|
private _attributeListeners;
|
|
39
45
|
constructor(timeline: Timeline, config: CursorConfig);
|
|
@@ -75,6 +81,27 @@ export declare class CursorTrigger extends BaseTrigger<CursorConfig> {
|
|
|
75
81
|
private _setupEventListeners;
|
|
76
82
|
private _setupHoverTargets;
|
|
77
83
|
private _setupTextCursor;
|
|
84
|
+
private _setupTextAttributeHitTesting;
|
|
85
|
+
/** Recompute whether any tooltip/text attribute elements currently exist. */
|
|
86
|
+
private _updateHasTextAttributeElements;
|
|
87
|
+
/**
|
|
88
|
+
* Watch the DOM for tooltip/text attribute elements being added, removed, or
|
|
89
|
+
* toggled so the hit-test fast path stays correct without polling. The
|
|
90
|
+
* callback only runs a single querySelector per mutation batch — far cheaper
|
|
91
|
+
* than an elementsFromPoint call on every pointer-move frame.
|
|
92
|
+
*/
|
|
93
|
+
private _observeTextAttributeElements;
|
|
94
|
+
private _findTextAttributeTarget;
|
|
95
|
+
private _showTextCursor;
|
|
96
|
+
/**
|
|
97
|
+
* Drop the cursor back to its default state only when neither hover source is
|
|
98
|
+
* active. Both the hover-selector hit-test and the text-attribute hit-test can
|
|
99
|
+
* hold the 'hover' state; releasing requires both to be inactive so the two
|
|
100
|
+
* handlers don't fight each other across pointer-move frames. The `'hover'`
|
|
101
|
+
* guard preserves an in-progress 'click' state.
|
|
102
|
+
*/
|
|
103
|
+
private _releaseHoverIfInactive;
|
|
104
|
+
private _hideTextCursor;
|
|
78
105
|
private _setupMediaCursor;
|
|
79
106
|
private _removeEventListeners;
|
|
80
107
|
private _setState;
|
|
@@ -40,6 +40,20 @@ export declare class MouseMoveTrigger extends BaseTrigger<MouseMoveConfig> {
|
|
|
40
40
|
* Called by TriggerManager on resize.
|
|
41
41
|
*/
|
|
42
42
|
refresh(): void;
|
|
43
|
+
private _scrollX;
|
|
44
|
+
private _scrollY;
|
|
45
|
+
/**
|
|
46
|
+
* Capture an element's layout rect in DOCUMENT coordinates (viewport rect at
|
|
47
|
+
* rest + current scroll). getLayoutRect strips transforms so an animating
|
|
48
|
+
* target doesn't feed back into the measurement.
|
|
49
|
+
*/
|
|
50
|
+
private _captureDocRect;
|
|
51
|
+
/**
|
|
52
|
+
* Convert a document-space rect to the current viewport position using the
|
|
53
|
+
* live scroll offset. This is what makes a target captured below the fold
|
|
54
|
+
* become hittable once it scrolls into view.
|
|
55
|
+
*/
|
|
56
|
+
private _viewportRect;
|
|
43
57
|
private _addTargetListeners;
|
|
44
58
|
private _handleTargetPointerMove;
|
|
45
59
|
private _findTargetAtPoint;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* - RGB/RGBA: rgb(255, 0, 0), rgba(255, 0, 0, 0.5)
|
|
7
7
|
* - HSL/HSLA: hsl(0, 100%, 50%), hsla(0, 100%, 50%, 0.5)
|
|
8
8
|
* - Named colors: red, coral, transparent
|
|
9
|
-
* - CSS variables: var(--color)
|
|
9
|
+
* - CSS variables: var(--color), --color
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
12
|
* Parse any color format to RGBA Float32Array
|
|
@@ -65,6 +65,26 @@ export declare function calculateElementOffset(element: string | Element | undef
|
|
|
65
65
|
x: number;
|
|
66
66
|
y: number;
|
|
67
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Resolve the user-unit -> screen-pixel scale of an SVG path target.
|
|
70
|
+
*
|
|
71
|
+
* A `<path>` inside an `<svg viewBox="0 0 227 1358">` that renders 400px wide is
|
|
72
|
+
* scaled ~1.76x on X: its `d` coordinates are in viewBox user units, not CSS px.
|
|
73
|
+
* `getPointAtLength` returns user units, so an HTML element translated by those
|
|
74
|
+
* raw values drifts off the visible line. This returns the per-axis scale so the
|
|
75
|
+
* sampled trajectory can be converted into the same pixel space the path renders
|
|
76
|
+
* in (mirrors what GSAP's MotionPathPlugin did via the path's CTM).
|
|
77
|
+
*
|
|
78
|
+
* Raw path-data strings and off-DOM targets have no rendered geometry, so they
|
|
79
|
+
* return {1, 1} (no scaling — unchanged legacy behavior).
|
|
80
|
+
*
|
|
81
|
+
* @param target - The path `target` (CSS selector, Element, or raw "d" string)
|
|
82
|
+
* @returns Per-axis scale factor; {x:1, y:1} when not an on-DOM SVG element
|
|
83
|
+
*/
|
|
84
|
+
export declare function resolvePathScreenScale(target: string | Element): {
|
|
85
|
+
x: number;
|
|
86
|
+
y: number;
|
|
87
|
+
};
|
|
68
88
|
/**
|
|
69
89
|
* Calculate offset to position path relative to an align element
|
|
70
90
|
* The path's first point (M command) will be positioned at the align element's center
|
|
@@ -72,9 +92,13 @@ export declare function calculateElementOffset(element: string | Element | undef
|
|
|
72
92
|
* @param align - Element or selector to align the path to
|
|
73
93
|
* @param pathData - SVG path data string
|
|
74
94
|
* @param animatedElement - The element being animated (to calculate relative offset)
|
|
95
|
+
* @param pathScale - User-unit -> screen-px scale applied to the path's first point
|
|
75
96
|
* @returns Offset to add to path coordinates
|
|
76
97
|
*/
|
|
77
|
-
export declare function calculatePathAlignOffset(align: string | Element | undefined, pathData: string, animatedElement?: Element
|
|
98
|
+
export declare function calculatePathAlignOffset(align: string | Element | undefined, pathData: string, animatedElement?: Element, pathScale?: {
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
}): {
|
|
78
102
|
x: number;
|
|
79
103
|
y: number;
|
|
80
104
|
};
|
|
@@ -24,6 +24,8 @@ export interface ParsedScalarProperty extends ParsedPropertyBase {
|
|
|
24
24
|
startValue: number;
|
|
25
25
|
endValue: number;
|
|
26
26
|
unit: string;
|
|
27
|
+
startUnit?: string;
|
|
28
|
+
endUnit?: string;
|
|
27
29
|
}
|
|
28
30
|
/**
|
|
29
31
|
* Color property (RGBA values)
|
|
@@ -76,6 +78,10 @@ export interface ParsedPathProperty extends ParsedPropertyBase {
|
|
|
76
78
|
x: number;
|
|
77
79
|
y: number;
|
|
78
80
|
};
|
|
81
|
+
pathScale: {
|
|
82
|
+
x: number;
|
|
83
|
+
y: number;
|
|
84
|
+
};
|
|
79
85
|
}
|
|
80
86
|
/**
|
|
81
87
|
* Discriminated union of all parsed property types
|