UNPKG

@frsource/tiny-carousel-plugin-scroll-snap-fallback

Version:

Add CSS Scroll Snap fallback polyfill to your @frsource/tiny-carousel 🧩

3 lines (2 loc) • 744 B
import{on as o}from"@frsource/tiny-carousel-utils";var t=function(t,e){void 0===e.scrollTimeout&&(e.scrollTimeout=45);var l=void 0,i=void 0,r=2;function s(o,e){i=void 0;var l,s=t.carouselElement.scrollLeft,n=[].concat(t.config.items),c=o>s?-1:0,u=0;do{u+=l=n.shift().offsetWidth}while(n.length&&u+l<s);r=2,e.target.scrollLeft=u+c*l}o(t.carouselElement,"scroll",function(o){--r||(i=i||o.target.scrollLeft,clearTimeout(l),l=setTimeout(s.bind(t,i),e.scrollTimeout,o))},{passive:!0})},e={install:function(o,e){void 0===e&&(e={}),!e.force&&("undefined"!=typeof CSS&&null!=CSS.supports&&CSS.supports("scroll-snap-align","start")||"undefined"!=typeof InstallTrigger)||t(o,e)}};export{e as pluginScrollSnapFallback}; //# sourceMappingURL=index.mjs.map