use-scroll-animate 4.9.0 → 5.1.0

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.
Files changed (226) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +2 -1
  3. package/README_ja.md +1 -0
  4. package/README_zh.md +2 -1
  5. package/dist/chunks/{base-BvpQ4Ggj.cjs → base-B5i8qQPR.cjs} +46 -40
  6. package/dist/chunks/base-B5i8qQPR.cjs.map +1 -0
  7. package/dist/chunks/{base-DbbRUxaa.js → base-C3Sw9sAO.js} +46 -41
  8. package/dist/chunks/base-C3Sw9sAO.js.map +1 -0
  9. package/dist/chunks/{core-BWO7JKJ5.cjs → core-BDcszY4L.cjs} +2 -2
  10. package/dist/chunks/{core-BWO7JKJ5.cjs.map → core-BDcszY4L.cjs.map} +1 -1
  11. package/dist/chunks/{core-CcaSsbV8.js → core-BTf__I-8.js} +2 -2
  12. package/dist/chunks/{core-CcaSsbV8.js.map → core-BTf__I-8.js.map} +1 -1
  13. package/dist/chunks/{core-CCAM3nKw.cjs → core-BjOYKSrV.cjs} +2 -2
  14. package/dist/chunks/{core-CCAM3nKw.cjs.map → core-BjOYKSrV.cjs.map} +1 -1
  15. package/dist/chunks/{core-BVTuet9o.js → core-DN3hHbHh.js} +2 -2
  16. package/dist/chunks/{core-BVTuet9o.js.map → core-DN3hHbHh.js.map} +1 -1
  17. package/dist/chunks/fx-B8hk1Fby.cjs +114 -0
  18. package/dist/chunks/fx-B8hk1Fby.cjs.map +1 -0
  19. package/dist/chunks/fx-ChjxrMBo.js +109 -0
  20. package/dist/chunks/fx-ChjxrMBo.js.map +1 -0
  21. package/dist/chunks/{index-tags-Dh8nwXqw.js → index-tags-DucKMQr_.js} +2 -1
  22. package/dist/chunks/{index-tags-Dh8nwXqw.js.map → index-tags-DucKMQr_.js.map} +1 -1
  23. package/dist/chunks/{index-tags-CIRY2KnU.cjs → index-tags-wv0R_vkO.cjs} +2 -1
  24. package/dist/chunks/{index-tags-CIRY2KnU.cjs.map → index-tags-wv0R_vkO.cjs.map} +1 -1
  25. package/dist/chunks/{spring-fFkqE9J0.cjs → spring--oZh55tB.cjs} +2 -2
  26. package/dist/chunks/{spring-fFkqE9J0.cjs.map → spring--oZh55tB.cjs.map} +1 -1
  27. package/dist/chunks/{spring-B6w7mVCU.js → spring-CckMe3x0.js} +2 -2
  28. package/dist/chunks/{spring-B6w7mVCU.js.map → spring-CckMe3x0.js.map} +1 -1
  29. package/dist/chunks/{variants-Cal4DB0E.js → variants-Bsevy6Xm.js} +2 -2
  30. package/dist/chunks/{variants-Cal4DB0E.js.map → variants-Bsevy6Xm.js.map} +1 -1
  31. package/dist/chunks/{variants-C8xj8gfd.cjs → variants-DxPmgrNX.cjs} +2 -2
  32. package/dist/chunks/{variants-C8xj8gfd.cjs.map → variants-DxPmgrNX.cjs.map} +1 -1
  33. package/dist/components/a11y.cjs +3 -2
  34. package/dist/components/a11y.cjs.map +1 -1
  35. package/dist/components/a11y.d.cts +1 -0
  36. package/dist/components/a11y.d.ts +1 -0
  37. package/dist/components/a11y.js +4 -3
  38. package/dist/components/a11y.js.map +1 -1
  39. package/dist/components/angular.cjs +8 -6
  40. package/dist/components/angular.cjs.map +1 -1
  41. package/dist/components/angular.d.cts +33 -4
  42. package/dist/components/angular.d.ts +33 -4
  43. package/dist/components/angular.js +8 -6
  44. package/dist/components/angular.js.map +1 -1
  45. package/dist/components/background.cjs +2 -4
  46. package/dist/components/background.cjs.map +1 -1
  47. package/dist/components/background.d.cts +2 -47
  48. package/dist/components/background.d.ts +2 -47
  49. package/dist/components/background.js +3 -4
  50. package/dist/components/background.js.map +1 -1
  51. package/dist/components/bridge.cjs +1 -1
  52. package/dist/components/bridge.js +1 -1
  53. package/dist/components/cards.cjs +2 -4
  54. package/dist/components/cards.cjs.map +1 -1
  55. package/dist/components/cards.d.cts +2 -47
  56. package/dist/components/cards.d.ts +2 -47
  57. package/dist/components/cards.js +2 -3
  58. package/dist/components/cards.js.map +1 -1
  59. package/dist/components/click.cjs +24 -130
  60. package/dist/components/click.cjs.map +1 -1
  61. package/dist/components/click.d.cts +2 -47
  62. package/dist/components/click.d.ts +2 -47
  63. package/dist/components/click.js +4 -109
  64. package/dist/components/click.js.map +1 -1
  65. package/dist/components/depth.cjs +3 -5
  66. package/dist/components/depth.cjs.map +1 -1
  67. package/dist/components/depth.d.cts +2 -47
  68. package/dist/components/depth.d.ts +2 -47
  69. package/dist/components/depth.js +3 -4
  70. package/dist/components/depth.js.map +1 -1
  71. package/dist/components/effects.cjs +265 -0
  72. package/dist/components/effects.cjs.map +1 -0
  73. package/dist/components/effects.d.cts +66 -0
  74. package/dist/components/effects.d.ts +66 -0
  75. package/dist/components/effects.js +258 -0
  76. package/dist/components/effects.js.map +1 -0
  77. package/dist/components/feedback.cjs +1 -3
  78. package/dist/components/feedback.cjs.map +1 -1
  79. package/dist/components/feedback.d.cts +2 -47
  80. package/dist/components/feedback.d.ts +2 -47
  81. package/dist/components/feedback.js +1 -2
  82. package/dist/components/feedback.js.map +1 -1
  83. package/dist/components/fx.cjs +289 -0
  84. package/dist/components/fx.cjs.map +1 -0
  85. package/dist/components/fx.css +3 -0
  86. package/dist/components/fx.d.cts +114 -0
  87. package/dist/components/fx.d.ts +114 -0
  88. package/dist/components/fx.js +275 -0
  89. package/dist/components/fx.js.map +1 -0
  90. package/dist/components/gesture.cjs +3 -5
  91. package/dist/components/gesture.cjs.map +1 -1
  92. package/dist/components/gesture.d.cts +2 -47
  93. package/dist/components/gesture.d.ts +2 -47
  94. package/dist/components/gesture.js +4 -5
  95. package/dist/components/gesture.js.map +1 -1
  96. package/dist/components/interaction.cjs +1 -3
  97. package/dist/components/interaction.cjs.map +1 -1
  98. package/dist/components/interaction.d.cts +2 -47
  99. package/dist/components/interaction.d.ts +2 -47
  100. package/dist/components/interaction.js +1 -2
  101. package/dist/components/interaction.js.map +1 -1
  102. package/dist/components/jsx.d.cts +1 -0
  103. package/dist/components/jsx.d.ts +1 -0
  104. package/dist/components/layout.cjs +1 -3
  105. package/dist/components/layout.cjs.map +1 -1
  106. package/dist/components/layout.d.cts +2 -47
  107. package/dist/components/layout.d.ts +2 -47
  108. package/dist/components/layout.js +2 -3
  109. package/dist/components/layout.js.map +1 -1
  110. package/dist/components/lazy.cjs +2 -1
  111. package/dist/components/lazy.cjs.map +1 -1
  112. package/dist/components/lazy.d.cts +1 -0
  113. package/dist/components/lazy.d.ts +1 -0
  114. package/dist/components/lazy.js +2 -1
  115. package/dist/components/lazy.js.map +1 -1
  116. package/dist/components/lite.cjs +366 -64
  117. package/dist/components/lite.cjs.map +1 -1
  118. package/dist/components/lite.js +349 -65
  119. package/dist/components/lite.js.map +1 -1
  120. package/dist/components/packs.cjs +1 -3
  121. package/dist/components/packs.cjs.map +1 -1
  122. package/dist/components/packs.d.cts +2 -47
  123. package/dist/components/packs.d.ts +2 -47
  124. package/dist/components/packs.js +2 -3
  125. package/dist/components/packs.js.map +1 -1
  126. package/dist/components/page.cjs +33 -22
  127. package/dist/components/page.cjs.map +1 -1
  128. package/dist/components/page.d.cts +15 -52
  129. package/dist/components/page.d.ts +15 -52
  130. package/dist/components/page.js +33 -22
  131. package/dist/components/page.js.map +1 -1
  132. package/dist/components/perf.cjs +3 -4
  133. package/dist/components/perf.cjs.map +1 -1
  134. package/dist/components/perf.d.cts +1 -0
  135. package/dist/components/perf.d.ts +1 -0
  136. package/dist/components/perf.js +4 -5
  137. package/dist/components/perf.js.map +1 -1
  138. package/dist/components/physics.cjs +2 -4
  139. package/dist/components/physics.cjs.map +1 -1
  140. package/dist/components/physics.d.cts +2 -47
  141. package/dist/components/physics.d.ts +2 -47
  142. package/dist/components/physics.js +3 -4
  143. package/dist/components/physics.js.map +1 -1
  144. package/dist/components/react.cjs +1 -1
  145. package/dist/components/react.js +1 -1
  146. package/dist/components/reveal.cjs +1 -3
  147. package/dist/components/reveal.cjs.map +1 -1
  148. package/dist/components/reveal.d.cts +2 -47
  149. package/dist/components/reveal.d.ts +2 -47
  150. package/dist/components/reveal.js +1 -2
  151. package/dist/components/reveal.js.map +1 -1
  152. package/dist/components/solid.cjs +8 -6
  153. package/dist/components/solid.cjs.map +1 -1
  154. package/dist/components/solid.d.cts +33 -4
  155. package/dist/components/solid.d.ts +33 -4
  156. package/dist/components/solid.js +8 -6
  157. package/dist/components/solid.js.map +1 -1
  158. package/dist/components/svelte.cjs +8 -6
  159. package/dist/components/svelte.cjs.map +1 -1
  160. package/dist/components/svelte.d.cts +33 -4
  161. package/dist/components/svelte.d.ts +33 -4
  162. package/dist/components/svelte.js +8 -6
  163. package/dist/components/svelte.js.map +1 -1
  164. package/dist/components/svg.cjs +1 -3
  165. package/dist/components/svg.cjs.map +1 -1
  166. package/dist/components/svg.d.cts +2 -47
  167. package/dist/components/svg.d.ts +2 -47
  168. package/dist/components/svg.js +2 -3
  169. package/dist/components/svg.js.map +1 -1
  170. package/dist/components/text.cjs +2 -4
  171. package/dist/components/text.cjs.map +1 -1
  172. package/dist/components/text.d.cts +2 -47
  173. package/dist/components/text.d.ts +2 -47
  174. package/dist/components/text.js +2 -3
  175. package/dist/components/text.js.map +1 -1
  176. package/dist/components/timeline.cjs +3 -7
  177. package/dist/components/timeline.cjs.map +1 -1
  178. package/dist/components/timeline.d.cts +4 -49
  179. package/dist/components/timeline.d.ts +4 -49
  180. package/dist/components/timeline.js +4 -7
  181. package/dist/components/timeline.js.map +1 -1
  182. package/dist/components/transitions.cjs +1 -3
  183. package/dist/components/transitions.cjs.map +1 -1
  184. package/dist/components/transitions.d.cts +2 -47
  185. package/dist/components/transitions.d.ts +2 -47
  186. package/dist/components/transitions.js +2 -3
  187. package/dist/components/transitions.js.map +1 -1
  188. package/dist/components/ui.cjs +3 -5
  189. package/dist/components/ui.cjs.map +1 -1
  190. package/dist/components/ui.d.cts +2 -47
  191. package/dist/components/ui.d.ts +2 -47
  192. package/dist/components/ui.js +4 -5
  193. package/dist/components/ui.js.map +1 -1
  194. package/dist/components/vue.cjs +8 -6
  195. package/dist/components/vue.cjs.map +1 -1
  196. package/dist/components/vue.d.cts +33 -4
  197. package/dist/components/vue.d.ts +33 -4
  198. package/dist/components/vue.js +8 -6
  199. package/dist/components/vue.js.map +1 -1
  200. package/dist/components/webgl.cjs +3 -5
  201. package/dist/components/webgl.cjs.map +1 -1
  202. package/dist/components/webgl.d.cts +2 -47
  203. package/dist/components/webgl.d.ts +2 -47
  204. package/dist/components/webgl.js +3 -4
  205. package/dist/components/webgl.js.map +1 -1
  206. package/dist/components.cjs +31 -10
  207. package/dist/components.cjs.map +1 -1
  208. package/dist/components.css +1 -0
  209. package/dist/components.d.cts +137 -17
  210. package/dist/components.d.ts +137 -17
  211. package/dist/components.js +15 -11
  212. package/dist/components.js.map +1 -1
  213. package/dist/components.umd.js +2 -2
  214. package/dist/components.umd.js.map +1 -1
  215. package/dist/index.cjs +2 -2
  216. package/dist/index.js +2 -2
  217. package/dist/index.umd.js +1 -1
  218. package/dist/index.umd.js.map +1 -1
  219. package/docs/API.md +1 -1
  220. package/docs/ROADMAP.md +12 -12
  221. package/docs/components.md +29 -1
  222. package/docs/performance.md +1 -1
  223. package/docs/upgrading-5.md +2 -2
  224. package/package.json +24 -3
  225. package/dist/chunks/base-BvpQ4Ggj.cjs.map +0 -1
  226. package/dist/chunks/base-DbbRUxaa.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"depth.cjs","sources":["../../src/components/depth/cube.ts","../../src/components/depth/core.ts","../../src/components/depth/depth-el.ts","../../src/components/depth/index.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { createSpring, type SpringValue } from '../physics/spring';\nimport { gesture } from '../gesture/core';\nimport css from './depth.css?raw';\n\nconst FACES = ['front', 'right', 'back', 'left', 'top', 'bottom'] as const;\n/** Rotation (deg) that brings each face to the front. */\nconst ROT: Record<string, [number, number]> = { front: [0, 0], right: [0, -90], back: [0, -180], left: [0, 90], top: [-90, 0], bottom: [90, 0] };\n\n/**\n * `<usa-cube>` — a CSS 3D cube whose up-to-six element children are its faces\n * (front, right, back, left, top, bottom). Rotate with drag / swipe, arrow\n * keys, `autoplay` (ms) or `show(face | index)`; spring-driven.\n * Attributes: `size` (px, 200), `autoplay`, `perspective` (900).\n * `usa:change` (`{ index, face }`). Reduced motion: instant face switch.\n */\nexport interface UsaCubeElement extends UsaElement {\n readonly index: number;\n show(face: number | string): void;\n next(): void;\n prev(): void;\n}\n\nexport function defineCube(tag = 'usa-cube'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaCube extends Base {\n static get observedAttributes(): string[] {\n return ['size', 'autoplay'];\n }\n private _i = 0;\n private _rx!: SpringValue;\n private _ry!: SpringValue;\n private _base: [number, number] = [0, 0];\n\n get index(): number {\n return this._i;\n }\n\n private faces(): HTMLElement[] {\n return Array.from(this.children).filter((c) => c instanceof HTMLElement && !c.hasAttribute('slot')).slice(0, 6) as HTMLElement[];\n }\n\n private paint(): void {\n this.style.setProperty('--usa-cube-rx', `${this._rx.value}deg`);\n this.style.setProperty('--usa-cube-ry', `${this._ry.value}deg`);\n }\n\n show(face: number | string): void {\n const n = this.faces().length || 1;\n const i = typeof face === 'number' ? ((face % n) + n) % n : Math.max(0, FACES.indexOf(face as any));\n this._i = i;\n const [rx, ry] = ROT[FACES[i]];\n // take the shortest way round on Y\n const cur = this._ry.target;\n const ty = ry + Math.round((cur - ry) / 360) * 360;\n this._base = [rx, ty];\n if (this.reduced) {\n this._rx.jump(rx);\n this._ry.jump(ty);\n } else {\n this._rx.set(rx);\n this._ry.set(ty);\n }\n this.faces().forEach((f, j) => f.setAttribute('aria-hidden', String(j !== i)));\n this.emit('change', { index: i, face: FACES[i] });\n }\n\n next(): void {\n this.show(this._i + 1);\n }\n\n prev(): void {\n this.show(this._i - 1);\n }\n\n mount(): void {\n this.style.setProperty('--usa-cube-size', `${this.num('size', 200)}px`);\n this.style.setProperty('--usa-cube-perspective', `${this.num('perspective', 900)}px`);\n this.faces().forEach((f, j) => f.setAttribute('data-face', FACES[j]));\n if (!this.hasAttribute('tabindex')) this.tabIndex = 0;\n if (!this.hasAttribute('role')) this.setAttribute('role', 'region');\n if (!this.hasAttribute('aria-roledescription')) this.setAttribute('aria-roledescription', 'cube');\n this._rx = createSpring({ spring: 'gentle', onUpdate: () => this.paint() });\n this._ry = createSpring({ spring: 'gentle', onUpdate: () => this.paint() });\n this.show(this._i);\n this.paint();\n this.onCleanup(\n gesture(this, {\n onPan: ({ dx, dy, last }) => {\n if (this.reduced) return;\n if (!last) {\n this._ry.jump(this._base[1] + dx * 0.5);\n this._rx.jump(this._base[0] - dy * 0.5);\n return;\n }\n if (Math.abs(dx) > 40 && Math.abs(dx) >= Math.abs(dy)) return dx < 0 ? this.next() : this.prev();\n if (Math.abs(dy) > 40 && this.faces().length > 4) return this.show(dy < 0 ? 'bottom' : 'top');\n this.show(this._i);\n },\n })\n );\n this.listen(this, 'keydown', (e: KeyboardEvent) => {\n const k: Record<string, () => void> = { ArrowRight: () => this.next(), ArrowLeft: () => this.prev(), ArrowUp: () => this.show('bottom'), ArrowDown: () => this.show('top'), Home: () => this.show(0) };\n if (!k[e.key] || ((e.key === 'ArrowUp' || e.key === 'ArrowDown') && this.faces().length < 6)) return;\n e.preventDefault();\n k[e.key]();\n });\n const ms = this.num('autoplay', 0);\n if (ms > 0 && !this.reduced) {\n let paused = false;\n const id = setInterval(() => !paused && this.show((this._i + 1) % Math.min(4, this.faces().length || 1)), ms);\n this.listen(this, 'pointerenter', () => (paused = true));\n this.listen(this, 'pointerleave', () => (paused = false));\n this.listen(this, 'focusin', () => (paused = true));\n this.listen(this, 'focusout', () => (paused = false));\n this.onCleanup(() => clearInterval(id));\n }\n }\n\n unmount(): void {\n this._rx?.stop();\n this._ry?.stop();\n }\n },\n { id: 'depth', text: css }\n );\n}\n","import { clamp } from '../base';\n\nexport interface TiltReading {\n /** Left/right tilt, -1…1. */\n x: number;\n /** Front/back tilt, -1…1. */\n y: number;\n}\n\n/** Map a DeviceOrientation reading (beta/gamma degrees) to -1…1 tilt around a resting pose (pure). */\nexport function orientationToTilt(beta: number | null, gamma: number | null, range = 30, rest = 45): TiltReading {\n return {\n x: clamp((gamma ?? 0) / range, -1, 1),\n y: clamp(((beta ?? rest) - rest) / range, -1, 1),\n };\n}\n\n/** `true` when DeviceOrientation events exist. */\nexport const supportsOrientation = (): boolean => typeof window !== 'undefined' && 'DeviceOrientationEvent' in window;\n\n/**\n * Ask for motion-sensor permission where required (iOS 13+; must run inside\n * a user gesture). Resolves `true` when tilt events can be used.\n */\nexport async function requestOrientationPermission(): Promise<boolean> {\n if (!supportsOrientation()) return false;\n const D = (window as any).DeviceOrientationEvent;\n if (typeof D.requestPermission !== 'function') return true;\n try {\n return (await D.requestPermission()) === 'granted';\n } catch {\n return false;\n }\n}\n\n/**\n * Listen to device tilt (smoothed); falls back to nothing on desktops.\n * Returns a stop function.\n */\nexport function deviceTilt(cb: (t: TiltReading) => void, o: { range?: number; smooth?: number } = {}): () => void {\n if (!supportsOrientation()) return () => {};\n let cur: TiltReading = { x: 0, y: 0 };\n const k = 1 - clamp(o.smooth ?? 0.2, 0, 0.95);\n const on = (e: DeviceOrientationEvent) => {\n const t = orientationToTilt(e.beta, e.gamma, o.range ?? 30);\n cur = { x: cur.x + (t.x - cur.x) * k, y: cur.y + (t.y - cur.y) * k };\n cb(cur);\n };\n window.addEventListener('deviceorientation', on);\n return () => window.removeEventListener('deviceorientation', on);\n}\n","import { defineElement, raf, caf, clamp, type UsaElement } from '../base';\nimport { deviceTilt, requestOrientationPermission, supportsOrientation } from './core';\nimport css from './depth.css?raw';\n\n/**\n * `<usa-depth>` — depth parallax: children with `data-depth` (-1…1, 0 = the\n * screen plane) move and scale by depth as the pointer moves, the device\n * tilts (`orientation`) or the page scrolls (`scroll`).\n * Attributes: `source` (`pointer` default · `orientation` · `scroll` ·\n * space-separated mix), `strength` (px at depth 1, 40), `rotate` (max tilt\n * of the whole scene in deg, 0). `requestPermission()` for iOS motion.\n * Reduced motion: layers stay flat.\n */\nexport interface UsaDepthElement extends UsaElement {\n /** Current -1…1 input. */\n readonly tilt: { x: number; y: number };\n requestPermission(): Promise<boolean>;\n}\n\nexport function defineDepth(tag = 'usa-depth'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaDepth extends Base {\n static get observedAttributes(): string[] {\n return ['source', 'strength', 'rotate'];\n }\n private _t = { x: 0, y: 0 };\n private _id = 0;\n\n get tilt(): { x: number; y: number } {\n return { ...this._t };\n }\n\n requestPermission(): Promise<boolean> {\n return requestOrientationPermission().then((ok) => {\n if (ok) {\n this.changed('source');\n }\n return ok;\n });\n }\n\n private apply(): void {\n this._id = 0;\n const s = this.num('strength', 40);\n const r = this.num('rotate', 0);\n const { x, y } = this._t;\n this.style.setProperty('--usa-depth-x', x.toFixed(4));\n this.style.setProperty('--usa-depth-y', y.toFixed(4));\n if (r) this.style.setProperty('--usa-depth-rot', `rotateX(${(-y * r).toFixed(2)}deg) rotateY(${(x * r).toFixed(2)}deg)`);\n this.querySelectorAll<HTMLElement>('[data-depth]').forEach((el) => {\n const d = clamp(Number(el.dataset.depth) || 0, -1, 1);\n el.style.transform = `translate3d(${(x * d * s).toFixed(2)}px, ${(y * d * s).toFixed(2)}px, 0) scale(${(1 + d * 0.04).toFixed(4)})`;\n });\n }\n\n private set(x: number, y: number): void {\n this._t = { x: clamp(x, -1, 1), y: clamp(y, -1, 1) };\n if (!this._id) this._id = raf(() => this.apply());\n }\n\n mount(): void {\n if (this.reduced) return;\n const src = this.str('source', 'pointer').split(/\\s+/);\n if (src.includes('pointer')) {\n this.listen(this, 'pointermove', (e: PointerEvent) => {\n const r = this.getBoundingClientRect();\n this.set(((e.clientX - r.left) / (r.width || 1)) * 2 - 1, ((e.clientY - r.top) / (r.height || 1)) * 2 - 1);\n });\n this.listen(this, 'pointerleave', () => this.set(0, 0));\n }\n if (src.includes('orientation') && supportsOrientation()) this.onCleanup(deviceTilt((t) => this.set(t.x, t.y)));\n if (src.includes('scroll')) {\n const on = () => {\n const r = this.getBoundingClientRect();\n const vh = window.innerHeight || 1;\n this.set(this._t.x, clamp(((r.top + r.height / 2) / vh) * 2 - 1, -1, 1));\n };\n this.listen(window, 'scroll', on, { passive: true });\n on();\n }\n this.onCleanup(() => {\n caf(this._id);\n this._id = 0;\n });\n }\n\n unmount(): void {\n this._t = { x: 0, y: 0 };\n this.querySelectorAll<HTMLElement>('[data-depth]').forEach((el) => (el.style.transform = ''));\n }\n },\n { id: 'depth', text: css }\n );\n}\n","/**\n * use-scroll-animate/components/depth — 3D (v3.5).\n * `<usa-cube>` (CSS 3D cube), `<usa-depth>` (layered depth parallax driven by\n * pointer, device orientation or scroll) and `deviceTilt()`. The 3D ring\n * carousel is `<usa-carousel-3d>` in `components/cards`.\n */\nimport { defineCube, type UsaCubeElement } from './cube';\nimport { defineDepth, type UsaDepthElement } from './depth-el';\n\nexport { defineCube, defineDepth };\nexport { deviceTilt, orientationToTilt, requestOrientationPermission, supportsOrientation } from './core';\nexport type { TiltReading } from './core';\nexport type { UsaCubeElement, UsaDepthElement };\nexport { configureComponents, prefersReducedMotion } from '../base';\nexport type { ComponentsConfig, UsaElement } from '../base';\n\n/** Register every component of this category under its default tag. */\nexport function defineDepthComponents(): void {\n defineCube();\n defineDepth();\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'usa-cube': UsaCubeElement;\n 'usa-depth': UsaDepthElement;\n }\n}\n"],"names":["defineElement","createSpring","gesture","clamp","raf","caf"],"mappings":";;;;;;;;AAKA,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAU;AAC1E;AACA,MAAM,GAAG,GAAqC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE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AG,CAAC;AACd,YAAA,CAAC,CAAC;QACJ;QAEA,OAAO,GAAA;AACL,YAAA,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;YACxB,IAAI,CAAC,gBAAgB,CAAc,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC,CAAC;QAC/F;KACD,EACH,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAC3B;AACH;;AC/FA;;;;;AAKG;AAWH;SACgB,qBAAqB,GAAA;AACnC,IAAA,UAAU,EAAE;AACZ,IAAA,WAAW,EAAE;AACf;;;;;;;;;;;;"}
