@motion.page/sdk 0.1.0 → 0.1.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.
@@ -117,6 +117,13 @@ export declare class TriggerManager {
117
117
  * Refresh all position-based triggers after layout changes (e.g. window resize).
118
118
  * This includes scroll triggers, hover event triggers, gesture triggers, and
119
119
  * mouseMove triggers — all of which cache element bounds at setup time.
120
+ *
121
+ * Scroll triggers are refreshed in DOM document order (top to bottom).
122
+ * This ensures that when a pinned trigger's spacer size changes during refresh,
123
+ * triggers lower in the page measure the already-updated spacer positions rather
124
+ * than stale pre-refresh values. Non-pinned triggers (no pin manager / layout
125
+ * rect) are always sorted after pinned ones so they benefit from all spacer
126
+ * updates before recalculating their own positions.
120
127
  */
121
128
  refreshScrollTriggers(): void;
122
129
  /**
@@ -1,10 +1,15 @@
1
1
  /**
2
- * Returns the element's bounding rect as if no CSS transform were applied.
3
- * Temporarily strips the inline transform, measures, then restores it.
2
+ * Returns the element's bounding rect as if no CSS transform or position:fixed were applied.
3
+ * Temporarily strips inline transforms and any fixed positioning, measures, then restores.
4
4
  * This gives us the "layout" position in the document flow.
5
5
  *
6
6
  * Used by ScrollTrigger and MarkerManager to compute trigger positions and
7
7
  * marker placements relative to the element's original layout position,
8
- * regardless of any animation transforms currently applied.
8
+ * regardless of any animation transforms or pin states currently applied.
9
+ *
10
+ * Handles position:fixed elements: a fixed element returns viewport-relative
11
+ * coordinates from getBoundingClientRect(), which would produce incorrect
12
+ * document-relative trigger positions. Temporarily clearing position/top/left/width
13
+ * restores document-flow measurement before reading the rect.
9
14
  */
10
15
  export declare function getLayoutRect(element: Element): DOMRect;
package/llms.txt ADDED
@@ -0,0 +1,64 @@
1
+ # @motion.page/sdk
2
+
3
+ > Zero-dependency animation SDK with named timelines, 8 trigger types, text splitting, FLIP morphing, custom cursors, and SVG drawing. Browser-only (requires document/window).
4
+
5
+ For complete SDK documentation, install the motion-page skill: `npx skills add motion-page/claude-plugin`
6
+
7
+ ## Getting Started
8
+
9
+ - **Installation**: npm install @motion.page/sdk; ESM, CJS, and browser IIFE builds
10
+ - **Quick Start**: Basic fade-in, scroll-triggered, and multi-step timeline examples
11
+ - **Core Concept**: Named timelines — Motion(name) retrieves or creates; same name = same instance
12
+ - **Implicit Values**: from-only resolves current CSS as to; to-only resolves current CSS as from; natural defaults (opacity:1, x:0, y:0, scale:1) are auto-filled
13
+
14
+ ## Core API
15
+
16
+ - **Motion()**: Factory with 3 overloads — retrieve timeline, single animation, multi-step array
17
+ - **Motion.set()**: Instant property setting (zero duration)
18
+ - **Motion.kill() / killAll()**: Destroy named timelines; killAll for SPA cleanup
19
+ - **Motion.reset()**: Kill tweens on targets and revert text splits
20
+ - **Motion.refreshScrollTriggers()**: Recalculate scroll positions after DOM changes
21
+ - **Motion.cleanup()**: Remove ScrollTrigger spacer/marker DOM nodes
22
+ - **Motion.utils**: toArray, clamp, random, snap, interpolate, mapRange, normalize, wrap — all support currying
23
+
24
+ ## Timeline
25
+
26
+ - **Playback Control**: play, pause, reverse, restart, seek
27
+ - **State**: progress, time, timeScale, duration, isActive — getter/setter pattern
28
+ - **Lifecycle Callbacks**: onStart, onUpdate(progress, time), onComplete
29
+ - **Sequencing**: tl.call(fn, params, position) — fire functions at timeline positions
30
+
31
+ ## Triggers
32
+
33
+ - **.onPageLoad()**: Auto-play when DOM ready
34
+ - **.onScroll(config)**: start, end, scrub, pin, pinSpacing, markers, toggleActions, snap, scroller
35
+ - **.onHover(config)**: target, each, onLeave (reverse/pause/stop/restart/none), leaveDelay
36
+ - **.onClick(config)**: target, each, toggle (reverse/restart/play), secondTarget, preventDefault
37
+ - **.onMouseMove(config)**: type (distance/axis), smooth, startProgress, leaveProgress
38
+ - **.onGesture(config)**: types (pointer/touch/wheel/scroll), events map, tolerance, dragMinimum, lockAxis
39
+ - **.onCursor(config)**: type (basic/text/media), smooth, squeeze, hideNative, default/hover/click states
40
+ - **.onPageExit(config)**: mode (all/include/exclude), selectors, skipHref
41
+
42
+ ## Animation Config
43
+
44
+ - **AnimationConfig**: from, to, duration, delay, ease, stagger, repeat, split, mask, fit, axis, callbacks
45
+ - **AnimationVars**: Transforms, opacity, colors, CSS properties, filter, drawSVG, path, custom properties
46
+ - **Easing**: power1-4, sine, expo, circ, back, elastic, bounce — .in/.out/.inOut
47
+ - **Stagger**: each, amount, from (start/center/edges/random/end/index), grid, axis, ease
48
+ - **Position Parameter**: Absolute (number), relative (+=/-=), anchored (<, >, <0.2, >-0.1)
49
+
50
+ ## Features
51
+
52
+ - **Text Splitting**: split: chars/words/lines; mask: true for clip reveals; data-split-* attributes
53
+ - **FLIP Morphing**: fit: { target, scale, resize, absolute } — animate between element states
54
+ - **DrawSVG**: String format ("0% 100%") or object ({ start, end } as 0-100 percentages)
55
+ - **Motion Path**: path: { target, align, start, end, rotate }
56
+ - **Custom Cursors**: type: basic/text/media; mp-cursor-text and mp-cursor-media HTML attributes
57
+
58
+ ## Optional
59
+
60
+ - **Types Reference**: All exported TypeScript types and interfaces
61
+ - **Browser Build**: IIFE bundle exposing window.Motion and window.MotionTimeline
62
+ - **SPA Cleanup**: Motion.killAll() + Motion.cleanup() on route change
63
+ - **Migration from GSAP**: gsap.to → Motion(name, target, {to}).play(); ScrollTrigger → .onScroll()
64
+ - **Migration from Framer Motion**: motion.div → Motion(name, selector, config); whileHover → .onHover()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@motion.page/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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",
@@ -14,7 +14,8 @@
14
14
  }
15
15
  },
16
16
  "files": [
17
- "dist"
17
+ "dist",
18
+ "llms.txt"
18
19
  ],
19
20
  "scripts": {
20
21
  "build": "rm -rf dist && tsc -p tsconfig.build.json && bun build src/index.ts --outdir dist --minify --sourcemap=linked && mkdir -p dist/.cjs-tmp && bun build src/index.ts --outdir dist/.cjs-tmp --format=cjs --minify --sourcemap=linked && mv dist/.cjs-tmp/index.js dist/index.cjs && mv dist/.cjs-tmp/index.js.map dist/index.cjs.map && rm -rf dist/.cjs-tmp",
@@ -42,12 +43,7 @@
42
43
  "transform"
43
44
  ],
44
45
  "author": "Motion.page",
45
- "license": "SEE LICENSE IN LICENSE",
46
- "repository": {
47
- "type": "git",
48
- "url": "https://github.com/nicDamours/motion.page",
49
- "directory": "packages/sdk"
50
- },
46
+ "license": "FSL-1.1-Apache-2.0",
51
47
  "homepage": "https://motion.page",
52
48
  "engines": {
53
49
  "node": ">=18"