UNPKG

swipescroll

Version:

Touch & drag horizontal scroll for carousels on mobile, laptops and desktops

3 lines (2 loc) 926 B
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).DriftScroll={})}(this,function(e){"use strict";function t(e){if(e){r(),window.addEventListener("resize",r);var t=0,o=0,i=function(i){t=i.touches[0].pageX,o=e.scrollLeft},n=function(i){var n=1.5*(i.touches[0].pageX-t);e.scrollLeft=o-n,i.preventDefault()};return e.addEventListener("touchstart",i,{passive:!1}),e.addEventListener("touchmove",n,{passive:!1}),function(){window.removeEventListener("resize",r),e.removeEventListener("touchstart",i),e.removeEventListener("touchmove",n)}}function r(){console.log("Visible width:",e.clientWidth,"Total width:",e.scrollWidth)}}"undefined"==typeof window||window.DriftScroll||(window.DriftScroll={initCarouselScroll:t}),e.initCarouselScroll=t}); //# sourceMappingURL=driftscroll.umd.js.map