use-scroll-animate 10.2.0 → 10.4.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.
- package/AGENTS.md +4 -0
- package/CHANGELOG.md +35 -0
- package/README.md +67 -0
- package/bin/motionary-mcp.mjs +265 -0
- package/dist/chunks/anim-image-DDdb9q3X.js +166 -0
- package/dist/chunks/anim-image-DDdb9q3X.js.map +1 -0
- package/dist/chunks/anim-image-blQgPFFS.cjs +174 -0
- package/dist/chunks/anim-image-blQgPFFS.cjs.map +1 -0
- package/dist/chunks/audio-BpU-A1m1.cjs.map +1 -1
- package/dist/chunks/{audio-D95jwlOh.js → audio-CWt1xdZB.js} +3 -3
- package/dist/chunks/{audio-D95jwlOh.js.map → audio-CWt1xdZB.js.map} +1 -1
- package/dist/chunks/{base-BnRyfuyM.js → base-BTev8qxg.js} +2 -2
- package/dist/chunks/{base-BnRyfuyM.js.map → base-BTev8qxg.js.map} +1 -1
- package/dist/chunks/base-DBheNxJu.cjs.map +1 -1
- package/dist/chunks/bind-B_CTL6Qn.js.map +1 -1
- package/dist/chunks/bind-Ui43-n2d.cjs.map +1 -1
- package/dist/chunks/builtins-CKKZNR95.cjs.map +1 -1
- package/dist/chunks/{builtins-CqIq1zBv.js → builtins-CPmS6aDB.js} +3 -3
- package/dist/chunks/{builtins-CqIq1zBv.js.map → builtins-CPmS6aDB.js.map} +1 -1
- package/dist/chunks/core-B5T0dhFH.cjs.map +1 -1
- package/dist/chunks/{core-DsGoL9EY.js → core-BviA7nFa.js} +2 -2
- package/dist/chunks/{core-DsGoL9EY.js.map → core-BviA7nFa.js.map} +1 -1
- package/dist/chunks/core-D74Fz-dL.cjs.map +1 -1
- package/dist/chunks/core-D7cVumUu.js.map +1 -1
- package/dist/chunks/{core-XA2yhn1b.js → core-KiM7MXjL.js} +2 -2
- package/dist/chunks/{core-XA2yhn1b.js.map → core-KiM7MXjL.js.map} +1 -1
- package/dist/chunks/core-MQlXZKUG.cjs.map +1 -1
- package/dist/chunks/ease-HwYZnZat.cjs +94 -0
- package/dist/chunks/ease-HwYZnZat.cjs.map +1 -0
- package/dist/chunks/ease-XN8_0sXu.js +89 -0
- package/dist/chunks/ease-XN8_0sXu.js.map +1 -0
- package/dist/chunks/fx-B_pbhpDp.cjs.map +1 -1
- package/dist/chunks/{fx-CtnrFEg9.js → fx-CgWKqVsn.js} +2 -2
- package/dist/chunks/{fx-CtnrFEg9.js.map → fx-CgWKqVsn.js.map} +1 -1
- package/dist/chunks/generative-2LhxG5BJ.js.map +1 -1
- package/dist/chunks/generative-BHIj-NU0.cjs.map +1 -1
- package/dist/chunks/{gpu-CDcXiNA8.js → gpu-BWfgYWMY.js} +2 -2
- package/dist/chunks/{gpu-CDcXiNA8.js.map → gpu-BWfgYWMY.js.map} +1 -1
- package/dist/chunks/gpu-cUixt7kT.cjs.map +1 -1
- package/dist/chunks/index-tags-B-JBecYg.js.map +1 -1
- package/dist/chunks/index-tags-hLIF2Clq.cjs.map +1 -1
- package/dist/chunks/{keyframes-W-474DMc.js → keyframes-B5PWe5bU.js} +3 -2
- package/dist/chunks/keyframes-B5PWe5bU.js.map +1 -0
- package/dist/chunks/{keyframes-ZheOkpt0.cjs → keyframes-tC3I7anQ.cjs} +4 -3
- package/dist/chunks/keyframes-tC3I7anQ.cjs.map +1 -0
- package/dist/chunks/{manifest-D58HXVY-.js → manifest-BHx5yPN6.js} +2 -2
- package/dist/chunks/{manifest-D58HXVY-.js.map → manifest-BHx5yPN6.js.map} +1 -1
- package/dist/chunks/manifest-PaF9B8Vt.cjs.map +1 -1
- package/dist/chunks/{player-48Zy_NBG.js → player-BfHMNtiM.js} +4 -4
- package/dist/chunks/{player-48Zy_NBG.js.map → player-BfHMNtiM.js.map} +1 -1
- package/dist/chunks/player-C4y4jXSv.cjs.map +1 -1
- package/dist/chunks/presets-BYBVJVeP.js.map +1 -1
- package/dist/chunks/presets-CUHys3sK.cjs.map +1 -1
- package/dist/chunks/{registry-gFJRpPES.js → registry-BKzyg1JV.js} +2 -2
- package/dist/chunks/{registry-gFJRpPES.js.map → registry-BKzyg1JV.js.map} +1 -1
- package/dist/chunks/{registry-BIEjKngP.js → registry-CT-TT_bx.js} +3 -3
- package/dist/chunks/{registry-BIEjKngP.js.map → registry-CT-TT_bx.js.map} +1 -1
- package/dist/chunks/{registry-eJgpFAzI.cjs → registry-tzwKkldE.cjs} +2 -2
- package/dist/chunks/{registry-eJgpFAzI.cjs.map → registry-tzwKkldE.cjs.map} +1 -1
- package/dist/chunks/registry-xQZnSqqV.cjs.map +1 -1
- package/dist/chunks/shared-CkKHWrtJ.js.map +1 -1
- package/dist/chunks/shared-jkgRH-Hx.cjs.map +1 -1
- package/dist/chunks/{spring-CZDNyqWp.js → spring-BHuP55DR.js} +2 -2
- package/dist/chunks/{spring-CZDNyqWp.js.map → spring-BHuP55DR.js.map} +1 -1
- package/dist/chunks/spring-BlTQD2AV.cjs.map +1 -1
- package/dist/chunks/stagger-CCFyhzSw.cjs.map +1 -1
- package/dist/chunks/stagger-DtMKo2SK.js.map +1 -1
- package/dist/chunks/{ticker-CM_56oVy.js → ticker-C8lSGml9.js} +2 -2
- package/dist/chunks/{ticker-CM_56oVy.js.map → ticker-C8lSGml9.js.map} +1 -1
- package/dist/chunks/{ticker-D4o6enH0.cjs → ticker-Un0bvTWR.cjs} +2 -2
- package/dist/chunks/{ticker-D4o6enH0.cjs.map → ticker-Un0bvTWR.cjs.map} +1 -1
- package/dist/chunks/{tween-CqX1JBuj.js → tween-BcejKpsx.js} +15 -91
- package/dist/chunks/tween-BcejKpsx.js.map +1 -0
- package/dist/chunks/{tween-CBuWYpI-.cjs → tween-CwLLC3Ko.cjs} +15 -95
- package/dist/chunks/tween-CwLLC3Ko.cjs.map +1 -0
- package/dist/chunks/variants-CrDDJoYK.cjs.map +1 -1
- package/dist/chunks/{variants-GU3yIL4F.js → variants-CsRGUIyA.js} +2 -2
- package/dist/chunks/{variants-GU3yIL4F.js.map → variants-CsRGUIyA.js.map} +1 -1
- package/dist/components/a11y.cjs.map +1 -1
- package/dist/components/a11y.js +2 -2
- package/dist/components/a11y.js.map +1 -1
- package/dist/components/angular.cjs.map +1 -1
- package/dist/components/angular.js +8 -8
- package/dist/components/angular.js.map +1 -1
- package/dist/components/background.cjs.map +1 -1
- package/dist/components/background.js +2 -2
- package/dist/components/background.js.map +1 -1
- package/dist/components/bridge.cjs.map +1 -1
- package/dist/components/bridge.js +1 -1
- package/dist/components/bridge.js.map +1 -1
- package/dist/components/cards.cjs.map +1 -1
- package/dist/components/cards.js +2 -2
- package/dist/components/cards.js.map +1 -1
- package/dist/components/click.cjs.map +1 -1
- package/dist/components/click.js +3 -3
- package/dist/components/click.js.map +1 -1
- package/dist/components/core.cjs.map +1 -1
- package/dist/components/core.js.map +1 -1
- package/dist/components/depth.cjs.map +1 -1
- package/dist/components/depth.js +3 -3
- package/dist/components/depth.js.map +1 -1
- package/dist/components/design.cjs.map +1 -1
- package/dist/components/design.js +3 -3
- package/dist/components/design.js.map +1 -1
- package/dist/components/dsl.cjs.map +1 -1
- package/dist/components/dsl.js +2 -2
- package/dist/components/dsl.js.map +1 -1
- package/dist/components/effects.cjs.map +1 -1
- package/dist/components/effects.js +9 -9
- package/dist/components/effects.js.map +1 -1
- package/dist/components/engine.cjs.map +1 -1
- package/dist/components/engine.js +2 -2
- package/dist/components/engine.js.map +1 -1
- package/dist/components/feedback.cjs.map +1 -1
- package/dist/components/feedback.js +1 -1
- package/dist/components/feedback.js.map +1 -1
- package/dist/components/fx-3d.cjs.map +1 -1
- package/dist/components/fx-3d.js +2 -2
- package/dist/components/fx-3d.js.map +1 -1
- package/dist/components/fx-ai.cjs.map +1 -1
- package/dist/components/fx-ai.js +2 -2
- package/dist/components/fx-ai.js.map +1 -1
- package/dist/components/fx-chart.cjs.map +1 -1
- package/dist/components/fx-chart.js +2 -2
- package/dist/components/fx-chart.js.map +1 -1
- package/dist/components/fx-cinema.cjs.map +1 -1
- package/dist/components/fx-cinema.js +2 -2
- package/dist/components/fx-cinema.js.map +1 -1
- package/dist/components/fx-cyber.cjs.map +1 -1
- package/dist/components/fx-cyber.js +2 -2
- package/dist/components/fx-cyber.js.map +1 -1
- package/dist/components/fx-festival.cjs.map +1 -1
- package/dist/components/fx-festival.js +2 -2
- package/dist/components/fx-festival.js.map +1 -1
- package/dist/components/fx-focus.cjs.map +1 -1
- package/dist/components/fx-focus.js +2 -2
- package/dist/components/fx-focus.js.map +1 -1
- package/dist/components/fx-form.cjs.map +1 -1
- package/dist/components/fx-form.js +2 -2
- package/dist/components/fx-form.js.map +1 -1
- package/dist/components/fx-game.cjs.map +1 -1
- package/dist/components/fx-game.js +2 -2
- package/dist/components/fx-game.js.map +1 -1
- package/dist/components/fx-genart.cjs.map +1 -1
- package/dist/components/fx-genart.js +2 -2
- package/dist/components/fx-genart.js.map +1 -1
- package/dist/components/fx-geo.cjs.map +1 -1
- package/dist/components/fx-geo.js +2 -2
- package/dist/components/fx-geo.js.map +1 -1
- package/dist/components/fx-gesture.cjs.map +1 -1
- package/dist/components/fx-gesture.js +2 -2
- package/dist/components/fx-gesture.js.map +1 -1
- package/dist/components/fx-gpu.js +3 -3
- package/dist/components/fx-light.cjs.map +1 -1
- package/dist/components/fx-light.js +2 -2
- package/dist/components/fx-light.js.map +1 -1
- package/dist/components/fx-lottie.cjs.map +1 -1
- package/dist/components/fx-lottie.js +2 -2
- package/dist/components/fx-lottie.js.map +1 -1
- package/dist/components/fx-morph.cjs.map +1 -1
- package/dist/components/fx-morph.js +2 -2
- package/dist/components/fx-morph.js.map +1 -1
- package/dist/components/fx-music.cjs.map +1 -1
- package/dist/components/fx-music.js +3 -3
- package/dist/components/fx-music.js.map +1 -1
- package/dist/components/fx-organic.cjs.map +1 -1
- package/dist/components/fx-organic.js +2 -2
- package/dist/components/fx-organic.js.map +1 -1
- package/dist/components/fx-paper.cjs.map +1 -1
- package/dist/components/fx-paper.js +2 -2
- package/dist/components/fx-paper.js.map +1 -1
- package/dist/components/fx-perf.cjs.map +1 -1
- package/dist/components/fx-perf.js +2 -2
- package/dist/components/fx-perf.js.map +1 -1
- package/dist/components/fx-physics.cjs.map +1 -1
- package/dist/components/fx-physics.js +2 -2
- package/dist/components/fx-physics.js.map +1 -1
- package/dist/components/fx-retro.cjs.map +1 -1
- package/dist/components/fx-retro.js +2 -2
- package/dist/components/fx-retro.js.map +1 -1
- package/dist/components/fx-safe.cjs.map +1 -1
- package/dist/components/fx-safe.js +2 -2
- package/dist/components/fx-safe.js.map +1 -1
- package/dist/components/fx-shop.cjs.map +1 -1
- package/dist/components/fx-shop.js +2 -2
- package/dist/components/fx-shop.js.map +1 -1
- package/dist/components/fx-social.cjs.map +1 -1
- package/dist/components/fx-social.js +2 -2
- package/dist/components/fx-social.js.map +1 -1
- package/dist/components/fx-spatial.cjs.map +1 -1
- package/dist/components/fx-spatial.js +2 -2
- package/dist/components/fx-spatial.js.map +1 -1
- package/dist/components/fx-surface.cjs.map +1 -1
- package/dist/components/fx-surface.js +2 -2
- package/dist/components/fx-surface.js.map +1 -1
- package/dist/components/fx-text.cjs.map +1 -1
- package/dist/components/fx-text.js +2 -2
- package/dist/components/fx-text.js.map +1 -1
- package/dist/components/fx-transitions.cjs.map +1 -1
- package/dist/components/fx-transitions.js +3 -3
- package/dist/components/fx-transitions.js.map +1 -1
- package/dist/components/fx-video.cjs.map +1 -1
- package/dist/components/fx-video.js +2 -2
- package/dist/components/fx-video.js.map +1 -1
- package/dist/components/fx-weather.cjs.map +1 -1
- package/dist/components/fx-weather.js +2 -2
- package/dist/components/fx-weather.js.map +1 -1
- package/dist/components/fx.cjs.map +1 -1
- package/dist/components/fx.js +6 -6
- package/dist/components/fx.js.map +1 -1
- package/dist/components/fx2.cjs.map +1 -1
- package/dist/components/fx2.js +6 -6
- package/dist/components/fx2.js.map +1 -1
- package/dist/components/gesture.cjs.map +1 -1
- package/dist/components/gesture.js +4 -4
- package/dist/components/gesture.js.map +1 -1
- package/dist/components/interaction.cjs.map +1 -1
- package/dist/components/interaction.js +1 -1
- package/dist/components/interaction.js.map +1 -1
- package/dist/components/layout.cjs.map +1 -1
- package/dist/components/layout.js +1 -1
- package/dist/components/layout.js.map +1 -1
- package/dist/components/lazy.cjs.map +1 -1
- package/dist/components/lazy.js.map +1 -1
- package/dist/components/lite.cjs.map +1 -1
- package/dist/components/lite.js.map +1 -1
- package/dist/components/marketplace.cjs.map +1 -1
- package/dist/components/marketplace.js +4 -4
- package/dist/components/marketplace.js.map +1 -1
- package/dist/components/native.cjs.map +1 -1
- package/dist/components/native.js +3 -3
- package/dist/components/native.js.map +1 -1
- package/dist/components/packs.cjs.map +1 -1
- package/dist/components/packs.js +1 -1
- package/dist/components/packs.js.map +1 -1
- package/dist/components/page.cjs.map +1 -1
- package/dist/components/page.js +3 -3
- package/dist/components/page.js.map +1 -1
- package/dist/components/perf.cjs.map +1 -1
- package/dist/components/perf.js +2 -2
- package/dist/components/perf.js.map +1 -1
- package/dist/components/physics.cjs.map +1 -1
- package/dist/components/physics.js +3 -3
- package/dist/components/physics.js.map +1 -1
- package/dist/components/plugins.cjs.map +1 -1
- package/dist/components/plugins.js +4 -4
- package/dist/components/plugins.js.map +1 -1
- package/dist/components/react.cjs.map +1 -1
- package/dist/components/react.js.map +1 -1
- package/dist/components/reveal.cjs.map +1 -1
- package/dist/components/reveal.js +1 -1
- package/dist/components/reveal.js.map +1 -1
- package/dist/components/solid.cjs.map +1 -1
- package/dist/components/solid.js +8 -8
- package/dist/components/solid.js.map +1 -1
- package/dist/components/svelte.cjs.map +1 -1
- package/dist/components/svelte.js +8 -8
- package/dist/components/svelte.js.map +1 -1
- package/dist/components/svg.cjs.map +1 -1
- package/dist/components/svg.js +1 -1
- package/dist/components/svg.js.map +1 -1
- package/dist/components/text.cjs.map +1 -1
- package/dist/components/text.js +2 -2
- package/dist/components/text.js.map +1 -1
- package/dist/components/timeline.cjs.map +1 -1
- package/dist/components/timeline.js +3 -3
- package/dist/components/timeline.js.map +1 -1
- package/dist/components/tokens.cjs.map +1 -1
- package/dist/components/tokens.js.map +1 -1
- package/dist/components/transitions.cjs.map +1 -1
- package/dist/components/transitions.js +1 -1
- package/dist/components/transitions.js.map +1 -1
- package/dist/components/ui.cjs.map +1 -1
- package/dist/components/ui.js +4 -4
- package/dist/components/ui.js.map +1 -1
- package/dist/components/vue.cjs.map +1 -1
- package/dist/components/vue.js +8 -8
- package/dist/components/vue.js.map +1 -1
- package/dist/components/webgl.cjs.map +1 -1
- package/dist/components/webgl.js +1 -1
- package/dist/components/webgl.js.map +1 -1
- package/dist/components/widgets.cjs +766 -212
- package/dist/components/widgets.cjs.map +1 -1
- package/dist/components/widgets.d.cts +207 -2
- package/dist/components/widgets.d.ts +207 -2
- package/dist/components/widgets.js +770 -221
- package/dist/components/widgets.js.map +1 -1
- package/dist/components.cjs.map +1 -1
- package/dist/components.js +10 -10
- package/dist/components.js.map +1 -1
- package/dist/element.cjs.map +1 -1
- package/dist/element.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/llms-full.txt +250 -1
- package/dist/llms.txt +13 -2
- package/dist/manifest.json +646 -1
- package/dist/presets/extended.cjs.map +1 -1
- package/dist/presets/extended.js.map +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.js.map +1 -1
- package/dist/runtime/format-apng.cjs +131 -0
- package/dist/runtime/format-apng.cjs.map +1 -0
- package/dist/runtime/format-apng.d.cts +250 -0
- package/dist/runtime/format-apng.d.ts +250 -0
- package/dist/runtime/format-apng.iife.js +2 -0
- package/dist/runtime/format-apng.iife.js.map +1 -0
- package/dist/runtime/format-apng.js +123 -0
- package/dist/runtime/format-apng.js.map +1 -0
- package/dist/runtime/format-css.cjs +5 -4
- package/dist/runtime/format-css.cjs.map +1 -1
- package/dist/runtime/format-css.js +5 -4
- package/dist/runtime/format-css.js.map +1 -1
- package/dist/runtime/format-gif.cjs +206 -0
- package/dist/runtime/format-gif.cjs.map +1 -0
- package/dist/runtime/format-gif.d.cts +223 -0
- package/dist/runtime/format-gif.d.ts +223 -0
- package/dist/runtime/format-gif.iife.js +2 -0
- package/dist/runtime/format-gif.iife.js.map +1 -0
- package/dist/runtime/format-gif.js +199 -0
- package/dist/runtime/format-gif.js.map +1 -0
- package/dist/runtime/format-motion.cjs +9 -8
- package/dist/runtime/format-motion.cjs.map +1 -1
- package/dist/runtime/format-motion.js +5 -4
- package/dist/runtime/format-motion.js.map +1 -1
- package/dist/runtime/format-sprite.cjs +226 -0
- package/dist/runtime/format-sprite.cjs.map +1 -0
- package/dist/runtime/format-sprite.d.cts +224 -0
- package/dist/runtime/format-sprite.d.ts +224 -0
- package/dist/runtime/format-sprite.iife.js +2 -0
- package/dist/runtime/format-sprite.iife.js.map +1 -0
- package/dist/runtime/format-sprite.js +216 -0
- package/dist/runtime/format-sprite.js.map +1 -0
- package/dist/runtime/format-svg.cjs +5 -4
- package/dist/runtime/format-svg.cjs.map +1 -1
- package/dist/runtime/format-svg.iife.js.map +1 -1
- package/dist/runtime/format-svg.js +4 -3
- package/dist/runtime/format-svg.js.map +1 -1
- package/dist/runtime/format-webp.cjs +123 -0
- package/dist/runtime/format-webp.cjs.map +1 -0
- package/dist/runtime/format-webp.d.cts +245 -0
- package/dist/runtime/format-webp.d.ts +245 -0
- package/dist/runtime/format-webp.iife.js +2 -0
- package/dist/runtime/format-webp.iife.js.map +1 -0
- package/dist/runtime/format-webp.js +115 -0
- package/dist/runtime/format-webp.js.map +1 -0
- package/dist/runtime/scroll.cjs +2 -2
- package/dist/runtime/scroll.cjs.map +1 -1
- package/dist/runtime/scroll.js +2 -2
- package/dist/runtime/scroll.js.map +1 -1
- package/dist/runtime/smooth.cjs +284 -0
- package/dist/runtime/smooth.cjs.map +1 -0
- package/dist/runtime/smooth.d.cts +137 -0
- package/dist/runtime/smooth.d.ts +137 -0
- package/dist/runtime/smooth.iife.js +2 -0
- package/dist/runtime/smooth.iife.js.map +1 -0
- package/dist/runtime/smooth.js +279 -0
- package/dist/runtime/smooth.js.map +1 -0
- package/dist/runtime/text.cjs +147 -0
- package/dist/runtime/text.cjs.map +1 -0
- package/dist/runtime/text.d.cts +65 -0
- package/dist/runtime/text.d.ts +65 -0
- package/dist/runtime/text.iife.js +2 -0
- package/dist/runtime/text.iife.js.map +1 -0
- package/dist/runtime/text.js +143 -0
- package/dist/runtime/text.js.map +1 -0
- package/dist/runtime.cjs +9 -8
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +9 -2
- package/dist/runtime.d.ts +9 -2
- package/dist/runtime.iife.js +1 -1
- package/dist/runtime.iife.js.map +1 -1
- package/dist/runtime.js +6 -5
- package/dist/runtime.js.map +1 -1
- package/dist/solid.cjs.map +1 -1
- package/dist/solid.js.map +1 -1
- package/dist/svelte.cjs.map +1 -1
- package/dist/svelte.js.map +1 -1
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.js.map +1 -1
- package/dist/widgets.umd.js +1 -1
- package/dist/widgets.umd.js.map +1 -1
- package/docs/ROADMAP.md +2 -2
- package/docs/components/README.md +12 -7
- package/docs/components/usa-parallax-layers.md +38 -0
- package/docs/components/usa-route-transition.md +38 -0
- package/docs/components/usa-scroll-ring.md +32 -0
- package/docs/components/usa-smooth-scroll.md +60 -0
- package/docs/components/usa-text-splitter.md +60 -0
- package/docs/components.md +94 -0
- package/docs/mcp.md +50 -0
- package/docs/runtime/format-apng.md +59 -0
- package/docs/runtime/format-gif.md +60 -0
- package/docs/runtime/format-sprite.md +60 -0
- package/docs/runtime/format-webp.md +58 -0
- package/docs/runtime/smooth.md +60 -0
- package/docs/runtime/text.md +59 -0
- package/package.json +64 -2
- package/dist/chunks/keyframes-W-474DMc.js.map +0 -1
- package/dist/chunks/keyframes-ZheOkpt0.cjs.map +0 -1
- package/dist/chunks/tween-CBuWYpI-.cjs.map +0 -1
- package/dist/chunks/tween-CqX1JBuj.js.map +0 -1
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var registry = require('../chunks/registry-tzwKkldE.cjs');
|
|
4
|
+
var ease = require('../chunks/ease-HwYZnZat.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `motionary/runtime/smooth` (10.4) — smooth (inertial) scrolling on the
|
|
8
|
+
* runtime ticker, written for Motionary (own implementation and API).
|
|
9
|
+
*
|
|
10
|
+
* - Wheel / trackpad input is eased towards its target (`lerp` or a fixed
|
|
11
|
+
* `duration` + `ease`) on the shared ticker; keyboard, scrollbar dragging,
|
|
12
|
+
* find-in-page and screen-reader scrolling stay native (the target follows
|
|
13
|
+
* them), touch stays native by default (`touch: true` to smooth it).
|
|
14
|
+
* - Works on the window or inside any scrollable `wrapper`; vertical or
|
|
15
|
+
* horizontal; nested scrollables and `[data-smooth-ignore]` are left alone.
|
|
16
|
+
* - Anchor links (`#id`) glide to their target (with `offset`), focus moves
|
|
17
|
+
* for keyboard users, and the URL hash is kept.
|
|
18
|
+
* - **Off under `prefers-reduced-motion: reduce`** (and while the media query
|
|
19
|
+
* matches; it re-enables when it stops matching) — wheel scrolling is then
|
|
20
|
+
* fully native. `force: true` overrides this only for non-motion use cases.
|
|
21
|
+
* - Real `scroll` events still fire, so `motionary/runtime/scroll` scenes,
|
|
22
|
+
* IntersectionObservers and CSS scroll timelines all keep working.
|
|
23
|
+
* SSR-safe: nothing touches `window` until `smoothScroll()` is called.
|
|
24
|
+
*/
|
|
25
|
+
const clamp = (v, a, b) => Math.min(b, Math.max(a, v));
|
|
26
|
+
const instances = new Set();
|
|
27
|
+
class SmoothScroll {
|
|
28
|
+
constructor(o = {}) {
|
|
29
|
+
/** Current (animated) scroll position, px. */
|
|
30
|
+
this.current = 0;
|
|
31
|
+
/** Where the scroll is heading, px. */
|
|
32
|
+
this.target = 0;
|
|
33
|
+
/** px per frame of the last update. */
|
|
34
|
+
this.velocity = 0;
|
|
35
|
+
/** True while gliding. */
|
|
36
|
+
this.isScrolling = false;
|
|
37
|
+
this.stopped = false;
|
|
38
|
+
this.reduced = false;
|
|
39
|
+
this.off = [];
|
|
40
|
+
this.tickOff = null;
|
|
41
|
+
this.written = NaN;
|
|
42
|
+
this.glide = null;
|
|
43
|
+
this.listeners = new Set();
|
|
44
|
+
this.touchY = 0;
|
|
45
|
+
if (typeof window === 'undefined')
|
|
46
|
+
throw new Error('[motionary] smoothScroll() needs a browser (call it on the client)');
|
|
47
|
+
this.o = o;
|
|
48
|
+
const w = o.wrapper || window;
|
|
49
|
+
this.win = w === window;
|
|
50
|
+
this.el = this.win ? document.scrollingElement || document.documentElement : w;
|
|
51
|
+
if (o.onScroll)
|
|
52
|
+
this.listeners.add(o.onScroll);
|
|
53
|
+
this.current = this.target = this.native;
|
|
54
|
+
const mq = typeof matchMedia === 'function' ? matchMedia('(prefers-reduced-motion: reduce)') : null;
|
|
55
|
+
const syncMq = () => {
|
|
56
|
+
this.reduced = !!mq?.matches && !o.force;
|
|
57
|
+
this.el.classList.toggle('usa-smooth', !this.reduced && !this.stopped);
|
|
58
|
+
};
|
|
59
|
+
syncMq();
|
|
60
|
+
if (mq)
|
|
61
|
+
this.on(mq, 'change', syncMq);
|
|
62
|
+
const evTarget = this.win ? window : this.el;
|
|
63
|
+
this.on(evTarget, 'wheel', (e) => this.wheel(e), { passive: false });
|
|
64
|
+
if (o.touch) {
|
|
65
|
+
this.on(evTarget, 'touchstart', (e) => (this.touchY = this.axis(e.touches[0].clientX, e.touches[0].clientY)), { passive: true });
|
|
66
|
+
this.on(evTarget, 'touchmove', (e) => {
|
|
67
|
+
if (!this.active || e.touches.length !== 1)
|
|
68
|
+
return;
|
|
69
|
+
const p = this.axis(e.touches[0].clientX, e.touches[0].clientY);
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
this.push((this.touchY - p) * (o.touchMultiplier ?? 1.5));
|
|
72
|
+
this.touchY = p;
|
|
73
|
+
}, { passive: false });
|
|
74
|
+
}
|
|
75
|
+
// native scrolling (keyboard, scrollbar, find, focus, assistive tech): follow it
|
|
76
|
+
this.on(evTarget, 'scroll', () => {
|
|
77
|
+
if (Math.abs(this.native - this.written) <= 1)
|
|
78
|
+
return; // our own write (browsers may coalesce several into one event)
|
|
79
|
+
// someone else scrolled (keyboard, scrollbar drag, find, focus): adopt it and drop any glide
|
|
80
|
+
this.halt();
|
|
81
|
+
this.glide = null;
|
|
82
|
+
this.current = this.target = this.native;
|
|
83
|
+
}, { passive: true });
|
|
84
|
+
if (o.anchors !== false)
|
|
85
|
+
this.on(this.win ? document : this.el, 'click', (e) => this.anchor(e));
|
|
86
|
+
instances.add(this);
|
|
87
|
+
}
|
|
88
|
+
on(t, type, fn, opt) {
|
|
89
|
+
t.addEventListener(type, fn, opt);
|
|
90
|
+
this.off.push(() => t.removeEventListener(type, fn, opt));
|
|
91
|
+
}
|
|
92
|
+
get horizontal() {
|
|
93
|
+
return this.o.orientation === 'horizontal';
|
|
94
|
+
}
|
|
95
|
+
axis(x, y) {
|
|
96
|
+
return this.horizontal ? x : y;
|
|
97
|
+
}
|
|
98
|
+
/** The scroll position the browser reports. */
|
|
99
|
+
get native() {
|
|
100
|
+
return this.horizontal ? this.el.scrollLeft : this.el.scrollTop;
|
|
101
|
+
}
|
|
102
|
+
/** Maximum scroll, px. */
|
|
103
|
+
get limit() {
|
|
104
|
+
return this.horizontal ? this.el.scrollWidth - this.el.clientWidth : this.el.scrollHeight - this.el.clientHeight;
|
|
105
|
+
}
|
|
106
|
+
/** 0–1 */
|
|
107
|
+
get progress() {
|
|
108
|
+
return this.limit ? this.current / this.limit : 0;
|
|
109
|
+
}
|
|
110
|
+
/** Smoothing is running (not stopped, not reduced motion). */
|
|
111
|
+
get active() {
|
|
112
|
+
return !this.stopped && !this.reduced;
|
|
113
|
+
}
|
|
114
|
+
wheel(e) {
|
|
115
|
+
if (!this.active || e.ctrlKey)
|
|
116
|
+
return; // ctrl+wheel = zoom
|
|
117
|
+
// leave nested scrollables / opted-out regions alone
|
|
118
|
+
for (let n = e.target; n && n !== this.el; n = n.parentElement) {
|
|
119
|
+
if (n.hasAttribute?.('data-smooth-ignore'))
|
|
120
|
+
return;
|
|
121
|
+
if (n !== document.body && n.scrollHeight > n.clientHeight + 1 && /(auto|scroll)/.test(getComputedStyle(n).overflowY))
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const unit = e.deltaMode === 1 ? 40 : e.deltaMode === 2 ? (this.horizontal ? this.el.clientWidth : this.el.clientHeight) : 1;
|
|
125
|
+
const d = (this.horizontal ? e.deltaX || e.deltaY : e.deltaY) * unit * (this.o.wheelMultiplier ?? 1);
|
|
126
|
+
const next = clamp(this.target + d, 0, this.limit);
|
|
127
|
+
if (next === this.target && (this.target <= 0 || this.target >= this.limit))
|
|
128
|
+
return; // at an edge: let the page / parent handle it
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
this.push(d);
|
|
131
|
+
}
|
|
132
|
+
push(d) {
|
|
133
|
+
this.glide = null;
|
|
134
|
+
this.target = clamp(this.target + d, 0, this.limit);
|
|
135
|
+
this.start();
|
|
136
|
+
}
|
|
137
|
+
start() {
|
|
138
|
+
if (this.tickOff)
|
|
139
|
+
return;
|
|
140
|
+
this.isScrolling = true;
|
|
141
|
+
this.tickOff = registry.requireModule('core', 'motionary/runtime/smooth').getTicker().add((_, dt) => this.tick(dt));
|
|
142
|
+
}
|
|
143
|
+
tick(dt) {
|
|
144
|
+
const prev = this.current;
|
|
145
|
+
if (this.glide) {
|
|
146
|
+
const g = this.glide;
|
|
147
|
+
g.t = Math.min(g.d, g.t + dt);
|
|
148
|
+
this.current = g.from + (g.to - g.from) * g.ease(g.d ? g.t / g.d : 1);
|
|
149
|
+
if (g.t >= g.d) {
|
|
150
|
+
this.current = this.target = g.to;
|
|
151
|
+
this.glide = null;
|
|
152
|
+
g.done?.();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else if (this.o.duration) {
|
|
156
|
+
this.glide = { from: this.current, to: this.target, t: 0, d: this.o.duration, ease: this.easeOf(this.o.ease) };
|
|
157
|
+
return this.tick(dt);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
// frame-rate independent lerp
|
|
161
|
+
const k = 1 - Math.pow(1 - clamp(this.o.lerp ?? 0.1, 0.001, 1), dt / (1000 / 60));
|
|
162
|
+
this.current += (this.target - this.current) * k;
|
|
163
|
+
if (Math.abs(this.target - this.current) < 0.5)
|
|
164
|
+
this.current = this.target;
|
|
165
|
+
}
|
|
166
|
+
this.velocity = this.current - prev;
|
|
167
|
+
this.write(this.current);
|
|
168
|
+
this.listeners.forEach((f) => f(this));
|
|
169
|
+
if (this.current === this.target && !this.glide)
|
|
170
|
+
this.halt();
|
|
171
|
+
}
|
|
172
|
+
easeOf(e) {
|
|
173
|
+
return typeof e === 'function' ? e : ease.parseEase(e || 'expo-out');
|
|
174
|
+
}
|
|
175
|
+
write(v) {
|
|
176
|
+
const r = Math.round(v * 100) / 100;
|
|
177
|
+
if (Math.abs(this.native - r) < 0.5)
|
|
178
|
+
return;
|
|
179
|
+
if (this.horizontal)
|
|
180
|
+
this.el.scrollLeft = r;
|
|
181
|
+
else
|
|
182
|
+
this.el.scrollTop = r;
|
|
183
|
+
this.written = this.native; // what the browser actually stored (it may round to device pixels)
|
|
184
|
+
}
|
|
185
|
+
halt() {
|
|
186
|
+
this.tickOff?.();
|
|
187
|
+
this.tickOff = null;
|
|
188
|
+
this.isScrolling = false;
|
|
189
|
+
this.velocity = 0;
|
|
190
|
+
}
|
|
191
|
+
anchor(e) {
|
|
192
|
+
if (e.defaultPrevented || e.button || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)
|
|
193
|
+
return;
|
|
194
|
+
const a = e.target.closest?.('a[href*="#"]');
|
|
195
|
+
if (!a || a.target === '_blank')
|
|
196
|
+
return;
|
|
197
|
+
const u = new URL(a.href, location.href);
|
|
198
|
+
if (u.origin !== location.origin || u.pathname !== location.pathname || !u.hash)
|
|
199
|
+
return;
|
|
200
|
+
const id = decodeURIComponent(u.hash.slice(1));
|
|
201
|
+
const t = id === 'top' ? null : document.getElementById(id);
|
|
202
|
+
if (id !== 'top' && !t)
|
|
203
|
+
return;
|
|
204
|
+
if (!this.win && t && !this.el.contains(t))
|
|
205
|
+
return;
|
|
206
|
+
e.preventDefault();
|
|
207
|
+
const off = typeof this.o.anchors === 'object' ? this.o.anchors.offset || 0 : 0;
|
|
208
|
+
this.scrollTo(t || 0, { offset: off, onComplete: () => {
|
|
209
|
+
if (t) {
|
|
210
|
+
if (!t.hasAttribute('tabindex') && !/^(a|button|input|select|textarea)$/i.test(t.tagName))
|
|
211
|
+
t.setAttribute('tabindex', '-1');
|
|
212
|
+
t.focus({ preventScroll: true });
|
|
213
|
+
}
|
|
214
|
+
} });
|
|
215
|
+
if (history.pushState)
|
|
216
|
+
history.pushState(null, '', u.hash);
|
|
217
|
+
}
|
|
218
|
+
/** Scroll to a position (px), an element, or a selector. Animated unless reduced motion / `immediate`. */
|
|
219
|
+
scrollTo(to, o = {}) {
|
|
220
|
+
let y;
|
|
221
|
+
if (typeof to === 'number')
|
|
222
|
+
y = to;
|
|
223
|
+
else {
|
|
224
|
+
const el = typeof to === 'string' ? document.querySelector(to) : to;
|
|
225
|
+
if (!el)
|
|
226
|
+
return;
|
|
227
|
+
const r = el.getBoundingClientRect();
|
|
228
|
+
const base = this.win ? 0 : this.axis(this.el.getBoundingClientRect().left, this.el.getBoundingClientRect().top);
|
|
229
|
+
y = this.native + this.axis(r.left, r.top) - base;
|
|
230
|
+
}
|
|
231
|
+
y = clamp(y + (o.offset || 0), 0, this.limit);
|
|
232
|
+
if (o.immediate || !this.active) {
|
|
233
|
+
this.halt();
|
|
234
|
+
this.glide = null;
|
|
235
|
+
this.current = this.target = y;
|
|
236
|
+
this.write(y);
|
|
237
|
+
o.onComplete?.();
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
this.target = y;
|
|
241
|
+
this.glide = { from: this.current, to: y, t: 0, d: o.duration ?? this.o.duration ?? Math.min(1200, 400 + Math.abs(y - this.current) * 0.4), ease: this.easeOf(o.ease ?? this.o.ease), done: o.onComplete };
|
|
242
|
+
this.start();
|
|
243
|
+
}
|
|
244
|
+
/** Pause smoothing (native scrolling everywhere) — e.g. while a modal is open. */
|
|
245
|
+
stop() {
|
|
246
|
+
this.stopped = true;
|
|
247
|
+
this.halt();
|
|
248
|
+
this.el.classList.remove('usa-smooth');
|
|
249
|
+
}
|
|
250
|
+
/** Resume after `stop()`. */
|
|
251
|
+
resume() {
|
|
252
|
+
this.stopped = false;
|
|
253
|
+
this.current = this.target = this.native;
|
|
254
|
+
this.el.classList.toggle('usa-smooth', !this.reduced);
|
|
255
|
+
}
|
|
256
|
+
/** Listen to every smoothed frame; returns an unsubscribe function. */
|
|
257
|
+
onScroll(fn) {
|
|
258
|
+
this.listeners.add(fn);
|
|
259
|
+
return () => this.listeners.delete(fn);
|
|
260
|
+
}
|
|
261
|
+
/** Remove all listeners and restore native scrolling. */
|
|
262
|
+
destroy() {
|
|
263
|
+
this.halt();
|
|
264
|
+
this.off.forEach((f) => f());
|
|
265
|
+
this.off = [];
|
|
266
|
+
this.listeners.clear();
|
|
267
|
+
this.el.classList.remove('usa-smooth');
|
|
268
|
+
instances.delete(this);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/** Start smooth scrolling (see module docs). Off under reduced motion. */
|
|
272
|
+
function smoothScroll(o = {}) {
|
|
273
|
+
return new SmoothScroll(o);
|
|
274
|
+
}
|
|
275
|
+
/** Every live instance. */
|
|
276
|
+
const allSmooth = () => Array.from(instances);
|
|
277
|
+
/** The module object for `use(smooth)`. */
|
|
278
|
+
const smooth = { id: 'smooth', version: registry.RUNTIME_VERSION, requires: ['core'], api: { smoothScroll, allSmooth, SmoothScroll } };
|
|
279
|
+
|
|
280
|
+
exports.SmoothScroll = SmoothScroll;
|
|
281
|
+
exports.allSmooth = allSmooth;
|
|
282
|
+
exports.smooth = smooth;
|
|
283
|
+
exports.smoothScroll = smoothScroll;
|
|
284
|
+
//# sourceMappingURL=smooth.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smooth.cjs","sources":["../../src/runtime/smooth.ts"],"sourcesContent":["/**\n * `motionary/runtime/smooth` (10.4) — smooth (inertial) scrolling on the\n * runtime ticker, written for Motionary (own implementation and API).\n *\n * - Wheel / trackpad input is eased towards its target (`lerp` or a fixed\n * `duration` + `ease`) on the shared ticker; keyboard, scrollbar dragging,\n * find-in-page and screen-reader scrolling stay native (the target follows\n * them), touch stays native by default (`touch: true` to smooth it).\n * - Works on the window or inside any scrollable `wrapper`; vertical or\n * horizontal; nested scrollables and `[data-smooth-ignore]` are left alone.\n * - Anchor links (`#id`) glide to their target (with `offset`), focus moves\n * for keyboard users, and the URL hash is kept.\n * - **Off under `prefers-reduced-motion: reduce`** (and while the media query\n * matches; it re-enables when it stops matching) — wheel scrolling is then\n * fully native. `force: true` overrides this only for non-motion use cases.\n * - Real `scroll` events still fire, so `motionary/runtime/scroll` scenes,\n * IntersectionObservers and CSS scroll timelines all keep working.\n * SSR-safe: nothing touches `window` until `smoothScroll()` is called.\n */\nimport { RUNTIME_VERSION, requireModule, type RuntimeModule } from './registry';\nimport type { CoreApi } from './index';\nimport { parseEase, type Ease } from './ease';\n\nexport interface SmoothOptions {\n /** Scroll container (default: the window / document scroller). */\n wrapper?: HTMLElement | Window;\n /** Easing factor per 60 fps frame, 0–1 (default 0.1). Ignored when `duration` is set. */\n lerp?: number;\n /** Fixed glide time in ms (with `ease`) instead of `lerp`. */\n duration?: number;\n ease?: string | Ease;\n orientation?: 'vertical' | 'horizontal';\n /** Wheel delta multiplier (default 1). */\n wheelMultiplier?: number;\n /** Smooth touch scrolling too (default false: native momentum is better on touch devices). */\n touch?: boolean;\n touchMultiplier?: number;\n /** Glide to `#anchor` links (default true). */\n anchors?: boolean | { offset?: number };\n /** Ignore prefers-reduced-motion (default false — leave it off unless the motion is essential). */\n force?: boolean;\n onScroll?: (s: SmoothScroll) => void;\n}\n\nexport interface ScrollToOptions2 {\n offset?: number;\n /** Jump without animating. */\n immediate?: boolean;\n duration?: number;\n ease?: string | Ease;\n onComplete?: () => void;\n}\n\nconst clamp = (v: number, a: number, b: number) => Math.min(b, Math.max(a, v));\nconst instances = new Set<SmoothScroll>();\n\nexport class SmoothScroll {\n /** Current (animated) scroll position, px. */\n current = 0;\n /** Where the scroll is heading, px. */\n target = 0;\n /** px per frame of the last update. */\n velocity = 0;\n /** True while gliding. */\n isScrolling = false;\n private o: SmoothOptions;\n private el: HTMLElement;\n private win: boolean;\n private stopped = false;\n private reduced = false;\n private off: (() => void)[] = [];\n private tickOff: (() => void) | null = null;\n private written = NaN;\n private glide: { from: number; to: number; t: number; d: number; ease: Ease; done?: () => void } | null = null;\n private listeners = new Set<(s: SmoothScroll) => void>();\n private touchY = 0;\n\n constructor(o: SmoothOptions = {}) {\n if (typeof window === 'undefined') throw new Error('[motionary] smoothScroll() needs a browser (call it on the client)');\n this.o = o;\n const w = o.wrapper || window;\n this.win = w === window;\n this.el = this.win ? (document.scrollingElement as HTMLElement) || document.documentElement : (w as HTMLElement);\n if (o.onScroll) this.listeners.add(o.onScroll);\n this.current = this.target = this.native;\n const mq = typeof matchMedia === 'function' ? matchMedia('(prefers-reduced-motion: reduce)') : null;\n const syncMq = () => {\n this.reduced = !!mq?.matches && !o.force;\n this.el.classList.toggle('usa-smooth', !this.reduced && !this.stopped);\n };\n syncMq();\n if (mq) this.on(mq as any, 'change', syncMq);\n const evTarget: EventTarget = this.win ? window : this.el;\n this.on(evTarget, 'wheel', (e: WheelEvent) => this.wheel(e), { passive: false });\n if (o.touch) {\n this.on(evTarget, 'touchstart', (e: TouchEvent) => (this.touchY = this.axis(e.touches[0].clientX, e.touches[0].clientY)), { passive: true });\n this.on(evTarget, 'touchmove', (e: TouchEvent) => {\n if (!this.active || e.touches.length !== 1) return;\n const p = this.axis(e.touches[0].clientX, e.touches[0].clientY);\n e.preventDefault();\n this.push((this.touchY - p) * (o.touchMultiplier ?? 1.5));\n this.touchY = p;\n }, { passive: false });\n }\n // native scrolling (keyboard, scrollbar, find, focus, assistive tech): follow it\n this.on(evTarget, 'scroll', () => {\n if (Math.abs(this.native - this.written) <= 1) return; // our own write (browsers may coalesce several into one event)\n // someone else scrolled (keyboard, scrollbar drag, find, focus): adopt it and drop any glide\n this.halt();\n this.glide = null;\n this.current = this.target = this.native;\n }, { passive: true });\n if (o.anchors !== false) this.on(this.win ? document : this.el, 'click', (e: MouseEvent) => this.anchor(e));\n instances.add(this);\n }\n\n private on(t: EventTarget, type: string, fn: (e: any) => void, opt?: AddEventListenerOptions): void {\n t.addEventListener(type, fn, opt);\n this.off.push(() => t.removeEventListener(type, fn, opt));\n }\n private get horizontal(): boolean {\n return this.o.orientation === 'horizontal';\n }\n private axis(x: number, y: number): number {\n return this.horizontal ? x : y;\n }\n /** The scroll position the browser reports. */\n get native(): number {\n return this.horizontal ? this.el.scrollLeft : this.el.scrollTop;\n }\n /** Maximum scroll, px. */\n get limit(): number {\n return this.horizontal ? this.el.scrollWidth - this.el.clientWidth : this.el.scrollHeight - this.el.clientHeight;\n }\n /** 0–1 */\n get progress(): number {\n return this.limit ? this.current / this.limit : 0;\n }\n /** Smoothing is running (not stopped, not reduced motion). */\n get active(): boolean {\n return !this.stopped && !this.reduced;\n }\n\n private wheel(e: WheelEvent): void {\n if (!this.active || e.ctrlKey) return; // ctrl+wheel = zoom\n // leave nested scrollables / opted-out regions alone\n for (let n = e.target as HTMLElement | null; n && n !== this.el; n = n.parentElement) {\n if (n.hasAttribute?.('data-smooth-ignore')) return;\n if (n !== document.body && n.scrollHeight > n.clientHeight + 1 && /(auto|scroll)/.test(getComputedStyle(n).overflowY)) return;\n }\n const unit = e.deltaMode === 1 ? 40 : e.deltaMode === 2 ? (this.horizontal ? this.el.clientWidth : this.el.clientHeight) : 1;\n const d = (this.horizontal ? e.deltaX || e.deltaY : e.deltaY) * unit * (this.o.wheelMultiplier ?? 1);\n const next = clamp(this.target + d, 0, this.limit);\n if (next === this.target && (this.target <= 0 || this.target >= this.limit)) return; // at an edge: let the page / parent handle it\n e.preventDefault();\n this.push(d);\n }\n private push(d: number): void {\n this.glide = null;\n this.target = clamp(this.target + d, 0, this.limit);\n this.start();\n }\n private start(): void {\n if (this.tickOff) return;\n this.isScrolling = true;\n this.tickOff = requireModule<CoreApi>('core', 'motionary/runtime/smooth').getTicker().add((_, dt) => this.tick(dt));\n }\n private tick(dt: number): void {\n const prev = this.current;\n if (this.glide) {\n const g = this.glide;\n g.t = Math.min(g.d, g.t + dt);\n this.current = g.from + (g.to - g.from) * g.ease(g.d ? g.t / g.d : 1);\n if (g.t >= g.d) {\n this.current = this.target = g.to;\n this.glide = null;\n g.done?.();\n }\n } else if (this.o.duration) {\n this.glide = { from: this.current, to: this.target, t: 0, d: this.o.duration, ease: this.easeOf(this.o.ease) };\n return this.tick(dt);\n } else {\n // frame-rate independent lerp\n const k = 1 - Math.pow(1 - clamp(this.o.lerp ?? 0.1, 0.001, 1), dt / (1000 / 60));\n this.current += (this.target - this.current) * k;\n if (Math.abs(this.target - this.current) < 0.5) this.current = this.target;\n }\n this.velocity = this.current - prev;\n this.write(this.current);\n this.listeners.forEach((f) => f(this));\n if (this.current === this.target && !this.glide) this.halt();\n }\n private easeOf(e?: string | Ease): Ease {\n return typeof e === 'function' ? e : parseEase(e || 'expo-out');\n }\n private write(v: number): void {\n const r = Math.round(v * 100) / 100;\n if (Math.abs(this.native - r) < 0.5) return;\n if (this.horizontal) this.el.scrollLeft = r;\n else this.el.scrollTop = r;\n this.written = this.native; // what the browser actually stored (it may round to device pixels)\n }\n private halt(): void {\n this.tickOff?.();\n this.tickOff = null;\n this.isScrolling = false;\n this.velocity = 0;\n }\n private anchor(e: MouseEvent): void {\n if (e.defaultPrevented || e.button || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;\n const a = (e.target as Element).closest?.('a[href*=\"#\"]') as HTMLAnchorElement | null;\n if (!a || a.target === '_blank') return;\n const u = new URL(a.href, location.href);\n if (u.origin !== location.origin || u.pathname !== location.pathname || !u.hash) return;\n const id = decodeURIComponent(u.hash.slice(1));\n const t = id === 'top' ? null : document.getElementById(id);\n if (id !== 'top' && !t) return;\n if (!this.win && t && !this.el.contains(t)) return;\n e.preventDefault();\n const off = typeof this.o.anchors === 'object' ? this.o.anchors.offset || 0 : 0;\n this.scrollTo(t || 0, { offset: off, onComplete: () => {\n if (t) {\n if (!t.hasAttribute('tabindex') && !/^(a|button|input|select|textarea)$/i.test(t.tagName)) t.setAttribute('tabindex', '-1');\n t.focus({ preventScroll: true });\n }\n } });\n if (history.pushState) history.pushState(null, '', u.hash);\n }\n\n /** Scroll to a position (px), an element, or a selector. Animated unless reduced motion / `immediate`. */\n scrollTo(to: number | string | Element, o: ScrollToOptions2 = {}): void {\n let y: number;\n if (typeof to === 'number') y = to;\n else {\n const el = typeof to === 'string' ? document.querySelector(to) : to;\n if (!el) return;\n const r = el.getBoundingClientRect();\n const base = this.win ? 0 : this.axis(this.el.getBoundingClientRect().left, this.el.getBoundingClientRect().top);\n y = this.native + this.axis(r.left, r.top) - base;\n }\n y = clamp(y + (o.offset || 0), 0, this.limit);\n if (o.immediate || !this.active) {\n this.halt();\n this.glide = null;\n this.current = this.target = y;\n this.write(y);\n o.onComplete?.();\n return;\n }\n this.target = y;\n this.glide = { from: this.current, to: y, t: 0, d: o.duration ?? this.o.duration ?? Math.min(1200, 400 + Math.abs(y - this.current) * 0.4), ease: this.easeOf(o.ease ?? this.o.ease), done: o.onComplete };\n this.start();\n }\n /** Pause smoothing (native scrolling everywhere) — e.g. while a modal is open. */\n stop(): void {\n this.stopped = true;\n this.halt();\n this.el.classList.remove('usa-smooth');\n }\n /** Resume after `stop()`. */\n resume(): void {\n this.stopped = false;\n this.current = this.target = this.native;\n this.el.classList.toggle('usa-smooth', !this.reduced);\n }\n /** Listen to every smoothed frame; returns an unsubscribe function. */\n onScroll(fn: (s: SmoothScroll) => void): () => void {\n this.listeners.add(fn);\n return () => this.listeners.delete(fn);\n }\n /** Remove all listeners and restore native scrolling. */\n destroy(): void {\n this.halt();\n this.off.forEach((f) => f());\n this.off = [];\n this.listeners.clear();\n this.el.classList.remove('usa-smooth');\n instances.delete(this);\n }\n}\n\n/** Start smooth scrolling (see module docs). Off under reduced motion. */\nexport function smoothScroll(o: SmoothOptions = {}): SmoothScroll {\n return new SmoothScroll(o);\n}\n\n/** Every live instance. */\nexport const allSmooth = (): SmoothScroll[] => Array.from(instances);\n\nexport interface SmoothApi {\n smoothScroll: typeof smoothScroll;\n allSmooth: typeof allSmooth;\n SmoothScroll: typeof SmoothScroll;\n}\n\n/** The module object for `use(smooth)`. */\nexport const smooth: RuntimeModule<SmoothApi> = { id: 'smooth', version: RUNTIME_VERSION, requires: ['core'], api: { smoothScroll, allSmooth, SmoothScroll } };\n"],"names":["requireModule","parseEase","RUNTIME_VERSION"],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;AAkBG;AAmCH,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9E,MAAM,SAAS,GAAG,IAAI,GAAG,EAAgB;MAE5B,YAAY,CAAA;AAqBvB,IAAA,WAAA,CAAY,IAAmB,EAAE,EAAA;;QAnBjC,IAAA,CAAA,OAAO,GAAG,CAAC;;QAEX,IAAA,CAAA,MAAM,GAAG,CAAC;;QAEV,IAAA,CAAA,QAAQ,GAAG,CAAC;;QAEZ,IAAA,CAAA,WAAW,GAAG,KAAK;QAIX,IAAA,CAAA,OAAO,GAAG,KAAK;QACf,IAAA,CAAA,OAAO,GAAG,KAAK;QACf,IAAA,CAAA,GAAG,GAAmB,EAAE;QACxB,IAAA,CAAA,OAAO,GAAwB,IAAI;QACnC,IAAA,CAAA,OAAO,GAAG,GAAG;QACb,IAAA,CAAA,KAAK,GAA6F,IAAI;AACtG,QAAA,IAAA,CA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tB,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IACxC;;IAEA,OAAO,GAAA;QACL,IAAI,CAAC,IAAI,EAAE;AACX,QAAA,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;AAC5B,QAAA,IAAI,CAAC,GAAG,GAAG,EAAE;AACb,QAAA,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;QACtB,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC;AACtC,QAAA,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;IACxB;AACD;AAED;AACM,SAAU,YAAY,CAAC,CAAA,GAAmB,EAAE,EAAA;AAChD,IAAA,OAAO,IAAI,YAAY,CAAC,CAAC,CAAC;AAC5B;AAEA;AACO,MAAM,SAAS,GAAG,MAAsB,KAAK,CAAC,IAAI,CAAC,SAAS;AAQnE;AACO,MAAM,MAAM,GAA6B,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAEC,wBAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE;;;;;"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/** A runtime module: `{ id, version, api }`, registered with `use()`. */
|
|
2
|
+
interface RuntimeModule<A = unknown> {
|
|
3
|
+
/** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */
|
|
4
|
+
id: string;
|
|
5
|
+
version: string;
|
|
6
|
+
/** Other modules this one needs (registered first by `use()` callers). */
|
|
7
|
+
requires?: string[];
|
|
8
|
+
/** The module's public API (what `requireModule(id)` returns). */
|
|
9
|
+
api: A;
|
|
10
|
+
/** Optional one-time setup, called on first registration. */
|
|
11
|
+
setup?(registry: RuntimeRegistry): void;
|
|
12
|
+
}
|
|
13
|
+
interface RuntimeRegistry {
|
|
14
|
+
version: string;
|
|
15
|
+
modules: Map<string, RuntimeModule>;
|
|
16
|
+
/** Shared per-page state slots (the ticker lives here). */
|
|
17
|
+
slots: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Easing functions (t ∈ [0, 1] → progress). Original implementations of the standard Penner-style curves. */
|
|
21
|
+
type Ease = (t: number) => number;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* `motionary/runtime/smooth` (10.4) — smooth (inertial) scrolling on the
|
|
25
|
+
* runtime ticker, written for Motionary (own implementation and API).
|
|
26
|
+
*
|
|
27
|
+
* - Wheel / trackpad input is eased towards its target (`lerp` or a fixed
|
|
28
|
+
* `duration` + `ease`) on the shared ticker; keyboard, scrollbar dragging,
|
|
29
|
+
* find-in-page and screen-reader scrolling stay native (the target follows
|
|
30
|
+
* them), touch stays native by default (`touch: true` to smooth it).
|
|
31
|
+
* - Works on the window or inside any scrollable `wrapper`; vertical or
|
|
32
|
+
* horizontal; nested scrollables and `[data-smooth-ignore]` are left alone.
|
|
33
|
+
* - Anchor links (`#id`) glide to their target (with `offset`), focus moves
|
|
34
|
+
* for keyboard users, and the URL hash is kept.
|
|
35
|
+
* - **Off under `prefers-reduced-motion: reduce`** (and while the media query
|
|
36
|
+
* matches; it re-enables when it stops matching) — wheel scrolling is then
|
|
37
|
+
* fully native. `force: true` overrides this only for non-motion use cases.
|
|
38
|
+
* - Real `scroll` events still fire, so `motionary/runtime/scroll` scenes,
|
|
39
|
+
* IntersectionObservers and CSS scroll timelines all keep working.
|
|
40
|
+
* SSR-safe: nothing touches `window` until `smoothScroll()` is called.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
interface SmoothOptions {
|
|
44
|
+
/** Scroll container (default: the window / document scroller). */
|
|
45
|
+
wrapper?: HTMLElement | Window;
|
|
46
|
+
/** Easing factor per 60 fps frame, 0–1 (default 0.1). Ignored when `duration` is set. */
|
|
47
|
+
lerp?: number;
|
|
48
|
+
/** Fixed glide time in ms (with `ease`) instead of `lerp`. */
|
|
49
|
+
duration?: number;
|
|
50
|
+
ease?: string | Ease;
|
|
51
|
+
orientation?: 'vertical' | 'horizontal';
|
|
52
|
+
/** Wheel delta multiplier (default 1). */
|
|
53
|
+
wheelMultiplier?: number;
|
|
54
|
+
/** Smooth touch scrolling too (default false: native momentum is better on touch devices). */
|
|
55
|
+
touch?: boolean;
|
|
56
|
+
touchMultiplier?: number;
|
|
57
|
+
/** Glide to `#anchor` links (default true). */
|
|
58
|
+
anchors?: boolean | {
|
|
59
|
+
offset?: number;
|
|
60
|
+
};
|
|
61
|
+
/** Ignore prefers-reduced-motion (default false — leave it off unless the motion is essential). */
|
|
62
|
+
force?: boolean;
|
|
63
|
+
onScroll?: (s: SmoothScroll) => void;
|
|
64
|
+
}
|
|
65
|
+
interface ScrollToOptions2 {
|
|
66
|
+
offset?: number;
|
|
67
|
+
/** Jump without animating. */
|
|
68
|
+
immediate?: boolean;
|
|
69
|
+
duration?: number;
|
|
70
|
+
ease?: string | Ease;
|
|
71
|
+
onComplete?: () => void;
|
|
72
|
+
}
|
|
73
|
+
declare class SmoothScroll {
|
|
74
|
+
/** Current (animated) scroll position, px. */
|
|
75
|
+
current: number;
|
|
76
|
+
/** Where the scroll is heading, px. */
|
|
77
|
+
target: number;
|
|
78
|
+
/** px per frame of the last update. */
|
|
79
|
+
velocity: number;
|
|
80
|
+
/** True while gliding. */
|
|
81
|
+
isScrolling: boolean;
|
|
82
|
+
private o;
|
|
83
|
+
private el;
|
|
84
|
+
private win;
|
|
85
|
+
private stopped;
|
|
86
|
+
private reduced;
|
|
87
|
+
private off;
|
|
88
|
+
private tickOff;
|
|
89
|
+
private written;
|
|
90
|
+
private glide;
|
|
91
|
+
private listeners;
|
|
92
|
+
private touchY;
|
|
93
|
+
constructor(o?: SmoothOptions);
|
|
94
|
+
private on;
|
|
95
|
+
private get horizontal();
|
|
96
|
+
private axis;
|
|
97
|
+
/** The scroll position the browser reports. */
|
|
98
|
+
get native(): number;
|
|
99
|
+
/** Maximum scroll, px. */
|
|
100
|
+
get limit(): number;
|
|
101
|
+
/** 0–1 */
|
|
102
|
+
get progress(): number;
|
|
103
|
+
/** Smoothing is running (not stopped, not reduced motion). */
|
|
104
|
+
get active(): boolean;
|
|
105
|
+
private wheel;
|
|
106
|
+
private push;
|
|
107
|
+
private start;
|
|
108
|
+
private tick;
|
|
109
|
+
private easeOf;
|
|
110
|
+
private write;
|
|
111
|
+
private halt;
|
|
112
|
+
private anchor;
|
|
113
|
+
/** Scroll to a position (px), an element, or a selector. Animated unless reduced motion / `immediate`. */
|
|
114
|
+
scrollTo(to: number | string | Element, o?: ScrollToOptions2): void;
|
|
115
|
+
/** Pause smoothing (native scrolling everywhere) — e.g. while a modal is open. */
|
|
116
|
+
stop(): void;
|
|
117
|
+
/** Resume after `stop()`. */
|
|
118
|
+
resume(): void;
|
|
119
|
+
/** Listen to every smoothed frame; returns an unsubscribe function. */
|
|
120
|
+
onScroll(fn: (s: SmoothScroll) => void): () => void;
|
|
121
|
+
/** Remove all listeners and restore native scrolling. */
|
|
122
|
+
destroy(): void;
|
|
123
|
+
}
|
|
124
|
+
/** Start smooth scrolling (see module docs). Off under reduced motion. */
|
|
125
|
+
declare function smoothScroll(o?: SmoothOptions): SmoothScroll;
|
|
126
|
+
/** Every live instance. */
|
|
127
|
+
declare const allSmooth: () => SmoothScroll[];
|
|
128
|
+
interface SmoothApi {
|
|
129
|
+
smoothScroll: typeof smoothScroll;
|
|
130
|
+
allSmooth: typeof allSmooth;
|
|
131
|
+
SmoothScroll: typeof SmoothScroll;
|
|
132
|
+
}
|
|
133
|
+
/** The module object for `use(smooth)`. */
|
|
134
|
+
declare const smooth: RuntimeModule<SmoothApi>;
|
|
135
|
+
|
|
136
|
+
export { SmoothScroll, allSmooth, smooth, smoothScroll };
|
|
137
|
+
export type { ScrollToOptions2, SmoothApi, SmoothOptions };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/** A runtime module: `{ id, version, api }`, registered with `use()`. */
|
|
2
|
+
interface RuntimeModule<A = unknown> {
|
|
3
|
+
/** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */
|
|
4
|
+
id: string;
|
|
5
|
+
version: string;
|
|
6
|
+
/** Other modules this one needs (registered first by `use()` callers). */
|
|
7
|
+
requires?: string[];
|
|
8
|
+
/** The module's public API (what `requireModule(id)` returns). */
|
|
9
|
+
api: A;
|
|
10
|
+
/** Optional one-time setup, called on first registration. */
|
|
11
|
+
setup?(registry: RuntimeRegistry): void;
|
|
12
|
+
}
|
|
13
|
+
interface RuntimeRegistry {
|
|
14
|
+
version: string;
|
|
15
|
+
modules: Map<string, RuntimeModule>;
|
|
16
|
+
/** Shared per-page state slots (the ticker lives here). */
|
|
17
|
+
slots: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Easing functions (t ∈ [0, 1] → progress). Original implementations of the standard Penner-style curves. */
|
|
21
|
+
type Ease = (t: number) => number;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* `motionary/runtime/smooth` (10.4) — smooth (inertial) scrolling on the
|
|
25
|
+
* runtime ticker, written for Motionary (own implementation and API).
|
|
26
|
+
*
|
|
27
|
+
* - Wheel / trackpad input is eased towards its target (`lerp` or a fixed
|
|
28
|
+
* `duration` + `ease`) on the shared ticker; keyboard, scrollbar dragging,
|
|
29
|
+
* find-in-page and screen-reader scrolling stay native (the target follows
|
|
30
|
+
* them), touch stays native by default (`touch: true` to smooth it).
|
|
31
|
+
* - Works on the window or inside any scrollable `wrapper`; vertical or
|
|
32
|
+
* horizontal; nested scrollables and `[data-smooth-ignore]` are left alone.
|
|
33
|
+
* - Anchor links (`#id`) glide to their target (with `offset`), focus moves
|
|
34
|
+
* for keyboard users, and the URL hash is kept.
|
|
35
|
+
* - **Off under `prefers-reduced-motion: reduce`** (and while the media query
|
|
36
|
+
* matches; it re-enables when it stops matching) — wheel scrolling is then
|
|
37
|
+
* fully native. `force: true` overrides this only for non-motion use cases.
|
|
38
|
+
* - Real `scroll` events still fire, so `motionary/runtime/scroll` scenes,
|
|
39
|
+
* IntersectionObservers and CSS scroll timelines all keep working.
|
|
40
|
+
* SSR-safe: nothing touches `window` until `smoothScroll()` is called.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
interface SmoothOptions {
|
|
44
|
+
/** Scroll container (default: the window / document scroller). */
|
|
45
|
+
wrapper?: HTMLElement | Window;
|
|
46
|
+
/** Easing factor per 60 fps frame, 0–1 (default 0.1). Ignored when `duration` is set. */
|
|
47
|
+
lerp?: number;
|
|
48
|
+
/** Fixed glide time in ms (with `ease`) instead of `lerp`. */
|
|
49
|
+
duration?: number;
|
|
50
|
+
ease?: string | Ease;
|
|
51
|
+
orientation?: 'vertical' | 'horizontal';
|
|
52
|
+
/** Wheel delta multiplier (default 1). */
|
|
53
|
+
wheelMultiplier?: number;
|
|
54
|
+
/** Smooth touch scrolling too (default false: native momentum is better on touch devices). */
|
|
55
|
+
touch?: boolean;
|
|
56
|
+
touchMultiplier?: number;
|
|
57
|
+
/** Glide to `#anchor` links (default true). */
|
|
58
|
+
anchors?: boolean | {
|
|
59
|
+
offset?: number;
|
|
60
|
+
};
|
|
61
|
+
/** Ignore prefers-reduced-motion (default false — leave it off unless the motion is essential). */
|
|
62
|
+
force?: boolean;
|
|
63
|
+
onScroll?: (s: SmoothScroll) => void;
|
|
64
|
+
}
|
|
65
|
+
interface ScrollToOptions2 {
|
|
66
|
+
offset?: number;
|
|
67
|
+
/** Jump without animating. */
|
|
68
|
+
immediate?: boolean;
|
|
69
|
+
duration?: number;
|
|
70
|
+
ease?: string | Ease;
|
|
71
|
+
onComplete?: () => void;
|
|
72
|
+
}
|
|
73
|
+
declare class SmoothScroll {
|
|
74
|
+
/** Current (animated) scroll position, px. */
|
|
75
|
+
current: number;
|
|
76
|
+
/** Where the scroll is heading, px. */
|
|
77
|
+
target: number;
|
|
78
|
+
/** px per frame of the last update. */
|
|
79
|
+
velocity: number;
|
|
80
|
+
/** True while gliding. */
|
|
81
|
+
isScrolling: boolean;
|
|
82
|
+
private o;
|
|
83
|
+
private el;
|
|
84
|
+
private win;
|
|
85
|
+
private stopped;
|
|
86
|
+
private reduced;
|
|
87
|
+
private off;
|
|
88
|
+
private tickOff;
|
|
89
|
+
private written;
|
|
90
|
+
private glide;
|
|
91
|
+
private listeners;
|
|
92
|
+
private touchY;
|
|
93
|
+
constructor(o?: SmoothOptions);
|
|
94
|
+
private on;
|
|
95
|
+
private get horizontal();
|
|
96
|
+
private axis;
|
|
97
|
+
/** The scroll position the browser reports. */
|
|
98
|
+
get native(): number;
|
|
99
|
+
/** Maximum scroll, px. */
|
|
100
|
+
get limit(): number;
|
|
101
|
+
/** 0–1 */
|
|
102
|
+
get progress(): number;
|
|
103
|
+
/** Smoothing is running (not stopped, not reduced motion). */
|
|
104
|
+
get active(): boolean;
|
|
105
|
+
private wheel;
|
|
106
|
+
private push;
|
|
107
|
+
private start;
|
|
108
|
+
private tick;
|
|
109
|
+
private easeOf;
|
|
110
|
+
private write;
|
|
111
|
+
private halt;
|
|
112
|
+
private anchor;
|
|
113
|
+
/** Scroll to a position (px), an element, or a selector. Animated unless reduced motion / `immediate`. */
|
|
114
|
+
scrollTo(to: number | string | Element, o?: ScrollToOptions2): void;
|
|
115
|
+
/** Pause smoothing (native scrolling everywhere) — e.g. while a modal is open. */
|
|
116
|
+
stop(): void;
|
|
117
|
+
/** Resume after `stop()`. */
|
|
118
|
+
resume(): void;
|
|
119
|
+
/** Listen to every smoothed frame; returns an unsubscribe function. */
|
|
120
|
+
onScroll(fn: (s: SmoothScroll) => void): () => void;
|
|
121
|
+
/** Remove all listeners and restore native scrolling. */
|
|
122
|
+
destroy(): void;
|
|
123
|
+
}
|
|
124
|
+
/** Start smooth scrolling (see module docs). Off under reduced motion. */
|
|
125
|
+
declare function smoothScroll(o?: SmoothOptions): SmoothScroll;
|
|
126
|
+
/** Every live instance. */
|
|
127
|
+
declare const allSmooth: () => SmoothScroll[];
|
|
128
|
+
interface SmoothApi {
|
|
129
|
+
smoothScroll: typeof smoothScroll;
|
|
130
|
+
allSmooth: typeof allSmooth;
|
|
131
|
+
SmoothScroll: typeof SmoothScroll;
|
|
132
|
+
}
|
|
133
|
+
/** The module object for `use(smooth)`. */
|
|
134
|
+
declare const smooth: RuntimeModule<SmoothApi>;
|
|
135
|
+
|
|
136
|
+
export { SmoothScroll, allSmooth, smooth, smoothScroll };
|
|
137
|
+
export type { ScrollToOptions2, SmoothApi, SmoothOptions };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(t,e,i){"use strict";const s=(t,e,i)=>Math.min(i,Math.max(e,t)),h=new Set;class o{constructor(t={}){if(this.current=0,this.target=0,this.velocity=0,this.isScrolling=!1,this.stopped=!1,this.reduced=!1,this.off=[],this.tickOff=null,this.written=NaN,this.glide=null,this.listeners=new Set,this.touchY=0,"undefined"==typeof window)throw new Error("[motionary] smoothScroll() needs a browser (call it on the client)");this.o=t;const e=t.wrapper||window;this.win=e===window,this.el=this.win?document.scrollingElement||document.documentElement:e,t.onScroll&&this.listeners.add(t.onScroll),this.current=this.target=this.native;const i="function"==typeof matchMedia?matchMedia("(prefers-reduced-motion: reduce)"):null,s=()=>{this.reduced=!!i?.matches&&!t.force,this.el.classList.toggle("usa-smooth",!this.reduced&&!this.stopped)};s(),i&&this.on(i,"change",s);const o=this.win?window:this.el;this.on(o,"wheel",t=>this.wheel(t),{passive:!1}),t.touch&&(this.on(o,"touchstart",t=>this.touchY=this.axis(t.touches[0].clientX,t.touches[0].clientY),{passive:!0}),this.on(o,"touchmove",e=>{if(!this.active||1!==e.touches.length)return;const i=this.axis(e.touches[0].clientX,e.touches[0].clientY);e.preventDefault(),this.push((this.touchY-i)*(t.touchMultiplier??1.5)),this.touchY=i},{passive:!1})),this.on(o,"scroll",()=>{Math.abs(this.native-this.written)<=1||(this.halt(),this.glide=null,this.current=this.target=this.native)},{passive:!0}),!1!==t.anchors&&this.on(this.win?document:this.el,"click",t=>this.anchor(t)),h.add(this)}on(t,e,i,s){t.addEventListener(e,i,s),this.off.push(()=>t.removeEventListener(e,i,s))}get horizontal(){return"horizontal"===this.o.orientation}axis(t,e){return this.horizontal?t:e}get native(){return this.horizontal?this.el.scrollLeft:this.el.scrollTop}get limit(){return this.horizontal?this.el.scrollWidth-this.el.clientWidth:this.el.scrollHeight-this.el.clientHeight}get progress(){return this.limit?this.current/this.limit:0}get active(){return!this.stopped&&!this.reduced}wheel(t){if(!this.active||t.ctrlKey)return;for(let e=t.target;e&&e!==this.el;e=e.parentElement){if(e.hasAttribute?.("data-smooth-ignore"))return;if(e!==document.body&&e.scrollHeight>e.clientHeight+1&&/(auto|scroll)/.test(getComputedStyle(e).overflowY))return}const e=1===t.deltaMode?40:2===t.deltaMode?this.horizontal?this.el.clientWidth:this.el.clientHeight:1,i=(this.horizontal&&t.deltaX||t.deltaY)*e*(this.o.wheelMultiplier??1);s(this.target+i,0,this.limit)===this.target&&(this.target<=0||this.target>=this.limit)||(t.preventDefault(),this.push(i))}push(t){this.glide=null,this.target=s(this.target+t,0,this.limit),this.start()}start(){this.tickOff||(this.isScrolling=!0,this.tickOff=e.requireModule("core","motionary/runtime/smooth").getTicker().add((t,e)=>this.tick(e)))}tick(t){const e=this.current;if(this.glide){const e=this.glide;e.t=Math.min(e.d,e.t+t),this.current=e.from+(e.to-e.from)*e.ease(e.d?e.t/e.d:1),e.t>=e.d&&(this.current=this.target=e.to,this.glide=null,e.done?.())}else{if(this.o.duration)return this.glide={from:this.current,to:this.target,t:0,d:this.o.duration,ease:this.easeOf(this.o.ease)},this.tick(t);{const e=1-Math.pow(1-s(this.o.lerp??.1,.001,1),t/(1e3/60));this.current+=(this.target-this.current)*e,Math.abs(this.target-this.current)<.5&&(this.current=this.target)}}this.velocity=this.current-e,this.write(this.current),this.listeners.forEach(t=>t(this)),this.current!==this.target||this.glide||this.halt()}easeOf(t){return"function"==typeof t?t:i.parseEase(t||"expo-out")}write(t){const e=Math.round(100*t)/100;Math.abs(this.native-e)<.5||(this.horizontal?this.el.scrollLeft=e:this.el.scrollTop=e,this.written=this.native)}halt(){this.tickOff?.(),this.tickOff=null,this.isScrolling=!1,this.velocity=0}anchor(t){if(t.defaultPrevented||t.button||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;const e=t.target.closest?.('a[href*="#"]');if(!e||"_blank"===e.target)return;const i=new URL(e.href,location.href);if(i.origin!==location.origin||i.pathname!==location.pathname||!i.hash)return;const s=decodeURIComponent(i.hash.slice(1)),h="top"===s?null:document.getElementById(s);if("top"!==s&&!h)return;if(!this.win&&h&&!this.el.contains(h))return;t.preventDefault();const o="object"==typeof this.o.anchors&&this.o.anchors.offset||0;this.scrollTo(h||0,{offset:o,onComplete:()=>{h&&(h.hasAttribute("tabindex")||/^(a|button|input|select|textarea)$/i.test(h.tagName)||h.setAttribute("tabindex","-1"),h.focus({preventScroll:!0}))}}),history.pushState&&history.pushState(null,"",i.hash)}scrollTo(t,e={}){let i;if("number"==typeof t)i=t;else{const e="string"==typeof t?document.querySelector(t):t;if(!e)return;const s=e.getBoundingClientRect(),h=this.win?0:this.axis(this.el.getBoundingClientRect().left,this.el.getBoundingClientRect().top);i=this.native+this.axis(s.left,s.top)-h}if(i=s(i+(e.offset||0),0,this.limit),e.immediate||!this.active)return this.halt(),this.glide=null,this.current=this.target=i,this.write(i),void e.onComplete?.();this.target=i,this.glide={from:this.current,to:i,t:0,d:e.duration??this.o.duration??Math.min(1200,400+.4*Math.abs(i-this.current)),ease:this.easeOf(e.ease??this.o.ease),done:e.onComplete},this.start()}stop(){this.stopped=!0,this.halt(),this.el.classList.remove("usa-smooth")}resume(){this.stopped=!1,this.current=this.target=this.native,this.el.classList.toggle("usa-smooth",!this.reduced)}onScroll(t){return this.listeners.add(t),()=>this.listeners.delete(t)}destroy(){this.halt(),this.off.forEach(t=>t()),this.off=[],this.listeners.clear(),this.el.classList.remove("usa-smooth"),h.delete(this)}}function r(t={}){return new o(t)}const n=()=>Array.from(h),l={id:"smooth",version:e.RUNTIME_VERSION,requires:["core"],api:{smoothScroll:r,allSmooth:n,SmoothScroll:o}};e.register(l),t.SmoothScroll=o,t.allSmooth=n,t.smooth=l,t.smoothScroll=r}(this.MotionaryRuntime=this.MotionaryRuntime||{},MotionaryRuntime,MotionaryRuntime);
|
|
2
|
+
//# sourceMappingURL=smooth.iife.js.map
|