1
+ {"version":3,"file":"depth.cjs","sources":["../../src/components/depth/cube.ts","../../src/components/depth/core.ts","../../src/components/depth/depth-el.ts","../../src/components/depth/index.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { createSpring, type SpringValue } from '../physics/spring';\nimport { gesture } from '../gesture/core';\nimport css from './depth.css?raw';\n\nconst FACES = ['front', 'right', 'back', 'left', 'top', 'bottom'] as const;\n/** Rotation (deg) that brings each face to the front. */\nconst ROT: Record<string, [number, number]> = { front: [0, 0], right: [0, -90], back: [0, -180], left: [0, 90], top: [-90, 0], bottom: [90, 0] };\n\n/**\n * `<usa-cube>` — a CSS 3D cube whose up-to-six element children are its faces\n * (front, right, back, left, top, bottom). Rotate with drag / swipe, arrow\n * keys, `autoplay` (ms) or `show(face | index)`; spring-driven.\n * Attributes: `size` (px, 200), `autoplay`, `perspective` (900).\n * `usa:change` (`{ index, face }`). Reduced motion: instant face switch.\n */\nexport interface UsaCubeElement extends UsaElement {\n readonly index: number;\n show(face: number | string): void;\n next(): void;\n prev(): void;\n}\n\nexport function defineCube(tag = 'usa-cube'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaCube extends Base {\n static get observedAttributes(): string[] {\n return ['size', 'autoplay'];\n }\n private _i = 0;\n private _rx!: SpringValue;\n private _ry!: SpringValue;\n private _base: [number, number] = [0, 0];\n\n get index(): number {\n return this._i;\n }\n\n private faces(): HTMLElement[] {\n return Array.from(this.children).filter((c) => c instanceof HTMLElement && !c.hasAttribute('slot')).slice(0, 6) as HTMLElement[];\n }\n\n private paint(): void {\n this.style.setProperty('--usa-cube-rx', `${this._rx.value}deg`);\n this.style.setProperty('--usa-cube-ry', `${this._ry.value}deg`);\n }\n\n show(face: number | string): void {\n const n = this.faces().length || 1;\n const i = typeof face === 'number' ? ((face % n) + n) % n : Math.max(0, FACES.indexOf(face as any));\n this._i = i;\n const [rx, ry] = ROT[FACES[i]];\n // take the shortest way round on Y\n const cur = this._ry.target;\n const ty = ry + Math.round((cur - ry) / 360) * 360;\n this._base = [rx, ty];\n if (this.reduced) {\n this._rx.jump(rx);\n this._ry.jump(ty);\n } else {\n this._rx.set(rx);\n this._ry.set(ty);\n }\n this.faces().forEach((f, j) => f.setAttribute('aria-hidden', String(j !== i)));\n this.emit('change', { index: i, face: FACES[i] });\n }\n\n next(): void {\n this.show(this._i + 1);\n }\n\n prev(): void {\n this.show(this._i - 1);\n }\n\n mount(): void {\n this.style.setProperty('--usa-cube-size', `${this.num('size', 200)}px`);\n this.style.setProperty('--usa-cube-perspective', `${this.num('perspective', 900)}px`);\n this.faces().forEach((f, j) => f.setAttribute('data-face', FACES[j]));\n if (!this.hasAttribute('tabindex')) this.tabIndex = 0;\n if (!this.hasAttribute('role')) this.setAttribute('role', 'region');\n if (!this.hasAttribute('aria-roledescription')) this.setAttribute('aria-roledescription', 'cube');\n this._rx = createSpring({ spring: 'gentle', onUpdate: () => this.paint() });\n this._ry = createSpring({ spring: 'gentle', onUpdate: () => this.paint() });\n this.show(this._i);\n this.paint();\n this.onCleanup(\n gesture(this, {\n onPan: ({ dx, dy, last }) => {\n if (this.reduced) return;\n if (!last) {\n this._ry.jump(this._base[1] + dx * 0.5);\n this._rx.jump(this._base[0] - dy * 0.5);\n return;\n }\n if (Math.abs(dx) > 40 && Math.abs(dx) >= Math.abs(dy)) return dx < 0 ? this.next() : this.prev();\n if (Math.abs(dy) > 40 && this.faces().length > 4) return this.show(dy < 0 ? 'bottom' : 'top');\n this.show(this._i);\n },\n })\n );\n this.listen(this, 'keydown', (e: KeyboardEvent) => {\n const k: Record<string, () => void> = { ArrowRight: () => this.next(), ArrowLeft: () => this.prev(), ArrowUp: () => this.show('bottom'), ArrowDown: () => this.show('top'), Home: () => this.show(0) };\n if (!k[e.key] || ((e.key === 'ArrowUp' || e.key === 'ArrowDown') && this.faces().length < 6)) return;\n e.preventDefault();\n k[e.key]();\n });\n const ms = this.num('autoplay', 0);\n if (ms > 0 && !this.reduced) {\n let paused = false;\n const id = setInterval(() => !paused && this.show((this._i + 1) % Math.min(4, this.faces().length || 1)), ms);\n this.listen(this, 'pointerenter', () => (paused = true));\n this.listen(this, 'pointerleave', () => (paused = false));\n this.listen(this, 'focusin', () => (paused = true));\n this.listen(this, 'focusout', () => (paused = false));\n this.onCleanup(() => clearInterval(id));\n }\n }\n\n unmount(): void {\n this._rx?.stop();\n this._ry?.stop();\n }\n },\n { id: 'depth', text: css }\n );\n}\n","import { clamp } from '../base';\n\nexport interface TiltReading {\n /** Left/right tilt, -1…1. */\n x: number;\n /** Front/back tilt, -1…1. */\n y: number;\n}\n\n/** Map a DeviceOrientation reading (beta/gamma degrees) to -1…1 tilt around a resting pose (pure). */\nexport function orientationToTilt(beta: number | null, gamma: number | null, range = 30, rest = 45): TiltReading {\n return {\n x: clamp((gamma ?? 0) / range, -1, 1),\n y: clamp(((beta ?? rest) - rest) / range, -1, 1),\n };\n}\n\n/** `true` when DeviceOrientation events exist. */\nexport const supportsOrientation = (): boolean => typeof window !== 'undefined' && 'DeviceOrientationEvent' in window;\n\n/**\n * Ask for motion-sensor permission where required (iOS 13+; must run inside\n * a user gesture). Resolves `true` when tilt events can be used.\n */\nexport async function requestOrientationPermission(): Promise<boolean> {\n if (!supportsOrientation()) return false;\n const D = (window as any).DeviceOrientationEvent;\n if (typeof D.requestPermission !== 'function') return true;\n try {\n return (await D.requestPermission()) === 'granted';\n } catch {\n return false;\n }\n}\n\n/**\n * Listen to device tilt (smoothed); falls back to nothing on desktops.\n * Returns a stop function.\n */\nexport function deviceTilt(cb: (t: TiltReading) => void, o: { range?: number; smooth?: number } = {}): () => void {\n if (!supportsOrientation()) return () => {};\n let cur: TiltReading = { x: 0, y: 0 };\n const k = 1 - clamp(o.smooth ?? 0.2, 0, 0.95);\n const on = (e: DeviceOrientationEvent) => {\n const t = orientationToTilt(e.beta, e.gamma, o.range ?? 30);\n cur = { x: cur.x + (t.x - cur.x) * k, y: cur.y + (t.y - cur.y) * k };\n cb(cur);\n };\n window.addEventListener('deviceorientation', on);\n return () => window.removeEventListener('deviceorientation', on);\n}\n","import { defineElement, raf, caf, clamp, type UsaElement } from '../base';\nimport { deviceTilt, requestOrientationPermission, supportsOrientation } from './core';\nimport css from './depth.css?raw';\n\n/**\n * `<usa-depth>` — depth parallax: children with `data-depth` (-1…1, 0 = the\n * screen plane) move and scale by depth as the pointer moves, the device\n * tilts (`orientation`) or the page scrolls (`scroll`).\n * Attributes: `source` (`pointer` default · `orientation` · `scroll` ·\n * space-separated mix), `strength` (px at depth 1, 40), `rotate` (max tilt\n * of the whole scene in deg, 0). `requestPermission()` for iOS motion.\n * Reduced motion: layers stay flat.\n */\nexport interface UsaDepthElement extends UsaElement {\n /** Current -1…1 input. */\n readonly tilt: { x: number; y: number };\n requestPermission(): Promise<boolean>;\n}\n\nexport function defineDepth(tag = 'usa-depth'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaDepth extends Base {\n static get observedAttributes(): string[] {\n return ['source', 'strength', 'rotate'];\n }\n private _t = { x: 0, y: 0 };\n private _id = 0;\n\n get tilt(): { x: number; y: number } {\n return { ...this._t };\n }\n\n requestPermission(): Promise<boolean> {\n return requestOrientationPermission().then((ok) => {\n if (ok) {\n this.changed('source');\n }\n return ok;\n });\n }\n\n private apply(): void {\n this._id = 0;\n const s = this.num('strength', 40);\n const r = this.num('rotate', 0);\n const { x, y } = this._t;\n this.style.setProperty('--usa-depth-x', x.toFixed(4));\n this.style.setProperty('--usa-depth-y', y.toFixed(4));\n if (r) this.style.setProperty('--usa-depth-rot', `rotateX(${(-y * r).toFixed(2)}deg) rotateY(${(x * r).toFixed(2)}deg)`);\n this.querySelectorAll<HTMLElement>('[data-depth]').forEach((el) => {\n const d = clamp(Number(el.dataset.depth) || 0, -1, 1);\n el.style.transform = `translate3d(${(x * d * s).toFixed(2)}px, ${(y * d * s).toFixed(2)}px, 0) scale(${(1 + d * 0.04).toFixed(4)})`;\n });\n }\n\n private set(x: number, y: number): void {\n this._t = { x: clamp(x, -1, 1), y: clamp(y, -1, 1) };\n if (!this._id) this._id = raf(() => this.apply());\n }\n\n mount(): void {\n if (this.reduced) return;\n const src = this.str('source', 'pointer').split(/\\s+/);\n if (src.includes('pointer')) {\n this.listen(this, 'pointermove', (e: PointerEvent) => {\n const r = this.getBoundingClientRect();\n this.set(((e.clientX - r.left) / (r.width || 1)) * 2 - 1, ((e.clientY - r.top) / (r.height || 1)) * 2 - 1);\n });\n this.listen(this, 'pointerleave', () => this.set(0, 0));\n }\n if (src.includes('orientation') && supportsOrientation()) this.onCleanup(deviceTilt((t) => this.set(t.x, t.y)));\n if (src.includes('scroll')) {\n const on = () => {\n const r = this.getBoundingClientRect();\n const vh = window.innerHeight || 1;\n this.set(this._t.x, clamp(((r.top + r.height / 2) / vh) * 2 - 1, -1, 1));\n };\n this.listen(window, 'scroll', on, { passive: true });\n on();\n }\n this.onCleanup(() => {\n caf(this._id);\n this._id = 0;\n });\n }\n\n unmount(): void {\n this._t = { x: 0, y: 0 };\n this.querySelectorAll<HTMLElement>('[data-depth]').forEach((el) => (el.style.transform = ''));\n }\n },\n { id: 'depth', text: css }\n );\n}\n","/**\n * use-scroll-animate/components/depth — 3D (v3.5).\n * `<usa-cube>` (CSS 3D cube), `<usa-depth>` (layered depth parallax driven by\n * pointer, device orientation or scroll) and `deviceTilt()`. The 3D ring\n * carousel is `<usa-carousel-3d>` in `components/cards`.\n */\nimport { defineCube, type UsaCubeElement } from './cube';\nimport { defineDepth, type UsaDepthElement } from './depth-el';\n\nexport { defineCube, defineDepth };\nexport { deviceTilt, orientationToTilt, requestOrientationPermission, supportsOrientation } from './core';\nexport type { TiltReading } from './core';\nexport type { UsaCubeElement, UsaDepthElement };\n\n/** Register every component of this category under its default tag. */\nexport function defineDepthComponents(): void {\n defineCube();\n defineDepth();\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'usa-cube': UsaCubeElement;\n 'usa-depth': UsaDepthElement;\n }\n}\n"],"names":["defineElement","createSpring","gesture","clamp","raf","caf"],"mappings":";;;;;;;;AAKA,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAU;AAC1E;AACA,MAAM,GAAG,GAAqC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE;AAgB1I,SAAU,UAAU,CAAC,GAAG,GAAG,UAAU,EAAA;AACzC,IAAA,OAAOA,kBAAa,CAClB,GAAG,EACH,CAAC,IAAI,KACH,MAAM,OAAQ,SAAQ,IAAI,CAAA;AAA1B,QAAA,WAAA,GAAA;;YAIU,IAAA,CAAA,EAAE,GAAG,CAAC;AAGN,YAAA,IAAA,CAAA,KAAK,GAAqB,CAAC,CAAC,EAAE,CAAC,CAAC;QA2F1C;AAjG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UAAU,EAAE;AACZ,IAAA,WAAW,EAAE;AACf;;;;;;;;;;"}
@@ -1,48 +1,3 @@
1
- /**
2
- * use-scroll-animate/components — shared base for the `<usa-*>` custom elements.
3
- *
4
- * Everything here is lazy: nothing touches `window`, `document`,
5
- * `HTMLElement` or `matchMedia` at import time, so the components can be
6
- * imported during SSR (Next, Nuxt, Astro…) and in Electron/Tauri preload
7
- * scripts. Classes are created the first time a `define*()` function runs.
8
- */
9
- interface ComponentsConfig {
10
- /**
11
- * Inject each component's CSS when it is defined (default `true`). Uses a
12
- * constructable stylesheet (`document.adoptedStyleSheets`, which a strict
13
- * `style-src` CSP does not block) and falls back to a `<style>` tag. Set
14
- * to `false` when you load `use-scroll-animate/components.css` yourself.
15
- */
16
- injectStyles?: boolean;
17
- /**
18
- * `'user'` (default) follows `prefers-reduced-motion`; `'reduce'` always
19
- * uses the reduced variants (e.g. a kiosk / battery-saver mode);
20
- * `'no-preference'` ignores the OS setting (only for demos — respect your users).
21
- */
22
- reducedMotion?: 'user' | 'reduce' | 'no-preference';
23
- /**
24
- * Global motion intensity (v2.7): `'off'` (same as reduced motion),
25
- * `'low'` (shorter, calmer), `'normal'` (default) or `'high'`. Scales every
26
- * component animation's duration and sets `--usa-motion` (0 / 0.6 / 1 /
27
- * 1.25) on `<html>` for your own CSS. See `setMotionIntensity()`.
28
- */
29
- motionIntensity?: MotionIntensity;
30
- /**
31
- * Motion-sensitivity level (v4.4), finer than reduced motion:
32
- * `'full'` (default) · `'gentle'` (no spins, zooms, skews or parallax —
33
- * translations and fades only, safe for vestibular disorders) ·
34
- * `'minimal'` (fades only; components use their reduced-motion variants) ·
35
- * `'static'` (no animation: every component shows its static alternative).
36
- * See `setMotionSensitivity()` in `use-scroll-animate/components/a11y`.
37
- */
38
- motionSensitivity?: MotionSensitivity;
39
- }
40
- type MotionSensitivity = 'full' | 'gentle' | 'minimal' | 'static';
41
- type MotionIntensity = 'off' | 'low' | 'normal' | 'high';
42
- /** Change global component settings (call before `define*()` for `injectStyles`). */
43
- declare function configureComponents(options: ComponentsConfig): void;
44
- /** `true` when animations should be reduced (OS setting or `configureComponents`). */
45
- declare function prefersReducedMotion(): boolean;
46
1
  /**
47
2
  * Members shared by every `<usa-*>` element. Attribute helpers, a cleanup
48
3
  * bag that is emptied on disconnect, and motion helpers that degrade to the
@@ -127,5 +82,5 @@ declare global {
127
82
  }
128
83
  }
129
84
 
130
- export { configureComponents, defineCube, defineDepth, defineDepthComponents, deviceTilt, orientationToTilt, prefersReducedMotion, requestOrientationPermission, supportsOrientation };
131
- export type { ComponentsConfig, TiltReading, UsaCubeElement, UsaDepthElement, UsaElement };
85
+ export { defineCube, defineDepth, defineDepthComponents, deviceTilt, orientationToTilt, requestOrientationPermission, supportsOrientation };
86
+ export type { TiltReading, UsaCubeElement, UsaDepthElement };
@@ -1,48 +1,3 @@
1
- /**
2
- * use-scroll-animate/components — shared base for the `<usa-*>` custom elements.
3
- *
4
- * Everything here is lazy: nothing touches `window`, `document`,
5
- * `HTMLElement` or `matchMedia` at import time, so the components can be
6
- * imported during SSR (Next, Nuxt, Astro…) and in Electron/Tauri preload
7
- * scripts. Classes are created the first time a `define*()` function runs.
8
- */
9
- interface ComponentsConfig {
10
- /**
11
- * Inject each component's CSS when it is defined (default `true`). Uses a
12
- * constructable stylesheet (`document.adoptedStyleSheets`, which a strict
13
- * `style-src` CSP does not block) and falls back to a `<style>` tag. Set
14
- * to `false` when you load `use-scroll-animate/components.css` yourself.
15
- */
16
- injectStyles?: boolean;
17
- /**
18
- * `'user'` (default) follows `prefers-reduced-motion`; `'reduce'` always
19
- * uses the reduced variants (e.g. a kiosk / battery-saver mode);
20
- * `'no-preference'` ignores the OS setting (only for demos — respect your users).
21
- */
22
- reducedMotion?: 'user' | 'reduce' | 'no-preference';
23
- /**
24
- * Global motion intensity (v2.7): `'off'` (same as reduced motion),
25
- * `'low'` (shorter, calmer), `'normal'` (default) or `'high'`. Scales every
26
- * component animation's duration and sets `--usa-motion` (0 / 0.6 / 1 /
27
- * 1.25) on `<html>` for your own CSS. See `setMotionIntensity()`.
28
- */
29
- motionIntensity?: MotionIntensity;
30
- /**
31
- * Motion-sensitivity level (v4.4), finer than reduced motion:
32
- * `'full'` (default) · `'gentle'` (no spins, zooms, skews or parallax —
33
- * translations and fades only, safe for vestibular disorders) ·
34
- * `'minimal'` (fades only; components use their reduced-motion variants) ·
35
- * `'static'` (no animation: every component shows its static alternative).
36
- * See `setMotionSensitivity()` in `use-scroll-animate/components/a11y`.
37
- */
38
- motionSensitivity?: MotionSensitivity;
39
- }
40
- type MotionSensitivity = 'full' | 'gentle' | 'minimal' | 'static';
41
- type MotionIntensity = 'off' | 'low' | 'normal' | 'high';
42
- /** Change global component settings (call before `define*()` for `injectStyles`). */
43
- declare function configureComponents(options: ComponentsConfig): void;
44
- /** `true` when animations should be reduced (OS setting or `configureComponents`). */
45
- declare function prefersReducedMotion(): boolean;
46
1
  /**
47
2
  * Members shared by every `<usa-*>` element. Attribute helpers, a cleanup
48
3
  * bag that is emptied on disconnect, and motion helpers that degrade to the
@@ -127,5 +82,5 @@ declare global {
127
82
  }
128
83
  }
129
84
 
130
- export { configureComponents, defineCube, defineDepth, defineDepthComponents, deviceTilt, orientationToTilt, prefersReducedMotion, requestOrientationPermission, supportsOrientation };
131
- export type { ComponentsConfig, TiltReading, UsaCubeElement, UsaDepthElement, UsaElement };
85
+ export { defineCube, defineDepth, defineDepthComponents, deviceTilt, orientationToTilt, requestOrientationPermission, supportsOrientation };
86
+ export type { TiltReading, UsaCubeElement, UsaDepthElement };
@@ -1,7 +1,6 @@
1
- import { v as defineElement, j as clamp, r as raf, k as caf } from '../chunks/base-DbbRUxaa.js';
2
- export { f as configureComponents, p as prefersReducedMotion } from '../chunks/base-DbbRUxaa.js';
3
- import { c as createSpring } from '../chunks/spring-B6w7mVCU.js';
4
- import { g as gesture } from '../chunks/core-CcaSsbV8.js';
1
+ import { x as defineElement, k as clamp, r as raf, q as caf } from '../chunks/base-C3Sw9sAO.js';
2
+ import { c as createSpring } from '../chunks/spring-CckMe3x0.js';
3
+ import { g as gesture } from '../chunks/core-BTf__I-8.js';
5
4
 
6
5
  var css = "usa-cube{--usa-cube-size:200px;display:block;width:var(--usa-cube-size);height:var(--usa-cube-size);perspective:var(--usa-cube-perspective,900px);touch-action:pan-y;user-select:none;-webkit-user-select:none;position:relative}usa-cube>[data-face]{position:absolute;inset:0;backface-visibility:hidden;transform:translateZ(calc(var(--usa-cube-size) / -2)) rotateX(var(--usa-cube-rx,0deg)) rotateY(var(--usa-cube-ry,0deg)) var(--usa-face) translateZ(calc(var(--usa-cube-size) / 2));transform-origin:50% 50%}usa-cube>[data-face=\"front\"]{--usa-face:rotateY(0deg)}usa-cube>[data-face=\"right\"]{--usa-face:rotateY(90deg)}usa-cube>[data-face=\"back\"]{--usa-face:rotateY(180deg)}usa-cube>[data-face=\"left\"]{--usa-face:rotateY(-90deg)}usa-cube>[data-face=\"top\"]{--usa-face:rotateX(90deg)}usa-cube>[data-face=\"bottom\"]{--usa-face:rotateX(-90deg)}usa-cube:focus-visible{outline:2px solid currentColor;outline-offset:6px}usa-depth{display:block;position:relative;perspective:1000px}usa-depth>*{transform:var(--usa-depth-rot,none);transform-style:preserve-3d}usa-depth [data-depth]{will-change:transform;transition:transform 0.12s linear}@media (prefers-reduced-motion:reduce){usa-depth [data-depth]{transform:none !important}}";
7
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"depth.js","sources":["../../src/components/depth/cube.ts","../../src/components/depth/core.ts","../../src/components/depth/depth-el.ts","../../src/components/depth/index.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { createSpring, type SpringValue } from '../physics/spring';\nimport { gesture } from '../gesture/core';\nimport css from './depth.css?raw';\n\nconst FACES = ['front', 'right', 'back', 'left', 'top', 'bottom'] as const;\n/** Rotation (deg) that brings each face to the front. */\nconst ROT: Record<string, [number, number]> = { front: [0, 0], right: [0, -90], back: [0, -180], left: [0, 90], top: [-90, 0], bottom: [90, 0] };\n\n/**\n * `<usa-cube>` — a CSS 3D cube whose up-to-six element children are its faces\n * (front, right, back, left, top, bottom). Rotate with drag / swipe, arrow\n * keys, `autoplay` (ms) or `show(face | index)`; spring-driven.\n * Attributes: `size` (px, 200), `autoplay`, `perspective` (900).\n * `usa:change` (`{ index, face }`). Reduced motion: instant face switch.\n */\nexport interface UsaCubeElement extends UsaElement {\n readonly index: number;\n show(face: number | string): void;\n next(): void;\n prev(): void;\n}\n\nexport function defineCube(tag = 'usa-cube'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaCube extends Base {\n static get observedAttributes(): string[] {\n return ['size', 'autoplay'];\n }\n private _i = 0;\n private _rx!: SpringValue;\n private _ry!: SpringValue;\n private _base: [number, number] = [0, 0];\n\n get index(): number {\n return this._i;\n }\n\n private faces(): HTMLElement[] {\n return Array.from(this.children).filter((c) => c instanceof HTMLElement && !c.hasAttribute('slot')).slice(0, 6) as HTMLElement[];\n }\n\n private paint(): void {\n this.style.setProperty('--usa-cube-rx', `${this._rx.value}deg`);\n this.style.setProperty('--usa-cube-ry', `${this._ry.value}deg`);\n }\n\n show(face: number | string): void {\n const n = this.faces().length || 1;\n const i = typeof face === 'number' ? ((face % n) + n) % n : Math.max(0, FACES.indexOf(face as any));\n this._i = i;\n const [rx, ry] = ROT[FACES[i]];\n // take the shortest way round on Y\n const cur = this._ry.target;\n const ty = ry + Math.round((cur - ry) / 360) * 360;\n this._base = [rx, ty];\n if (this.reduced) {\n this._rx.jump(rx);\n this._ry.jump(ty);\n } else {\n this._rx.set(rx);\n this._ry.set(ty);\n }\n this.faces().forEach((f, j) => f.setAttribute('aria-hidden', String(j !== i)));\n this.emit('change', { index: i, face: FACES[i] });\n }\n\n next(): void {\n this.show(this._i + 1);\n }\n\n prev(): void {\n this.show(this._i - 1);\n }\n\n mount(): void {\n this.style.setProperty('--usa-cube-size', `${this.num('size', 200)}px`);\n this.style.setProperty('--usa-cube-perspective', `${this.num('perspective', 900)}px`);\n this.faces().forEach((f, j) => f.setAttribute('data-face', FACES[j]));\n if (!this.hasAttribute('tabindex')) this.tabIndex = 0;\n if (!this.hasAttribute('role')) this.setAttribute('role', 'region');\n if (!this.hasAttribute('aria-roledescription')) this.setAttribute('aria-roledescription', 'cube');\n this._rx = createSpring({ spring: 'gentle', onUpdate: () => this.paint() });\n this._ry = createSpring({ spring: 'gentle', onUpdate: () => this.paint() });\n this.show(this._i);\n this.paint();\n this.onCleanup(\n gesture(this, {\n onPan: ({ dx, dy, last }) => {\n if (this.reduced) return;\n if (!last) {\n this._ry.jump(this._base[1] + dx * 0.5);\n this._rx.jump(this._base[0] - dy * 0.5);\n return;\n }\n if (Math.abs(dx) > 40 && Math.abs(dx) >= Math.abs(dy)) return dx < 0 ? this.next() : this.prev();\n if (Math.abs(dy) > 40 && this.faces().length > 4) return this.show(dy < 0 ? 'bottom' : 'top');\n this.show(this._i);\n },\n })\n );\n this.listen(this, 'keydown', (e: KeyboardEvent) => {\n const k: Record<string, () => void> = { ArrowRight: () => this.next(), ArrowLeft: () => this.prev(), ArrowUp: () => this.show('bottom'), ArrowDown: () => this.show('top'), Home: () => this.show(0) };\n if (!k[e.key] || ((e.key === 'ArrowUp' || e.key === 'ArrowDown') && this.faces().length < 6)) return;\n e.preventDefault();\n k[e.key]();\n });\n const ms = this.num('autoplay', 0);\n if (ms > 0 && !this.reduced) {\n let paused = false;\n const id = setInterval(() => !paused && this.show((this._i + 1) % Math.min(4, this.faces().length || 1)), ms);\n this.listen(this, 'pointerenter', () => (paused = true));\n this.listen(this, 'pointerleave', () => (paused = false));\n this.listen(this, 'focusin', () => (paused = true));\n this.listen(this, 'focusout', () => (paused = false));\n this.onCleanup(() => clearInterval(id));\n }\n }\n\n unmount(): void {\n this._rx?.stop();\n this._ry?.stop();\n }\n },\n { id: 'depth', text: css }\n );\n}\n","import { clamp } from '../base';\n\nexport interface TiltReading {\n /** Left/right tilt, -1…1. */\n x: number;\n /** Front/back tilt, -1…1. */\n y: number;\n}\n\n/** Map a DeviceOrientation reading (beta/gamma degrees) to -1…1 tilt around a resting pose (pure). */\nexport function orientationToTilt(beta: number | null, gamma: number | null, range = 30, rest = 45): TiltReading {\n return {\n x: clamp((gamma ?? 0) / range, -1, 1),\n y: clamp(((beta ?? rest) - rest) / range, -1, 1),\n };\n}\n\n/** `true` when DeviceOrientation events exist. */\nexport const supportsOrientation = (): boolean => typeof window !== 'undefined' && 'DeviceOrientationEvent' in window;\n\n/**\n * Ask for motion-sensor permission where required (iOS 13+; must run inside\n * a user gesture). Resolves `true` when tilt events can be used.\n */\nexport async function requestOrientationPermission(): Promise<boolean> {\n if (!supportsOrientation()) return false;\n const D = (window as any).DeviceOrientationEvent;\n if (typeof D.requestPermission !== 'function') return true;\n try {\n return (await D.requestPermission()) === 'granted';\n } catch {\n return false;\n }\n}\n\n/**\n * Listen to device tilt (smoothed); falls back to nothing on desktops.\n * Returns a stop function.\n */\nexport function deviceTilt(cb: (t: TiltReading) => void, o: { range?: number; smooth?: number } = {}): () => void {\n if (!supportsOrientation()) return () => {};\n let cur: TiltReading = { x: 0, y: 0 };\n const k = 1 - clamp(o.smooth ?? 0.2, 0, 0.95);\n const on = (e: DeviceOrientationEvent) => {\n const t = orientationToTilt(e.beta, e.gamma, o.range ?? 30);\n cur = { x: cur.x + (t.x - cur.x) * k, y: cur.y + (t.y - cur.y) * k };\n cb(cur);\n };\n window.addEventListener('deviceorientation', on);\n return () => window.removeEventListener('deviceorientation', on);\n}\n","import { defineElement, raf, caf, clamp, type UsaElement } from '../base';\nimport { deviceTilt, requestOrientationPermission, supportsOrientation } from './core';\nimport css from './depth.css?raw';\n\n/**\n * `<usa-depth>` — depth parallax: children with `data-depth` (-1…1, 0 = the\n * screen plane) move and scale by depth as the pointer moves, the device\n * tilts (`orientation`) or the page scrolls (`scroll`).\n * Attributes: `source` (`pointer` default · `orientation` · `scroll` ·\n * space-separated mix), `strength` (px at depth 1, 40), `rotate` (max tilt\n * of the whole scene in deg, 0). `requestPermission()` for iOS motion.\n * Reduced motion: layers stay flat.\n */\nexport interface UsaDepthElement extends UsaElement {\n /** Current -1…1 input. */\n readonly tilt: { x: number; y: number };\n requestPermission(): Promise<boolean>;\n}\n\nexport function defineDepth(tag = 'usa-depth'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaDepth extends Base {\n static get observedAttributes(): string[] {\n return ['source', 'strength', 'rotate'];\n }\n private _t = { x: 0, y: 0 };\n private _id = 0;\n\n get tilt(): { x: number; y: number } {\n return { ...this._t };\n }\n\n requestPermission(): Promise<boolean> {\n return requestOrientationPermission().then((ok) => {\n if (ok) {\n this.changed('source');\n }\n return ok;\n });\n }\n\n private apply(): void {\n this._id = 0;\n const s = this.num('strength', 40);\n const r = this.num('rotate', 0);\n const { x, y } = this._t;\n this.style.setProperty('--usa-depth-x', x.toFixed(4));\n this.style.setProperty('--usa-depth-y', y.toFixed(4));\n if (r) this.style.setProperty('--usa-depth-rot', `rotateX(${(-y * r).toFixed(2)}deg) rotateY(${(x * r).toFixed(2)}deg)`);\n this.querySelectorAll<HTMLElement>('[data-depth]').forEach((el) => {\n const d = clamp(Number(el.dataset.depth) || 0, -1, 1);\n el.style.transform = `translate3d(${(x * d * s).toFixed(2)}px, ${(y * d * s).toFixed(2)}px, 0) scale(${(1 + d * 0.04).toFixed(4)})`;\n });\n }\n\n private set(x: number, y: number): void {\n this._t = { x: clamp(x, -1, 1), y: clamp(y, -1, 1) };\n if (!this._id) this._id = raf(() => this.apply());\n }\n\n mount(): void {\n if (this.reduced) return;\n const src = this.str('source', 'pointer').split(/\\s+/);\n if (src.includes('pointer')) {\n this.listen(this, 'pointermove', (e: PointerEvent) => {\n const r = this.getBoundingClientRect();\n this.set(((e.clientX - r.left) / (r.width || 1)) * 2 - 1, ((e.clientY - r.top) / (r.height || 1)) * 2 - 1);\n });\n this.listen(this, 'pointerleave', () => this.set(0, 0));\n }\n if (src.includes('orientation') && supportsOrientation()) this.onCleanup(deviceTilt((t) => this.set(t.x, t.y)));\n if (src.includes('scroll')) {\n const on = () => {\n const r = this.getBoundingClientRect();\n const vh = window.innerHeight || 1;\n this.set(this._t.x, clamp(((r.top + r.height / 2) / vh) * 2 - 1, -1, 1));\n };\n this.listen(window, 'scroll', on, { passive: true });\n on();\n }\n this.onCleanup(() => {\n caf(this._id);\n this._id = 0;\n });\n }\n\n unmount(): void {\n this._t = { x: 0, y: 0 };\n this.querySelectorAll<HTMLElement>('[data-depth]').forEach((el) => (el.style.transform = ''));\n }\n },\n { id: 'depth', text: css }\n );\n}\n","/**\n * use-scroll-animate/components/depth — 3D (v3.5).\n * `<usa-cube>` (CSS 3D cube), `<usa-depth>` (layered depth parallax driven by\n * pointer, device orientation or scroll) and `deviceTilt()`. The 3D ring\n * carousel is `<usa-carousel-3d>` in `components/cards`.\n */\nimport { defineCube, type UsaCubeElement } from './cube';\nimport { defineDepth, type UsaDepthElement } from './depth-el';\n\nexport { defineCube, defineDepth };\nexport { deviceTilt, orientationToTilt, requestOrientationPermission, supportsOrientation } from './core';\nexport type { TiltReading } from './core';\nexport type { UsaCubeElement, UsaDepthElement };\nexport { configureComponents, prefersReducedMotion } from '../base';\nexport type { ComponentsConfig, UsaElement } from '../base';\n\n/** Register every component of this category under its default tag. */\nexport function defineDepthComponents(): void {\n defineCube();\n defineDepth();\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'usa-cube': UsaCubeElement;\n 'usa-depth': UsaDepthElement;\n }\n}\n"],"names":[],"mappings":";;;;;;;AAKA,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAU;AAC1E;AACA,MAAM,GAAG,GAAqC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,E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AAA,CAAC,CAAC;QACJ;QAEA,OAAO,GAAA;AACL,YAAA,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;YACxB,IAAI,CAAC,gBAAgB,CAAc,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC,CAAC;QAC/F;KACD,EACH,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAC3B;AACH;;AC/FA;;;;;AAKG;AAWH;SACgB,qBAAqB,GAAA;AACnC,IAAA,UAAU,EAAE;AACZ,IAAA,WAAW,EAAE;AACf;;;;"}
1
+ {"version":3,"file":"depth.js","sources":["../../src/components/depth/cube.ts","../../src/components/depth/core.ts","../../src/components/depth/depth-el.ts","../../src/components/depth/index.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { createSpring, type SpringValue } from '../physics/spring';\nimport { gesture } from '../gesture/core';\nimport css from './depth.css?raw';\n\nconst FACES = ['front', 'right', 'back', 'left', 'top', 'bottom'] as const;\n/** Rotation (deg) that brings each face to the front. */\nconst ROT: Record<string, [number, number]> = { front: [0, 0], right: [0, -90], back: [0, -180], left: [0, 90], top: [-90, 0], bottom: [90, 0] };\n\n/**\n * `<usa-cube>` — a CSS 3D cube whose up-to-six element children are its faces\n * (front, right, back, left, top, bottom). Rotate with drag / swipe, arrow\n * keys, `autoplay` (ms) or `show(face | index)`; spring-driven.\n * Attributes: `size` (px, 200), `autoplay`, `perspective` (900).\n * `usa:change` (`{ index, face }`). Reduced motion: instant face switch.\n */\nexport interface UsaCubeElement extends UsaElement {\n readonly index: number;\n show(face: number | string): void;\n next(): void;\n prev(): void;\n}\n\nexport function defineCube(tag = 'usa-cube'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaCube extends Base {\n static get observedAttributes(): string[] {\n return ['size', 'autoplay'];\n }\n private _i = 0;\n private _rx!: SpringValue;\n private _ry!: SpringValue;\n private _base: [number, number] = [0, 0];\n\n get index(): number {\n return this._i;\n }\n\n private faces(): HTMLElement[] {\n return Array.from(this.children).filter((c) => c instanceof HTMLElement && !c.hasAttribute('slot')).slice(0, 6) as HTMLElement[];\n }\n\n private paint(): void {\n this.style.setProperty('--usa-cube-rx', `${this._rx.value}deg`);\n this.style.setProperty('--usa-cube-ry', `${this._ry.value}deg`);\n }\n\n show(face: number | string): void {\n const n = this.faces().length || 1;\n const i = typeof face === 'number' ? ((face % n) + n) % n : Math.max(0, FACES.indexOf(face as any));\n this._i = i;\n const [rx, ry] = ROT[FACES[i]];\n // take the shortest way round on Y\n const cur = this._ry.target;\n const ty = ry + Math.round((cur - ry) / 360) * 360;\n this._base = [rx, ty];\n if (this.reduced) {\n this._rx.jump(rx);\n this._ry.jump(ty);\n } else {\n this._rx.set(rx);\n this._ry.set(ty);\n }\n this.faces().forEach((f, j) => f.setAttribute('aria-hidden', String(j !== i)));\n this.emit('change', { index: i, face: FACES[i] });\n }\n\n next(): void {\n this.show(this._i + 1);\n }\n\n prev(): void {\n this.show(this._i - 1);\n }\n\n mount(): void {\n this.style.setProperty('--usa-cube-size', `${this.num('size', 200)}px`);\n this.style.setProperty('--usa-cube-perspective', `${this.num('perspective', 900)}px`);\n this.faces().forEach((f, j) => f.setAttribute('data-face', FACES[j]));\n if (!this.hasAttribute('tabindex')) this.tabIndex = 0;\n if (!this.hasAttribute('role')) this.setAttribute('role', 'region');\n if (!this.hasAttribute('aria-roledescription')) this.setAttribute('aria-roledescription', 'cube');\n this._rx = createSpring({ spring: 'gentle', onUpdate: () => this.paint() });\n this._ry = createSpring({ spring: 'gentle', onUpdate: () => this.paint() });\n this.show(this._i);\n this.paint();\n this.onCleanup(\n gesture(this, {\n onPan: ({ dx, dy, last }) => {\n if (this.reduced) return;\n if (!last) {\n this._ry.jump(this._base[1] + dx * 0.5);\n this._rx.jump(this._base[0] - dy * 0.5);\n return;\n }\n if (Math.abs(dx) > 40 && Math.abs(dx) >= Math.abs(dy)) return dx < 0 ? this.next() : this.prev();\n if (Math.abs(dy) > 40 && this.faces().length > 4) return this.show(dy < 0 ? 'bottom' : 'top');\n this.show(this._i);\n },\n })\n );\n this.listen(this, 'keydown', (e: KeyboardEvent) => {\n const k: Record<string, () => void> = { ArrowRight: () => this.next(), ArrowLeft: () => this.prev(), ArrowUp: () => this.show('bottom'), ArrowDown: () => this.show('top'), Home: () => this.show(0) };\n if (!k[e.key] || ((e.key === 'ArrowUp' || e.key === 'ArrowDown') && this.faces().length < 6)) return;\n e.preventDefault();\n k[e.key]();\n });\n const ms = this.num('autoplay', 0);\n if (ms > 0 && !this.reduced) {\n let paused = false;\n const id = setInterval(() => !paused && this.show((this._i + 1) % Math.min(4, this.faces().length || 1)), ms);\n this.listen(this, 'pointerenter', () => (paused = true));\n this.listen(this, 'pointerleave', () => (paused = false));\n this.listen(this, 'focusin', () => (paused = true));\n this.listen(this, 'focusout', () => (paused = false));\n this.onCleanup(() => clearInterval(id));\n }\n }\n\n unmount(): void {\n this._rx?.stop();\n this._ry?.stop();\n }\n },\n { id: 'depth', text: css }\n );\n}\n","import { clamp } from '../base';\n\nexport interface TiltReading {\n /** Left/right tilt, -1…1. */\n x: number;\n /** Front/back tilt, -1…1. */\n y: number;\n}\n\n/** Map a DeviceOrientation reading (beta/gamma degrees) to -1…1 tilt around a resting pose (pure). */\nexport function orientationToTilt(beta: number | null, gamma: number | null, range = 30, rest = 45): TiltReading {\n return {\n x: clamp((gamma ?? 0) / range, -1, 1),\n y: clamp(((beta ?? rest) - rest) / range, -1, 1),\n };\n}\n\n/** `true` when DeviceOrientation events exist. */\nexport const supportsOrientation = (): boolean => typeof window !== 'undefined' && 'DeviceOrientationEvent' in window;\n\n/**\n * Ask for motion-sensor permission where required (iOS 13+; must run inside\n * a user gesture). Resolves `true` when tilt events can be used.\n */\nexport async function requestOrientationPermission(): Promise<boolean> {\n if (!supportsOrientation()) return false;\n const D = (window as any).DeviceOrientationEvent;\n if (typeof D.requestPermission !== 'function') return true;\n try {\n return (await D.requestPermission()) === 'granted';\n } catch {\n return false;\n }\n}\n\n/**\n * Listen to device tilt (smoothed); falls back to nothing on desktops.\n * Returns a stop function.\n */\nexport function deviceTilt(cb: (t: TiltReading) => void, o: { range?: number; smooth?: number } = {}): () => void {\n if (!supportsOrientation()) return () => {};\n let cur: TiltReading = { x: 0, y: 0 };\n const k = 1 - clamp(o.smooth ?? 0.2, 0, 0.95);\n const on = (e: DeviceOrientationEvent) => {\n const t = orientationToTilt(e.beta, e.gamma, o.range ?? 30);\n cur = { x: cur.x + (t.x - cur.x) * k, y: cur.y + (t.y - cur.y) * k };\n cb(cur);\n };\n window.addEventListener('deviceorientation', on);\n return () => window.removeEventListener('deviceorientation', on);\n}\n","import { defineElement, raf, caf, clamp, type UsaElement } from '../base';\nimport { deviceTilt, requestOrientationPermission, supportsOrientation } from './core';\nimport css from './depth.css?raw';\n\n/**\n * `<usa-depth>` — depth parallax: children with `data-depth` (-1…1, 0 = the\n * screen plane) move and scale by depth as the pointer moves, the device\n * tilts (`orientation`) or the page scrolls (`scroll`).\n * Attributes: `source` (`pointer` default · `orientation` · `scroll` ·\n * space-separated mix), `strength` (px at depth 1, 40), `rotate` (max tilt\n * of the whole scene in deg, 0). `requestPermission()` for iOS motion.\n * Reduced motion: layers stay flat.\n */\nexport interface UsaDepthElement extends UsaElement {\n /** Current -1…1 input. */\n readonly tilt: { x: number; y: number };\n requestPermission(): Promise<boolean>;\n}\n\nexport function defineDepth(tag = 'usa-depth'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaDepth extends Base {\n static get observedAttributes(): string[] {\n return ['source', 'strength', 'rotate'];\n }\n private _t = { x: 0, y: 0 };\n private _id = 0;\n\n get tilt(): { x: number; y: number } {\n return { ...this._t };\n }\n\n requestPermission(): Promise<boolean> {\n return requestOrientationPermission().then((ok) => {\n if (ok) {\n this.changed('source');\n }\n return ok;\n });\n }\n\n private apply(): void {\n this._id = 0;\n const s = this.num('strength', 40);\n const r = this.num('rotate', 0);\n const { x, y } = this._t;\n this.style.setProperty('--usa-depth-x', x.toFixed(4));\n this.style.setProperty('--usa-depth-y', y.toFixed(4));\n if (r) this.style.setProperty('--usa-depth-rot', `rotateX(${(-y * r).toFixed(2)}deg) rotateY(${(x * r).toFixed(2)}deg)`);\n this.querySelectorAll<HTMLElement>('[data-depth]').forEach((el) => {\n const d = clamp(Number(el.dataset.depth) || 0, -1, 1);\n el.style.transform = `translate3d(${(x * d * s).toFixed(2)}px, ${(y * d * s).toFixed(2)}px, 0) scale(${(1 + d * 0.04).toFixed(4)})`;\n });\n }\n\n private set(x: number, y: number): void {\n this._t = { x: clamp(x, -1, 1), y: clamp(y, -1, 1) };\n if (!this._id) this._id = raf(() => this.apply());\n }\n\n mount(): void {\n if (this.reduced) return;\n const src = this.str('source', 'pointer').split(/\\s+/);\n if (src.includes('pointer')) {\n this.listen(this, 'pointermove', (e: PointerEvent) => {\n const r = this.getBoundingClientRect();\n this.set(((e.clientX - r.left) / (r.width || 1)) * 2 - 1, ((e.clientY - r.top) / (r.height || 1)) * 2 - 1);\n });\n this.listen(this, 'pointerleave', () => this.set(0, 0));\n }\n if (src.includes('orientation') && supportsOrientation()) this.onCleanup(deviceTilt((t) => this.set(t.x, t.y)));\n if (src.includes('scroll')) {\n const on = () => {\n const r = this.getBoundingClientRect();\n const vh = window.innerHeight || 1;\n this.set(this._t.x, clamp(((r.top + r.height / 2) / vh) * 2 - 1, -1, 1));\n };\n this.listen(window, 'scroll', on, { passive: true });\n on();\n }\n this.onCleanup(() => {\n caf(this._id);\n this._id = 0;\n });\n }\n\n unmount(): void {\n this._t = { x: 0, y: 0 };\n this.querySelectorAll<HTMLElement>('[data-depth]').forEach((el) => (el.style.transform = ''));\n }\n },\n { id: 'depth', text: css }\n );\n}\n","/**\n * use-scroll-animate/components/depth — 3D (v3.5).\n * `<usa-cube>` (CSS 3D cube), `<usa-depth>` (layered depth parallax driven by\n * pointer, device orientation or scroll) and `deviceTilt()`. The 3D ring\n * carousel is `<usa-carousel-3d>` in `components/cards`.\n */\nimport { defineCube, type UsaCubeElement } from './cube';\nimport { defineDepth, type UsaDepthElement } from './depth-el';\n\nexport { defineCube, defineDepth };\nexport { deviceTilt, orientationToTilt, requestOrientationPermission, supportsOrientation } from './core';\nexport type { TiltReading } from './core';\nexport type { UsaCubeElement, UsaDepthElement };\n\n/** Register every component of this category under its default tag. */\nexport function defineDepthComponents(): void {\n defineCube();\n defineDepth();\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'usa-cube': UsaCubeElement;\n 'usa-depth': UsaDepthElement;\n }\n}\n"],"names":[],"mappings":";;;;;;AAKA,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAU;AAC1E;AACA,MAAM,GAAG,GAAqC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE;AAgB1I,SAAU,UAAU,CAAC,GAAG,GAAG,UAAU,EAAA;AACzC,IAAA,OAAO,aAAa,CAClB,GAAG,EACH,CAAC,IAAI,KACH,MAAM,OAAQ,SAAQ,IAAI,CAAA;AAA1B,QAAA,WAAA,GAAA;;YAIU,IAAA,CAAA,EAAE,GAAG,CAAC;AAGN,YAAA,IAAA,CAAA,KAAK,GAAqB,CAAC,CAAC,EAAE,CAAC,CAAC;QA2F1C;AAjGE,QAAA,WAAW,kBAAkB,GAAA;AAC3B,YAAA,OAAO,CAAC,MAAM,E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';
2
+
3
+ var components_fx = require('./fx.cjs');
4
+ require('../chunks/base-B5i8qQPR.cjs');
5
+ require('../chunks/core-BDcszY4L.cjs');
6
+ require('./tokens.cjs');
7
+ require('../chunks/fx-B8hk1Fby.cjs');
8
+
9
+ let layer = null;
10
+ /** A fixed, pointer-transparent, aria-hidden layer for transient particles. */
11
+ function fxLayer() {
12
+ if (layer?.isConnected)
13
+ return layer;
14
+ layer = document.createElement('div');
15
+ layer.setAttribute('aria-hidden', 'true');
16
+ layer.setAttribute('data-usa-fx-layer', '');
17
+ layer.style.cssText = 'position:fixed;inset:0;pointer-events:none;overflow:hidden;z-index:2147483000;contain:strict';
18
+ document.body.appendChild(layer);
19
+ return layer;
20
+ }
21
+ /** Client point of the triggering pointer event, or the element's center. */
22
+ function origin(el, ctx) {
23
+ const e = ctx.event;
24
+ const r = el.getBoundingClientRect();
25
+ return e && typeof e.clientX === 'number' && (e.clientX || e.clientY) ? { x: e.clientX, y: e.clientY } : { x: r.left + r.width / 2, y: r.top + r.height / 2 };
26
+ }
27
+ /** Spawn an absolutely positioned node in the fx layer at (x, y); removed when its animation ends. */
28
+ function spawn(x, y, css, ctx, frames, opts, text = '') {
29
+ const n = document.createElement('span');
30
+ n.style.cssText = `position:absolute;left:${x}px;top:${y}px;${css}`;
31
+ if (text)
32
+ n.textContent = text;
33
+ fxLayer().appendChild(n);
34
+ const a = ctx.animate(n, frames, { fill: 'forwards', ...opts });
35
+ const rm = () => n.remove();
36
+ if (a)
37
+ a.finished.then(rm, rm);
38
+ else
39
+ rm();
40
+ return a;
41
+ }
42
+ /** An overlay child covering `el` (makes `el` a positioning context). Returns it and a remover. */
43
+ function overlay(el, css) {
44
+ const o = document.createElement('span');
45
+ o.setAttribute('aria-hidden', 'true');
46
+ o.style.cssText = `position:absolute;inset:0;pointer-events:none;border-radius:inherit;${css}`;
47
+ if (getComputedStyle(el).position === 'static')
48
+ el.style.position = 'relative';
49
+ el.appendChild(o);
50
+ return [o, () => o.remove()];
51
+ }
52
+ const PALETTE = ['#7c5cff', '#ff5c8a', '#22d3ee', '#facc15', '#34d399'];
53
+ const rand = (a, b) => a + Math.random() * (b - a);
54
+ /** Wait for all animations (ignoring nulls). */
55
+ const all = (anims) => Promise.all(anims.filter(Boolean).map((a) => a.finished.catch(() => undefined)));
56
+
57
+ const CARD_FX = [
58
+ {
59
+ name: 'holo',
60
+ kind: 'card',
61
+ description: 'Holographic foil: a rainbow sheen and sparkle that follow the pointer (persistent; bind with trigger="load").',
62
+ reduced: 'run',
63
+ defaults: { strength: 0.55 },
64
+ run: (el, o, ctx) => {
65
+ const [layer, remove] = overlay(el, `mix-blend-mode:color-dodge;opacity:${o.strength};background:linear-gradient(115deg,transparent 20%,#ff8bd855 35%,#8bf3ff55 45%,#fff58b55 55%,transparent 70%),repeating-linear-gradient(55deg,#ffffff10 0 2px,transparent 2px 6px);background-size:250% 250%,100% 100%;background-position:50% 50%;transition:background-position .2s ease-out`);
66
+ if (ctx.reduced)
67
+ return remove;
68
+ const move = (e) => {
69
+ const r = el.getBoundingClientRect();
70
+ const x = ((e.clientX - r.left) / (r.width || 1)) * 100;
71
+ const y = ((e.clientY - r.top) / (r.height || 1)) * 100;
72
+ layer.style.backgroundPosition = `${x}% ${y}%, 0 0`;
73
+ el.style.transform = `perspective(700px) rotateY(${(x - 50) / 8}deg) rotateX(${(50 - y) / 8}deg)`;
74
+ };
75
+ const leave = () => {
76
+ layer.style.backgroundPosition = '50% 50%, 0 0';
77
+ el.style.transform = '';
78
+ };
79
+ el.addEventListener('pointermove', move);
80
+ el.addEventListener('pointerleave', leave);
81
+ return () => {
82
+ el.removeEventListener('pointermove', move);
83
+ el.removeEventListener('pointerleave', leave);
84
+ leave();
85
+ remove();
86
+ };
87
+ },
88
+ },
89
+ {
90
+ name: 'glare-sweep',
91
+ kind: 'card',
92
+ description: 'A diagonal light streak sweeps across the card once.',
93
+ defaults: { duration: 900, color: 'rgba(255,255,255,.55)' },
94
+ run: (el, o, ctx) => {
95
+ if (ctx.reduced)
96
+ return;
97
+ const [g, remove] = overlay(el, `overflow:hidden;background:linear-gradient(105deg,transparent 35%,${o.color} 50%,transparent 65%);background-size:250% 100%`);
98
+ const a = ctx.animate(g, [{ backgroundPosition: '150% 0' }, { backgroundPosition: '-50% 0' }], { duration: o.duration, easing: 'ease-in-out' });
99
+ if (a)
100
+ a.finished.then(remove, remove);
101
+ else
102
+ remove();
103
+ return a;
104
+ },
105
+ },
106
+ {
107
+ name: 'book-open',
108
+ kind: 'card',
109
+ description: 'The card opens like a book cover around its left edge, peeks and closes.',
110
+ defaults: { angle: 35, duration: 1100 },
111
+ run: (el, o, ctx) => {
112
+ el.style.transformOrigin = 'left center';
113
+ return ctx.animate(el, [{ transform: 'perspective(900px) rotateY(0)' }, { transform: `perspective(900px) rotateY(-${o.angle}deg)`, offset: 0.45 }, { transform: 'perspective(900px) rotateY(0)' }], { duration: o.duration, easing: 'cubic-bezier(0.34, 1.3, 0.64, 1)' });
114
+ },
115
+ },
116
+ {
117
+ name: 'card-fan',
118
+ kind: 'card',
119
+ description: 'The element’s children fan out like a hand of cards, then gather.',
120
+ defaults: { spread: 14, duration: 900 },
121
+ run: (el, o, ctx) => {
122
+ const kids = Array.from(el.children);
123
+ const mid = (kids.length - 1) / 2;
124
+ return all(kids.map((k, i) => ctx.animate(k, [{ transform: 'none' }, { transform: `translateX(${(i - mid) * o.spread}px) rotate(${(i - mid) * (o.spread / 2)}deg)`, offset: 0.5 }, { transform: 'none' }], { duration: o.duration, easing: 'cubic-bezier(0.34, 1.56, 0.64, 1)' })));
125
+ },
126
+ },
127
+ {
128
+ name: 'topple',
129
+ kind: 'card',
130
+ description: 'Tips backwards on its bottom edge and springs upright.',
131
+ defaults: { duration: 1000 },
132
+ run: (el, o, ctx) => {
133
+ el.style.transformOrigin = 'bottom center';
134
+ return ctx.animate(el, [{ transform: 'perspective(800px) rotateX(0)' }, { transform: 'perspective(800px) rotateX(55deg)', offset: 0.35 }, { transform: 'perspective(800px) rotateX(-12deg)', offset: 0.6 }, { transform: 'perspective(800px) rotateX(5deg)', offset: 0.8 }, { transform: 'perspective(800px) rotateX(0)' }], { duration: o.duration, easing: 'ease-out' });
135
+ },
136
+ },
137
+ {
138
+ name: 'float-tilt',
139
+ kind: 'loop',
140
+ description: 'Idle floating with a slow 3D sway (loop; stops under reduced motion).',
141
+ defaults: { duration: 4200, distance: 8 },
142
+ run: (el, o, ctx) => {
143
+ const a = ctx.animate(el, [{ transform: 'translateY(0) rotateX(0) rotateY(0)' }, { transform: `translateY(-${o.distance}px) rotateX(4deg) rotateY(-5deg)` }, { transform: 'translateY(0) rotateX(0) rotateY(0)' }], { duration: o.duration, iterations: Infinity, easing: 'ease-in-out' });
144
+ return () => a?.cancel();
145
+ },
146
+ },
147
+ ];
148
+ const CLICK_FX = [
149
+ {
150
+ name: 'shockwave',
151
+ kind: 'click',
152
+ description: 'Two expanding rings from the click point.',
153
+ defaults: { color: '#7c5cff', size: 160, duration: 700 },
154
+ run: (el, o, ctx) => {
155
+ if (ctx.reduced)
156
+ return;
157
+ const { x, y } = origin(el, ctx);
158
+ return all([0, 120].map((delay) => spawn(x, y, `width:${o.size}px;height:${o.size}px;margin:${-o.size / 2}px 0 0 ${-o.size / 2}px;border:3px solid ${o.color};border-radius:50%`, ctx, [{ transform: 'scale(0)', opacity: 0.9 }, { transform: 'scale(1)', opacity: 0 }], { duration: o.duration, delay, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' })));
159
+ },
160
+ },
161
+ {
162
+ name: 'ink-splash',
163
+ kind: 'click',
164
+ description: 'Ink blobs splatter from the click point and fade.',
165
+ defaults: { count: 9, colors: PALETTE, duration: 800 },
166
+ run: (el, o, ctx) => {
167
+ if (ctx.reduced)
168
+ return;
169
+ const { x, y } = origin(el, ctx);
170
+ return all(Array.from({ length: o.count }, (_, i) => {
171
+ const s = rand(6, 22);
172
+ const ang = rand(0, Math.PI * 2);
173
+ const d = rand(20, 70);
174
+ return spawn(x, y, `width:${s}px;height:${s}px;margin:${-s / 2}px 0 0 ${-s / 2}px;background:${o.colors[i % o.colors.length]};border-radius:${rand(40, 50)}% ${rand(50, 60)}% ${rand(40, 60)}% ${rand(45, 55)}%`, ctx, [{ transform: 'translate(0,0) scale(.3)', opacity: 1 }, { transform: `translate(${Math.cos(ang) * d}px,${Math.sin(ang) * d}px) scale(1)`, opacity: 0.9, offset: 0.5 }, { transform: `translate(${Math.cos(ang) * d}px,${Math.sin(ang) * d + 8}px) scale(1.1)`, opacity: 0 }], { duration: o.duration, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' });
175
+ }));
176
+ },
177
+ },
178
+ {
179
+ name: 'star-burst',
180
+ kind: 'click',
181
+ description: 'Spinning stars burst outward.',
182
+ defaults: { count: 10, colors: ['#facc15', '#fb923c', '#f472b6'], duration: 900 },
183
+ run: (el, o, ctx) => {
184
+ if (ctx.reduced)
185
+ return;
186
+ const { x, y } = origin(el, ctx);
187
+ return all(Array.from({ length: o.count }, (_, i) => {
188
+ const ang = (i / o.count) * Math.PI * 2;
189
+ const d = rand(40, 80);
190
+ const s = rand(12, 22);
191
+ return spawn(x, y, `font-size:${s}px;line-height:1;margin:${-s / 2}px 0 0 ${-s / 2}px;color:${o.colors[i % o.colors.length]}`, ctx, [{ transform: 'translate(0,0) rotate(0) scale(.2)', opacity: 1 }, { transform: `translate(${Math.cos(ang) * d}px,${Math.sin(ang) * d}px) rotate(${rand(180, 360)}deg) scale(1)`, opacity: 0 }], { duration: o.duration, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' }, '★');
192
+ }));
193
+ },
194
+ },
195
+ {
196
+ name: 'jelly-press',
197
+ kind: 'click',
198
+ description: 'The pressed element squishes like jelly and wobbles back.',
199
+ defaults: { duration: 650 },
200
+ run: (el, o, ctx) => ctx.reduced ? ctx.animate(el, [{ opacity: 1 }, { opacity: 0.7 }, { opacity: 1 }], { duration: 250 }) : ctx.animate(el, [{ transform: 'scale(1,1)' }, { transform: 'scale(1.15,.85)', offset: 0.2 }, { transform: 'scale(.9,1.1)', offset: 0.4 }, { transform: 'scale(1.05,.95)', offset: 0.6 }, { transform: 'scale(.98,1.02)', offset: 0.8 }, { transform: 'scale(1,1)' }], { duration: o.duration, easing: 'ease-out' }),
201
+ },
202
+ {
203
+ name: 'ring-ripple',
204
+ kind: 'click',
205
+ description: 'Concentric outlined rings ripple out like water.',
206
+ defaults: { rings: 3, color: '#22d3ee', size: 120, duration: 1000 },
207
+ run: (el, o, ctx) => {
208
+ if (ctx.reduced)
209
+ return;
210
+ const { x, y } = origin(el, ctx);
211
+ return all(Array.from({ length: o.rings }, (_, i) => spawn(x, y, `width:${o.size}px;height:${o.size}px;margin:${-o.size / 2}px 0 0 ${-o.size / 2}px;border:2px solid ${o.color};border-radius:50%`, ctx, [{ transform: 'scale(.1)', opacity: 0.8 }, { transform: 'scale(1)', opacity: 0 }], { duration: o.duration, delay: i * 160, easing: 'ease-out' })));
212
+ },
213
+ },
214
+ {
215
+ name: 'emoji-rain',
216
+ kind: 'click',
217
+ description: 'Emoji pop up and fall around the click (pass `emoji: "🎉✨💜"`).',
218
+ defaults: { emoji: '🎉✨💜🔥', count: 14, duration: 1300 },
219
+ run: (el, o, ctx) => {
220
+ if (ctx.reduced)
221
+ return;
222
+ const { x, y } = origin(el, ctx);
223
+ const chars = Array.from(String(o.emoji));
224
+ return all(Array.from({ length: o.count }, (_, i) => {
225
+ const dx = rand(-90, 90);
226
+ return spawn(x, y, `font-size:${rand(16, 28)}px;line-height:1`, ctx, [{ transform: 'translate(0,0) scale(.4)', opacity: 0 }, { transform: `translate(${dx * 0.6}px,${rand(-90, -50)}px) scale(1)`, opacity: 1, offset: 0.35 }, { transform: `translate(${dx}px,${rand(40, 90)}px) rotate(${rand(-60, 60)}deg) scale(.9)`, opacity: 0 }], { duration: o.duration, delay: i * 25, easing: 'cubic-bezier(0.33, 0, 0.67, 1)' }, chars[i % chars.length]);
227
+ }));
228
+ },
229
+ },
230
+ ];
231
+
232
+ /**
233
+ * use-scroll-animate/components/effects — the 5.x effect packs, all
234
+ * registered through `registerEffect()` (5.0) and playable with
235
+ * `playEffect()`, `bindEffect()` or `<usa-fx>`. Kept out of
236
+ * `use-scroll-animate/components` / `components/lite` so their size budgets
237
+ * hold; the UMD bundle registers everything.
238
+ *
239
+ * ```ts
240
+ * import { registerAllEffects } from 'use-scroll-animate/components/effects';
241
+ * registerAllEffects();
242
+ * ```
243
+ */
244
+ /** The effect packs by version, in release order. */
245
+ const EFFECT_PACKS = {
246
+ 'cards-click': [...CARD_FX, ...CLICK_FX],
247
+ };
248
+ /** 5.1: card & click effects 2.0. */
249
+ function registerCardClickEffects() {
250
+ components_fx.registerEffects(EFFECT_PACKS['cards-click']);
251
+ }
252
+ /** Register the built-ins and every pack (idempotent). */
253
+ function registerAllEffects() {
254
+ components_fx.registerBuiltinEffects();
255
+ for (const defs of Object.values(EFFECT_PACKS))
256
+ components_fx.registerEffects(defs);
257
+ }
258
+
259
+ exports.CARD_FX = CARD_FX;
260
+ exports.CLICK_FX = CLICK_FX;
261
+ exports.EFFECT_PACKS = EFFECT_PACKS;
262
+ exports.fxLayer = fxLayer;
263
+ exports.registerAllEffects = registerAllEffects;
264
+ exports.registerCardClickEffects = registerCardClickEffects;
265
+ //# sourceMappingURL=effects.cjs.map