@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.
@@ -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
  };
@@ -78,6 +78,10 @@ export interface ParsedPathProperty extends ParsedPropertyBase {
78
78
  x: number;
79
79
  y: number;
80
80
  };
81
+ pathScale: {
82
+ x: number;
83
+ y: number;
84
+ };
81
85
  }
82
86
  /**
83
87
  * Discriminated union of all parsed property types
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@motion.page/sdk",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "High-performance CSS animation SDK with scroll, hover, gesture, and cursor triggers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",