@motion.page/sdk 1.2.3 → 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.
- package/dist/core/Animation.d.ts +7 -0
- package/dist/core/PropTween.d.ts +41 -2
- package/dist/core/Timeline.d.ts +6 -0
- package/dist/index.cjs +19 -17
- package/dist/index.js +19 -17
- package/dist/render/CSSRenderer.d.ts +7 -0
- package/dist/triggers/PinManager.d.ts +26 -0
- package/dist/triggers/ScrollTrigger.d.ts +7 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/utils/PropertyParser/constants.d.ts +3 -0
- package/dist/utils/PropertyParser/index.d.ts +1 -1
- package/dist/utils/PropertyParser/predicates.d.ts +20 -0
- package/dist/utils/PropertyParser/types.d.ts +14 -1
- package/package.json +1 -1
|
@@ -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)
|
|
@@ -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
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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;
|
|
@@ -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
|
*/
|
|
@@ -82,8 +92,11 @@ export interface ParsedPathProperty extends ParsedPropertyBase {
|
|
|
82
92
|
x: number;
|
|
83
93
|
y: number;
|
|
84
94
|
};
|
|
95
|
+
alignTarget?: string | Element;
|
|
96
|
+
alignAt: [number, number];
|
|
97
|
+
pathTarget: string | Element;
|
|
85
98
|
}
|
|
86
99
|
/**
|
|
87
100
|
* Discriminated union of all parsed property types
|
|
88
101
|
*/
|
|
89
|
-
export type ParsedProperty = ParsedScalarProperty | ParsedColorProperty | ParsedFilterProperty | ParsedDrawSVGProperty | ParsedPathProperty | ParsedClipPathProperty;
|
|
102
|
+
export type ParsedProperty = ParsedScalarProperty | ParsedStringProperty | ParsedColorProperty | ParsedFilterProperty | ParsedDrawSVGProperty | ParsedPathProperty | ParsedClipPathProperty;
|