@rethink-js/rt-smooth-scroll 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,7 +17,7 @@
17
17
  - Per-instance configuration via HTML attributes
18
18
  - Console logs showing each instance’s final resolved config
19
19
 
20
- **Lenis GitHub:** https://github.com/studio-freight/lenis :contentReference[oaicite:0]{index=0}
20
+ **Lenis GitHub:** https://github.com/studio-freight/lenis
21
21
 
22
22
  ---
23
23
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @rethink-js/rt-smooth-scroll v1.0.1 | MIT */
1
+ /*! @rethink-js/rt-smooth-scroll v1.0.2 | MIT */
2
2
  (() => {
3
3
  // src/index.js
4
4
  (function() {
package/dist/index.min.js CHANGED
@@ -1,3 +1,3 @@
1
- /*! @rethink-js/rt-smooth-scroll v1.0.1 | MIT */
1
+ /*! @rethink-js/rt-smooth-scroll v1.0.2 | MIT */
2
2
  (()=>{(function(){var p="rtSmoothScroll";if(window[p]&&window[p].__initialized)return;function O(o,n){return!o||!o.hasAttribute(n)?null:o.getAttribute(n)}function z(o){var n=document.documentElement,t=document.body,e=O(n,o);return e!==null||(e=O(t,o),e!==null)?e:null}function q(o){var n=document.documentElement,t=document.body;return!!(n&&n.hasAttribute(o)||t&&t.hasAttribute(o))}function g(o,n){if(o==null)return n;var t=String(o).trim().toLowerCase();return t===""||t==="true"||t==="1"||t==="yes"||t==="y"||t==="on"?!0:t==="false"||t==="0"||t==="no"||t==="n"||t==="off"?!1:n}function y(o,n){if(o==null)return n;var t=Number(o);return Number.isFinite(t)?t:n}function A(o,n){if(o==null)return n;var t=String(o);return t.length?t:n}function m(o){return o<0?0:o>1?1:o}function j(o){var n=String(o||"").trim();if(!n)return null;var t={linear:function(e){return m(e)},easeInQuad:function(e){return e=m(e),e*e},easeOutQuad:function(e){return e=m(e),e*(2-e)},easeInOutQuad:function(e){return e=m(e),e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2},easeInCubic:function(e){return e=m(e),e*e*e},easeOutCubic:function(e){return e=m(e),1-Math.pow(1-e,3)},easeInOutCubic:function(e){return e=m(e),e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2},easeInOutSine:function(e){return e=m(e),-(Math.cos(Math.PI*e)-1)/2},easeOutExpo:function(e){return e=m(e),e===1?1:1-Math.pow(2,-10*e)}};return t[n]||null}function x(o){if(!o)return!1;for(var n=0;n<o.attributes.length;n++){var t=o.attributes[n].name;if(t&&t.indexOf("rt-smooth-scroll-")===0)return!0}return!1}function P(){var o=document.body,n=document.documentElement;if(o){var t=document.querySelectorAll("[rt-smooth-scroll-instance]"),e=t&&t.length>0;!q("rt-smooth-scroll")&&!e&&o.setAttribute("rt-smooth-scroll","");var f=x(n)||x(o);if(!(f||e)){var h={"rt-smooth-scroll-lerp":"0.25","rt-smooth-scroll-orientation":"vertical","rt-smooth-scroll-gesture-orientation":"vertical","rt-smooth-scroll-normalize-wheel":"true","rt-smooth-scroll-wheel-multiplier":"1","rt-smooth-scroll-easing":"easeOutCubic","rt-smooth-scroll-smooth-touch":"true","rt-smooth-scroll-sync-touch":"true","rt-smooth-scroll-sync-touch-lerp":"0","rt-smooth-scroll-touch-inertia-multiplier":"10","rt-smooth-scroll-touch-multiplier":"2"};for(var v in h)!n.hasAttribute(v)&&!o.hasAttribute(v)&&o.setAttribute(v,h[v])}}}function E(o){var n="rt-smooth-scroll-";function t(w){var S=o(w);return S!=null?S:z(w)}var e=t(n+"duration"),f=t(n+"lerp"),h=e!=null&&String(e).trim()!=="",v=f!=null&&String(f).trim()!=="",s=y(e,1.15),b=y(f,.25);h&&!v&&(b=0);var I=A(t(n+"orientation"),"vertical"),T=A(t(n+"gesture-orientation"),"vertical"),C=g(t(n+"normalize-wheel"),!0),_=y(t(n+"wheel-multiplier"),1),L=g(t(n+"smooth-touch"),!0),F=g(t(n+"sync-touch"),!0),N=y(t(n+"sync-touch-lerp"),0),R=y(t(n+"touch-inertia-multiplier"),10),i=y(t(n+"touch-multiplier"),2),r=g(t(n+"infinite"),!1),u=A(t(n+"easing"),"easeOutCubic"),a=j(u),c={lerp:b,orientation:I,gestureOrientation:T,normalizeWheel:C,wheelMultiplier:_,smoothTouch:L,syncTouch:F,syncTouchLerp:N,touchInertiaMultiplier:R,touchMultiplier:i,infinite:r};b===0&&(c.duration=s),a&&(c.easing=a);var l=t(n+"options-json");if(l)try{var d=JSON.parse(l);if(d&&typeof d=="object")for(var M in d)c[M]=d[M]}catch(w){}return c}function Q(o){return new Promise(function(n,t){if(typeof window.Lenis!="undefined")return n();var e=document.querySelector('script[data-rt-lenis="true"]');if(e){e.addEventListener("load",function(){n()}),e.addEventListener("error",function(h){t(h)});return}var f=document.createElement("script");f.src=o,f.async=!0,f.dataset.rtLenis="true",f.onload=function(){n()},f.onerror=function(h){t(h)},document.head.appendChild(f)})}function D(){P();var o=q("rt-smooth-scroll"),n=document.querySelectorAll("[rt-smooth-scroll-instance]"),t=o||n&&n.length>0;if(!t)return;var e=A(z("rt-smooth-scroll-lenis-src"),"https://cdn.jsdelivr.net/npm/lenis@1.3.16/dist/lenis.min.js"),f=g(z("rt-smooth-scroll-observe-resize"),!0),h=g(z("rt-smooth-scroll-observe-mutations"),!0),v=y(z("rt-smooth-scroll-resize-debounce-ms"),0),s={destroyed:!1,rafId:0,instances:{},order:[],observers:{},resizeTimers:{}};function b(i){var r=s.instances[i];if(!(!r||s.destroyed)){if(v>0){clearTimeout(s.resizeTimers[i]),s.resizeTimers[i]=setTimeout(function(){var u=s.instances[i];!u||s.destroyed||u.resize()},v);return}r.resize()}}function I(){function i(r){if(!s.destroyed){for(var u=0;u<s.order.length;u++){var a=s.order[u],c=s.instances[a];c&&c.raf(r)}s.rafId=requestAnimationFrame(i)}}s.rafId=requestAnimationFrame(i)}function T(i,r){if(!(!r||r===window)){var u=null,a=null;f&&typeof ResizeObserver!="undefined"&&(u=new ResizeObserver(function(){b(i)}),u.observe(r)),h&&typeof MutationObserver!="undefined"&&(a=new MutationObserver(function(){b(i)}),a.observe(r,{childList:!0,subtree:!0})),s.observers[i]={ro:u,mo:a}}}function C(i){var r=s.observers[i];r&&(r.ro&&r.ro.disconnect(),r.mo&&r.mo.disconnect(),delete s.observers[i])}function _(i){var r={};for(var u in i)if(Object.prototype.hasOwnProperty.call(i,u)){var a=i[u];typeof a=="function"?r[u]="[Function]":r[u]=a}return r}function L(i,r,u,a){var c=a||{};r&&(c.wrapper=r),u&&(c.content=u);var l=new window.Lenis(c);s.instances[i]=l,s.order.push(i),r&&r!==window&&T(i,r),i==="root"&&(window.lenis=l);try{console.log("[rt-smooth-scroll] instance:",i,{wrapper:r===window?"window":r,content:u||null,options:_(c)})}catch(d){}return l}function F(i){var r=O(i,"rt-smooth-scroll-content");if(r){var u=i.querySelector(r);if(u)return u}return i.firstElementChild||i}function N(){function i(r,u){if(typeof r=="string"&&r.length){var a=s.instances[r];a&&u(r,a);return}for(var c=0;c<s.order.length;c++){var l=s.order[c],d=s.instances[l];d&&u(l,d)}}return{__initialized:!0,ids:function(){return s.order.slice()},get:function(r){return s.instances[r]||null},start:function(r){i(r,function(u,a){a.start()})},stop:function(r){i(r,function(u,a){a.stop()})},toggle:function(r,u){i(r,function(a,c){if(typeof u=="boolean"){u?c.stop():c.start();return}c.isStopped?c.start():c.stop()})},resize:function(r){i(r,function(u){b(u)})},destroy:function(r){if(s.destroyed)return;function u(a){clearTimeout(s.resizeTimers[a]),C(a);var c=s.instances[a];if(c){try{c.destroy()}catch(d){}delete s.instances[a]}var l=s.order.indexOf(a);if(l>=0&&s.order.splice(l,1),a==="root")try{delete window.lenis}catch(d){window.lenis=void 0}}if(typeof r=="string"&&r.length){u(r);return}for(;s.order.length;)u(s.order[0]);s.destroyed=!0,s.rafId&&cancelAnimationFrame(s.rafId)}}}function R(i){window.disableScroll=function(){i.stop(),document.body&&document.body.classList.add("no-scroll")},window.enableScroll=function(){i.start(),document.body&&document.body.classList.remove("no-scroll")}}Q(e).then(function(){if(!s.destroyed){if(o&&!s.instances.root){var i=E(function(){return null});L("root",window,document.documentElement,i)}for(var r=document.querySelectorAll("[rt-smooth-scroll-instance]"),u=0,a=0;a<r.length;a++){var c=r[a],l=O(c,"rt-smooth-scroll-id");if(l||(u++,l="instance-"+u),!s.instances[l]){var d=F(c),M=E(function(S){return O(c,S)});L(l,c,d,M)}}I();var w=N();window[p]=w,R(w),window.addEventListener("resize",function(){w.resize()})}}).catch(function(){})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",D):D(),window[p]=window[p]||{__initialized:!0,ids:function(){return[]},get:function(){return null}}})();})();
3
3
  //# sourceMappingURL=index.min.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rethink-js/rt-smooth-scroll",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Lightweight smooth scrolling powered by Lenis with automatic loading, attribute config, and multi-instance support.",
5
5
  "keywords": [
6
6
  "smooth-scroll",