@motion.page/sdk 1.2.2 → 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/README.md +49 -0
- package/dist/core/PropTween.d.ts +3 -0
- package/dist/index.cjs +18 -18
- package/dist/index.js +18 -18
- package/dist/triggers/MouseMoveTrigger.d.ts +14 -0
- package/dist/utils/PathParser.d.ts +25 -1
- package/dist/utils/PropertyParser/types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -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
|
};
|