@motion.page/sdk 1.2.2 → 1.2.4

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.
@@ -24,6 +24,13 @@ export declare function setCSSProperty(element: Element, property: string, value
24
24
  * so the browser resolves mixed units natively.
25
25
  */
26
26
  export declare function setCSSMixedUnitProperty(element: Element, property: string, startValue: number, startUnit: string, endValue: number, endUnit: string, progress: number): void;
27
+ /**
28
+ * Set a compound CSS string property (transform-origin, background-position, …)
29
+ * verbatim. Unlike setCSSProperty, the value is a full multi-token CSS string
30
+ * already assembled by the caller, so it's written as-is (no value+unit
31
+ * concatenation). Batches during a tick, writes immediately otherwise.
32
+ */
33
+ export declare function setCSSStringProperty(element: Element, property: string, value: string): void;
27
34
  /**
28
35
  * Set a CSS color property value on an element
29
36
  * Takes RGBA values directly for performance (avoids string formatting in hot path)
@@ -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;
@@ -39,6 +39,7 @@ export declare class PinManager {
39
39
  private _fixedTop;
40
40
  private _fixedLeft;
41
41
  private _width;
42
+ private _gridPlacement;
42
43
  private _fixedBreakingAncestors;
43
44
  private _isBodyPin;
44
45
  private _originalHtmlHeight;
@@ -54,6 +55,31 @@ export declare class PinManager {
54
55
  * @param useFixedPin - true for window scroller (position:fixed), false for custom (transform)
55
56
  */
56
57
  setup(element: HTMLElement, pinStart: number, pinEnd: number, scrollerStartOffset: number, useFixedPin: boolean, pinSpacing?: boolean | 'margin' | 'padding'): void;
58
+ /**
59
+ * Measure the element's layout rect for spacer + pin sizing, recovering a real
60
+ * size when the element has collapsed to 0 in normal flow.
61
+ *
62
+ * Normally this is just `getBoundingClientRect()`. But an element whose box is
63
+ * driven entirely by percentage/auto dimensions with no definite-size ancestor
64
+ * — e.g. an inline `<svg>` that has only a `viewBox` (no width/height attrs)
65
+ * and `width: 100%`, living in a shrink-to-fit flex column — collapses to a 0
66
+ * width (and/or height) in normal flow. The spacer and the pinned element would
67
+ * then lock that 0, leaving the element invisible: any scroll animation on it
68
+ * (e.g. `scale`) still runs, but on a 0×0 box, so nothing shows.
69
+ *
70
+ * GSAP's `pinSpacing` sidesteps this by wrapping the pinned element in a div
71
+ * with a FIXED width/height to match its rendered size. To achieve the same,
72
+ * when the in-flow measurement is degenerate (0 width or height) we briefly
73
+ * take the element out of the shrink-to-fit flow (`position: absolute`, hidden
74
+ * to avoid any flash) so its percentage/`max-*` dimensions resolve against a
75
+ * real containing block, read the recovered rect, then restore the exact prior
76
+ * inline styles. The recovery is used only when it actually yields a non-zero
77
+ * box; otherwise the original rect is returned unchanged.
78
+ *
79
+ * Non-degenerate elements skip the recovery entirely, so normal pins are
80
+ * byte-identical to before.
81
+ */
82
+ private _measurePinRect;
57
83
  /**
58
84
  * Update pin state based on scroll position
59
85
  */
@@ -65,6 +65,13 @@ export declare class ScrollTrigger extends BaseTrigger<ScrollConfig> {
65
65
  * Resolve the trigger element from config or first animation
66
66
  */
67
67
  private _resolveTriggerElement;
68
+ /**
69
+ * Resolve the element the `end` position is measured against (GSAP `endTrigger`
70
+ * parity). Returns null when no `endTarget` is configured or it matches nothing,
71
+ * in which case `end` is measured against the start/trigger element — the
72
+ * default GSAP behaviour.
73
+ */
74
+ private _resolveEndTargetElement;
68
75
  /**
69
76
  * Calculate trigger start/end scroll positions based on config.
70
77
  *
@@ -386,6 +386,16 @@ export interface ClickConfig {
386
386
  }
387
387
  export interface ScrollConfig {
388
388
  target?: string | Element;
389
+ /**
390
+ * Optional element the `end` position is measured against, when it differs
391
+ * from `target`. Mirrors GSAP ScrollTrigger's `endTrigger`: `start` is resolved
392
+ * relative to `target`, `end` relative to `endTarget`. When omitted, `end` is
393
+ * resolved against `target` (GSAP's default). Used by v2→v3 migrations that
394
+ * carried a distinct end element (e.g. a seed pinned from its own bottom until a
395
+ * taller sibling's bottom). Ignored when `end` is a relative `+=`/`-=` offset,
396
+ * which is always measured from the start position.
397
+ */
398
+ endTarget?: string | Element;
389
399
  start?: string;
390
400
  end?: string;
391
401
  scrub?: boolean | number;
@@ -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
  };
@@ -5,6 +5,9 @@
5
5
  export declare const TRANSFORM_PROPS: Set<string>;
6
6
  export declare const PX_PROPS: Set<string>;
7
7
  export declare const DEG_PROPS: Set<string>;
8
+ export declare const STRING_PROPS: Set<string>;
9
+ export declare const TRANSFORM_CONFIG_STRING_PROPS: Set<string>;
10
+ export declare const KEYWORD_PROPS: Set<string>;
8
11
  export declare const UNITLESS_PROPS: Set<string>;
9
12
  export declare const COLOR_PROPS: Set<string>;
10
13
  export declare const NAMED_COLORS: Set<string>;
@@ -17,7 +17,7 @@
17
17
  * `./register` import here.
18
18
  */
19
19
  export type { PropertyValue, ParsedProperty } from './types';
20
- export { isTransformProp, isColorProp, isFilterProp, isDrawSVGProp, isPathProp, isClipPathProp, isCSSVariable, looksLikeColor, } from './predicates';
20
+ export { isTransformProp, isColorProp, isFilterProp, isDrawSVGProp, isPathProp, isClipPathProp, isStringProp, isTransformConfigProp, isKeywordProp, isCSSVariable, looksLikeColor, } from './predicates';
21
21
  export { parseValue, getDefaultUnit, getCurrentValue, convertPxToUnit, getCurrentValueInUnit, getOriginalCSSValueWithUnit, camelToKebab, } from './units';
22
22
  export { isRelativeValue, getRelativeOperator, calculateRelativeValue, } from './relative';
23
23
  export { parseProperty } from './parsers';
@@ -27,6 +27,26 @@ export declare function isPathProp(prop: string): boolean;
27
27
  * Check if a property is the clip-path property (accepts both kebab and camel case)
28
28
  */
29
29
  export declare function isClipPathProp(prop: string): boolean;
30
+ /**
31
+ * Check if a property is a compound CSS string property (transform-origin,
32
+ * background-position, …) that must be applied verbatim rather than parsed as
33
+ * a single numeric scalar.
34
+ */
35
+ export declare function isStringProp(prop: string): boolean;
36
+ /**
37
+ * Check if a property is a discrete keyword property (pointer-events, visibility,
38
+ * …) whose value is a non-numeric CSS keyword. These must be applied verbatim
39
+ * (via the string renderer) rather than parsed as a numeric scalar, which would
40
+ * turn `none`/`hidden` into `0` and have the browser ignore the invalid value.
41
+ */
42
+ export declare function isKeywordProp(prop: string): boolean;
43
+ /**
44
+ * Check if a property configures a transform's reference point (transform-origin,
45
+ * perspective-origin). These are "set and hold": when only one endpoint specifies
46
+ * them they stay constant for the whole tween instead of decaying to/from the
47
+ * element's natural origin (which would move the transform pivot mid-tween).
48
+ */
49
+ export declare function isTransformConfigProp(prop: string): boolean;
30
50
  /**
31
51
  * Check if a property is a CSS variable (custom property)
32
52
  */
@@ -27,6 +27,16 @@ export interface ParsedScalarProperty extends ParsedPropertyBase {
27
27
  startUnit?: string;
28
28
  endUnit?: string;
29
29
  }
30
+ /**
31
+ * Compound CSS string property (transform-origin, background-position, …).
32
+ * Holds the raw start/end strings; PropTween interpolates them component-wise
33
+ * when every token is numeric and snaps otherwise.
34
+ */
35
+ export interface ParsedStringProperty extends ParsedPropertyBase {
36
+ type: 'string';
37
+ startString: string;
38
+ endString: string;
39
+ }
30
40
  /**
31
41
  * Color property (RGBA values)
32
42
  */
@@ -78,8 +88,15 @@ export interface ParsedPathProperty extends ParsedPropertyBase {
78
88
  x: number;
79
89
  y: number;
80
90
  };
91
+ pathScale: {
92
+ x: number;
93
+ y: number;
94
+ };
95
+ alignTarget?: string | Element;
96
+ alignAt: [number, number];
97
+ pathTarget: string | Element;
81
98
  }
82
99
  /**
83
100
  * Discriminated union of all parsed property types
84
101
  */
85
- export type ParsedProperty = ParsedScalarProperty | ParsedColorProperty | ParsedFilterProperty | ParsedDrawSVGProperty | ParsedPathProperty | ParsedClipPathProperty;
102
+ export type ParsedProperty = ParsedScalarProperty | ParsedStringProperty | ParsedColorProperty | ParsedFilterProperty | ParsedDrawSVGProperty | ParsedPathProperty | ParsedClipPathProperty;
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.4",
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",