@motion.page/sdk 1.2.1 → 1.2.2
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 +0 -49
- package/dist/core/Animation.d.ts +2 -2
- package/dist/core/PropTween.d.ts +3 -1
- package/dist/core/Timeline.d.ts +6 -1
- package/dist/index.cjs +16 -16
- package/dist/index.js +16 -16
- package/dist/render/CSSRenderer.d.ts +6 -0
- package/dist/triggers/CursorTrigger.d.ts +27 -0
- package/dist/triggers/PinManager.d.ts +1 -0
- package/dist/utils/ColorParser.d.ts +1 -1
- package/dist/utils/PropertyParser/types.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,7 +19,6 @@ A high-performance animation SDK with a declarative API. Scroll-triggered animat
|
|
|
19
19
|
- [Motion()](#motion-function)
|
|
20
20
|
- [Motion Static Methods](#motion-static-methods)
|
|
21
21
|
- [Motion.context](#motioncontext--dynamic-content--spa)
|
|
22
|
-
- [Motion.responsive](#motionresponsive--responsive-breakpoint-variants)
|
|
23
22
|
- [Motion.utils](#motionutils)
|
|
24
23
|
- [Timeline](#timeline)
|
|
25
24
|
- [Triggers](#triggers)
|
|
@@ -285,7 +284,6 @@ Calling `Motion()` with the same name on an already-existing timeline returns it
|
|
|
285
284
|
| `Motion.refreshScrollTriggers` | `(): void` | Recalculate all scroll trigger start/end positions (call after layout changes). |
|
|
286
285
|
| `Motion.cleanup` | `(): void` | Remove ScrollTrigger spacer and marker DOM nodes from the document. |
|
|
287
286
|
| `Motion.context` | `(fn: () => void): MotionContext` | Create a scoped context that tracks all timelines created during `fn()`. Returns a `MotionContext` with `revert()`, `refresh()`, and `add(fn)` methods. Essential for dynamic content (AJAX filters, SPA navigation, infinite scroll). |
|
|
288
|
-
| `Motion.responsive` | `(name, variants, breakpoints): ResponsiveManager` | Register a reactive timeline whose per-breakpoint variant is live-swapped as the viewport crosses a breakpoint — no page reload. `variants` is a sparse map of `desktop` / `laptop` / `tablet` / `phone` factories; `breakpoints` is `{ laptops, tablets, phones }` in px. Returns a manager with `getActiveTier()` and `destroy()`. |
|
|
289
287
|
|
|
290
288
|
#### Examples
|
|
291
289
|
|
|
@@ -346,53 +344,6 @@ ctx.add(() => {
|
|
|
346
344
|
});
|
|
347
345
|
```
|
|
348
346
|
|
|
349
|
-
#### Motion.responsive — Responsive Breakpoint Variants
|
|
350
|
-
|
|
351
|
-
Use `Motion.responsive()` to give one timeline a different animation per viewport tier. Instead of compiling a separate block per breakpoint, you register a **sparse map of variant factories** and the SDK live-swaps the active variant as the viewport crosses a breakpoint — it kills the previous tier's timeline and builds the new one, with **no page reload**.
|
|
352
|
-
|
|
353
|
-
```ts
|
|
354
|
-
Motion.responsive(
|
|
355
|
-
'hero',
|
|
356
|
-
{
|
|
357
|
-
// Each tier is a factory that builds AND registers its timeline.
|
|
358
|
-
desktop: () =>
|
|
359
|
-
Motion('hero', '.title', {
|
|
360
|
-
from: { opacity: 0, x: -120 },
|
|
361
|
-
duration: 1,
|
|
362
|
-
}).onPageLoad(),
|
|
363
|
-
|
|
364
|
-
phone: () =>
|
|
365
|
-
Motion('hero', '.title', {
|
|
366
|
-
from: { opacity: 0, y: 40 },
|
|
367
|
-
duration: 0.6,
|
|
368
|
-
}).onPageLoad(),
|
|
369
|
-
},
|
|
370
|
-
{ laptops: 992, tablets: 768, phones: 576 } // breakpoint boundaries in px
|
|
371
|
-
);
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
**Tiers & ranges.** There are four tiers — `desktop`, `laptop`, `tablet`, `phone`. The `breakpoints` object sets the boundaries, and each tier owns a width range (with the values above):
|
|
375
|
-
|
|
376
|
-
| Tier | Active range |
|
|
377
|
-
|------|--------------|
|
|
378
|
-
| `desktop` | `≥ 993px` (above `laptops`) |
|
|
379
|
-
| `laptop` | `769px – 992px` |
|
|
380
|
-
| `tablet` | `577px – 768px` |
|
|
381
|
-
| `phone` | `≤ 576px` (at or below `phones`) |
|
|
382
|
-
|
|
383
|
-
**Sparse maps cascade up.** You only define the tiers you care about. A tier with no variant falls back to the nearest **wider** tier that does. In the example above, `laptop` and `tablet` widths both use the `desktop` variant; only `phone` width switches to the phone variant.
|
|
384
|
-
|
|
385
|
-
**Return value — the manager.** `Motion.responsive()` returns a `ResponsiveManager`:
|
|
386
|
-
|
|
387
|
-
```ts
|
|
388
|
-
const hero = Motion.responsive('hero', { /* variants */ }, { laptops: 992, tablets: 768, phones: 576 });
|
|
389
|
-
|
|
390
|
-
hero.getActiveTier(); // 'desktop' | 'laptop' | 'tablet' | 'phone' | null — the tier currently driving the page
|
|
391
|
-
hero.destroy(); // remove the breakpoint listeners and kill the active variant
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
> In SSR or environments without `matchMedia`, the `desktop` variant is built once with no live swapping. If the responsive runtime is tree-shaken out of a custom bundle that has no responsive timelines, the call best-effort builds the `desktop` variant and returns `undefined`.
|
|
395
|
-
|
|
396
347
|
---
|
|
397
348
|
|
|
398
349
|
### Motion.utils
|
package/dist/core/Animation.d.ts
CHANGED
|
@@ -70,13 +70,13 @@ export declare class Animation {
|
|
|
70
70
|
/**
|
|
71
71
|
* Render animation at specific progress (0-1)
|
|
72
72
|
*/
|
|
73
|
-
render(progress: number): void;
|
|
73
|
+
render(progress: number, shouldRender?: (propTween: PropTween) => boolean): void;
|
|
74
74
|
/**
|
|
75
75
|
* Render animation at an absolute time position (seconds)
|
|
76
76
|
* Handles repeat, repeatDelay, and yoyo for timeline-driven scrubbing.
|
|
77
77
|
* When driven by a Timeline (_isActive = true), also fires lifecycle callbacks.
|
|
78
78
|
*/
|
|
79
|
-
renderAtTime(totalTime: number): void;
|
|
79
|
+
renderAtTime(totalTime: number, shouldRender?: (propTween: PropTween) => boolean): void;
|
|
80
80
|
/**
|
|
81
81
|
* Apply easing function to progress
|
|
82
82
|
*/
|
package/dist/core/PropTween.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export declare class PropTween {
|
|
|
18
18
|
endValue: number;
|
|
19
19
|
change: number;
|
|
20
20
|
unit: string;
|
|
21
|
+
startUnit: string | null;
|
|
22
|
+
endUnit: string | null;
|
|
21
23
|
next: PropTween | null;
|
|
22
24
|
valueType: PropTweenValueType;
|
|
23
25
|
startColor: Float32Array | null;
|
|
@@ -48,7 +50,7 @@ export declare class PropTween {
|
|
|
48
50
|
/**
|
|
49
51
|
* Initialize the PropTween with scalar values
|
|
50
52
|
*/
|
|
51
|
-
init(target: AnimationTarget, property: string, startValue: number, endValue: number, unit?: string): this;
|
|
53
|
+
init(target: AnimationTarget, property: string, startValue: number, endValue: number, unit?: string, startUnit?: string, endUnit?: string): this;
|
|
52
54
|
/**
|
|
53
55
|
* Initialize the PropTween with color values
|
|
54
56
|
*/
|
package/dist/core/Timeline.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare class Timeline {
|
|
|
34
34
|
static setEngineActivationCallback(callback: () => void): void;
|
|
35
35
|
private _name?;
|
|
36
36
|
private _children;
|
|
37
|
+
private _initialRenderStartTimes;
|
|
37
38
|
private _duration;
|
|
38
39
|
private _time;
|
|
39
40
|
private _progress;
|
|
@@ -127,6 +128,9 @@ export declare class Timeline {
|
|
|
127
128
|
* Internal method to add an AnimationBuilder directly
|
|
128
129
|
*/
|
|
129
130
|
private _addBuilder;
|
|
131
|
+
private _getInitialRenderStartTimes;
|
|
132
|
+
private _renderAnimationInitialBoundary;
|
|
133
|
+
private _renderInitialTimelineState;
|
|
130
134
|
/**
|
|
131
135
|
* Call function at position
|
|
132
136
|
*/
|
|
@@ -294,7 +298,8 @@ export declare class Timeline {
|
|
|
294
298
|
*/
|
|
295
299
|
private _resetChildrenForCycle;
|
|
296
300
|
/**
|
|
297
|
-
* Render
|
|
301
|
+
* Render initial start values without letting later timeline segments
|
|
302
|
+
* overwrite earlier segments for the same target/property.
|
|
298
303
|
*/
|
|
299
304
|
private _renderPositionZeroAnimations;
|
|
300
305
|
/**
|