diff --git a/bundled/lenis.js b/bundled/lenis.js index 856d8008..6736799c 100644 --- a/bundled/lenis.js +++ b/bundled/lenis.js @@ -1,2 +1,2 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t||self).Lenis=e()}(this,function(){function t(t,e){for(var i=0;i1,hasPointer:!!window.navigator.msPointerEnabled,hasKeyDown:"onkeydown"in document,isFirefox:navigator.userAgent.indexOf("Firefox")>-1}),i(this,l)[l]=Object.assign({mouseMultiplier:1,touchMultiplier:2,firefoxMultiplier:15,keyStep:120,preventTouch:!1,unpreventTouchClass:"vs-touchmove-allowed",useKeyboard:!0,useTouch:!0},t),i(this,a)[a]=new n,i(this,c)[c]={y:0,x:0,deltaX:0,deltaY:0},i(this,u)[u]={x:null,y:null},i(this,d)[d]=null,void 0!==i(this,l)[l].passive&&(this.listenerOptions={passive:i(this,l)[l].passive})}var e=t.prototype;return e._notify=function(t){var e=i(this,c)[c];e.x+=e.deltaX,e.y+=e.deltaY,i(this,a)[a].emit(s,{x:e.x,y:e.y,deltaX:e.deltaX,deltaY:e.deltaY,originalEvent:t})},e._bind=function(){r.hasWheelEvent&&i(this,h)[h].addEventListener("wheel",this._onWheel,this.listenerOptions),r.hasMouseWheelEvent&&i(this,h)[h].addEventListener("mousewheel",this._onMouseWheel,this.listenerOptions),r.hasTouch&&i(this,l)[l].useTouch&&(i(this,h)[h].addEventListener("touchstart",this._onTouchStart,this.listenerOptions),i(this,h)[h].addEventListener("touchmove",this._onTouchMove,this.listenerOptions)),r.hasPointer&&r.hasTouchWin&&(i(this,d)[d]=document.body.style.msTouchAction,document.body.style.msTouchAction="none",i(this,h)[h].addEventListener("MSPointerDown",this._onTouchStart,!0),i(this,h)[h].addEventListener("MSPointerMove",this._onTouchMove,!0)),r.hasKeyDown&&i(this,l)[l].useKeyboard&&document.addEventListener("keydown",this._onKeyDown)},e._unbind=function(){r.hasWheelEvent&&i(this,h)[h].removeEventListener("wheel",this._onWheel),r.hasMouseWheelEvent&&i(this,h)[h].removeEventListener("mousewheel",this._onMouseWheel),r.hasTouch&&(i(this,h)[h].removeEventListener("touchstart",this._onTouchStart),i(this,h)[h].removeEventListener("touchmove",this._onTouchMove)),r.hasPointer&&r.hasTouchWin&&(document.body.style.msTouchAction=i(this,d)[d],i(this,h)[h].removeEventListener("MSPointerDown",this._onTouchStart,!0),i(this,h)[h].removeEventListener("MSPointerMove",this._onTouchMove,!0)),r.hasKeyDown&&i(this,l)[l].useKeyboard&&document.removeEventListener("keydown",this._onKeyDown)},e.on=function(t,e){i(this,a)[a].on(s,t,e);var o=i(this,a)[a].e;o&&o[s]&&1===o[s].length&&this._bind()},e.off=function(t,e){i(this,a)[a].off(s,t,e);var o=i(this,a)[a].e;(!o[s]||o[s].length<=0)&&this._unbind()},e.destroy=function(){i(this,a)[a].off(),this._unbind()},t}()}()}(e),e.exports}();function l(t,e){var i=t%e;return i<0&&(i+=e),i}var h=["duration","easing"],a=/*#__PURE__*/function(){function t(){}var o=t.prototype;return o.to=function(t,e){var o=this,n=void 0===e?{}:e,r=n.duration,s=void 0===r?1:r,l=n.easing,a=void 0===l?function(t){return t}:l,c=function(t,e){if(null==t)return{};var i,o,n={},r=Object.keys(t);for(o=0;o=0||(n[i]=t[i]);return n}(n,h);this.target=t,this.fromKeys=i({},c),this.toKeys=i({},c),this.keys=Object.keys(i({},c)),this.keys.forEach(function(e){o.fromKeys[e]=t[e]}),this.duration=s,this.easing=a,this.currentTime=0,this.isRunning=!0},o.stop=function(){this.isRunning=!1},o.raf=function(t){var e=this;if(this.isRunning){this.currentTime=Math.min(this.currentTime+t,this.duration);var i=this.easing(this.progress);this.keys.forEach(function(t){var o=e.fromKeys[t];e.target[t]=o+(e.toKeys[t]-o)*i}),1===i&&this.stop()}},e(t,[{key:"progress",get:function(){return this.currentTime/this.duration}}]),t}();/*#__PURE__*/ -return function(t){var i,n;function r(e){var i,o,n,r,l=void 0===e?{}:e,h=l.duration,c=void 0===h?1.2:h,u=l.easing,d=void 0===u?function(t){return Math.min(1,1.001-Math.pow(2,-10*t))}:u,p=l.smooth,f=void 0===p||p,v=l.mouseMultiplier,w=void 0===v?1:v,y=l.smoothTouch,g=void 0!==y&&y,m=l.touchMultiplier,b=void 0===m?2:m,T=l.direction,M=void 0===T?"vertical":T,S=l.gestureDirection,_=void 0===S?"vertical":S,O=l.infinite,E=void 0!==O&&O,W=l.wrapper,x=void 0===W?window:W,P=l.content,D=void 0===P?document.body:P;(r=t.call(this)||this).onWindowResize=function(){r.wrapperWidth=window.innerWidth,r.wrapperHeight=window.innerHeight},r.onWrapperResize=function(t){var e=t[0];if(e){var i=e.contentRect;r.wrapperWidth=i.width,r.wrapperHeight=i.height}},r.onContentResize=function(t){var e=t[0];if(e){var i=e.contentRect;r.contentWidth=i.width,r.contentHeight=i.height}},r.onVirtualScroll=function(t){var e=t.deltaY,i=t.deltaX,o=t.originalEvent,n=!!o.composedPath().find(function(t){return t.hasAttribute&&t.hasAttribute("data-lenis-prevent")});o.ctrlKey||n||(r.smooth=o.changedTouches?r.smoothTouch:r.options.smooth,r.stopped?o.preventDefault():r.smooth&&4!==o.buttons&&(r.smooth&&o.preventDefault(),r.targetScroll-="both"===r.gestureDirection?i+e:"horizontal"===r.gestureDirection?i:e,r.scrollTo(r.targetScroll)))},r.onScroll=function(t){r.isScrolling&&r.smooth||(r.targetScroll=r.scroll=r.lastScroll=r.wrapperNode[r.scrollProperty],r.notify())},window.lenisVersion="0.2.19",r.options={duration:c,easing:d,smooth:f,mouseMultiplier:w,smoothTouch:g,touchMultiplier:b,direction:M,gestureDirection:_,infinite:E,wrapper:x,content:D},r.duration=c,r.easing=d,r.smooth=f,r.mouseMultiplier=w,r.smoothTouch=g,r.touchMultiplier=b,r.direction=M,r.gestureDirection=_,r.infinite=E,r.wrapperNode=x,r.contentNode=D,r.wrapperNode.addEventListener("scroll",r.onScroll),r.wrapperNode===window?(r.wrapperNode.addEventListener("resize",r.onWindowResize),r.onWindowResize()):(r.wrapperHeight=r.wrapperNode.offsetHeight,r.wrapperWidth=r.wrapperNode.offsetWidth,r.wrapperObserver=new ResizeObserver(r.onWrapperResize),r.wrapperObserver.observe(r.wrapperNode)),r.contentHeight=r.contentNode.offsetHeight,r.contentWidth=r.contentNode.offsetWidth,r.contentObserver=new ResizeObserver(r.onContentResize),r.contentObserver.observe(r.contentNode),r.targetScroll=r.scroll=r.lastScroll=r.wrapperNode[r.scrollProperty],r.animate=new a;var k=(null==(i=navigator)||null==(o=i.userAgentData)?void 0:o.platform)||(null==(n=navigator)?void 0:n.platform)||"unknown";return r.virtualScroll=new s({el:r.wrapperNode,firefoxMultiplier:50,mouseMultiplier:r.mouseMultiplier*(k.includes("Win")?.84:.4),touchMultiplier:r.touchMultiplier,passive:!1}),r.virtualScroll.on(r.onVirtualScroll),r}n=t,(i=r).prototype=Object.create(n.prototype),i.prototype.constructor=i,o(i,n);var h=r.prototype;return h.start=function(){this.stopped=!1},h.stop=function(){this.stopped=!0,this.animate.stop()},h.destroy=function(){var t;this.wrapperNode===window&&this.wrapperNode.removeEventListener("resize",this.onWindowResize),this.wrapperNode.removeEventListener("scroll",this.onScroll),this.virtualScroll.destroy(),null==(t=this.wrapperObserver)||t.disconnect(),this.contentObserver.disconnect()},h.raf=function(t){var e=t-(this.now||0);this.now=t,!this.stopped&&this.smooth&&(this.lastScroll=this.scroll,this.animate.raf(.001*e),this.scroll===this.targetScroll&&(this.lastScroll=this.scroll),this.isScrolling&&(this.setScroll(this.scroll),this.notify()),this.isScrolling=this.scroll!==this.targetScroll)},h.setScroll=function(t){var e=this.infinite?l(t,this.limit):t;"horizontal"===this.direction?this.wrapperNode.scrollTo(e,0):this.wrapperNode.scrollTo(0,e)},h.notify=function(){var t=this.infinite?l(this.scroll,this.limit):this.scroll;this.emit("scroll",{scroll:t,limit:this.limit,velocity:this.velocity,direction:this.lastScroll number} EasingFunction - * @typedef {'vertical' | 'horizontal'} Direction - * @typedef {'vertical' | 'horizontal' | 'both'} GestureDirection - * - * @typedef LenisOptions - * @property {number} [duration] - * @property {EasingFunction} [easing] - * @property {boolean} [smooth] - * @property {number} [mouseMultiplier] - * @property {boolean} [smoothTouch] - * @property {number} [touchMultiplier] - * @property {Direction} [direction] - * @property {GestureDirection} [gestureDirection] - * @property {boolean} [infinite] - * @property {Window | HTMLElement} [wrapper] - * @property {HTMLElement} [content] - * - * @param {LenisOptions} - */ - constructor({ duration, easing, smooth, mouseMultiplier, smoothTouch, touchMultiplier, direction, gestureDirection, infinite, wrapper, content, }?: { - duration?: number; - easing?: (t: number) => number; - smooth?: boolean; - mouseMultiplier?: number; - smoothTouch?: boolean; - touchMultiplier?: number; - direction?: "vertical" | "horizontal"; - gestureDirection?: "vertical" | "horizontal" | "both"; - infinite?: boolean; - wrapper?: Window | HTMLElement; - content?: HTMLElement; - }); - options: { - duration: number; - easing: (t: number) => number; - smooth: boolean; - mouseMultiplier: number; - smoothTouch: boolean; - touchMultiplier: number; - direction: "vertical" | "horizontal"; - gestureDirection: "vertical" | "horizontal" | "both"; - infinite: boolean; - wrapper: Window | HTMLElement; - content: HTMLElement; - }; - duration: number; - easing: (t: number) => number; - smooth: boolean; - mouseMultiplier: number; - smoothTouch: boolean; - touchMultiplier: number; - direction: "vertical" | "horizontal"; - gestureDirection: "vertical" | "horizontal" | "both"; - infinite: boolean; - wrapperNode: Window | HTMLElement; - contentNode: HTMLElement; - wrapperHeight: any; - wrapperWidth: any; - wrapperObserver: ResizeObserver; - contentHeight: number; - contentWidth: number; - contentObserver: ResizeObserver; - targetScroll: any; - scroll: any; - lastScroll: any; - animate: Animate; - virtualScroll: any; - get scrollProperty(): string; - start(): void; - stopped: boolean; - stop(): void; - destroy(): void; - onWindowResize: () => void; - onWrapperResize: ([entry]: [any]) => void; - onContentResize: ([entry]: [any]) => void; - get limit(): number; - onVirtualScroll: ({ deltaY, deltaX, originalEvent: e }: { - deltaY: any; - deltaX: any; - originalEvent: any; - }) => void; - raf(now: any): void; - now: any; - isScrolling: boolean; - get velocity(): number; - setScroll(value: any): void; - onScroll: (e: any) => void; - notify(): void; - scrollTo(target: any, { offset, immediate, duration, easing, }?: { - offset?: number; - immediate?: boolean; - duration?: number; - easing?: (t: number) => number; - }): void; -} -declare class Animate { - to(target: any, { duration, easing, ...keys }?: { - duration?: number; - easing?: (t: any) => any; - }): void; - target: any; - fromKeys: {}; - toKeys: {}; - keys: string[]; - duration: number; - easing: (t: any) => any; - currentTime: any; - isRunning: boolean; - stop(): void; - raf(deltaTime: any): void; - get progress(): number; -} -export {}; +export default class Lenis { + constructor({ duration, easing, smooth, mouseMultiplier, smoothTouch, touchMultiplier, direction, gestureDirection, infinite, wrapper, content, }?: { + duration?: number; + easing?: (t: number) => number; + smooth?: boolean; + mouseMultiplier?: number; + smoothTouch?: boolean; + touchMultiplier?: number; + direction?: "vertical" | "horizontal"; + gestureDirection?: "both" | "vertical" | "horizontal"; + infinite?: boolean; + wrapper?: Window | HTMLElement; + content?: HTMLElement; + }); + options: { + duration: number; + easing: (t: number) => number; + smooth: boolean; + mouseMultiplier: number; + smoothTouch: boolean; + touchMultiplier: number; + direction: "vertical" | "horizontal"; + gestureDirection: "both" | "vertical" | "horizontal"; + infinite: boolean; + wrapper: HTMLElement | Window; + content: HTMLElement; + }; + duration: number; + easing: (t: number) => number; + smooth: boolean; + mouseMultiplier: number; + smoothTouch: boolean; + touchMultiplier: number; + direction: "vertical" | "horizontal"; + gestureDirection: "both" | "vertical" | "horizontal"; + infinite: boolean; + wrapperNode: HTMLElement | Window; + contentNode: HTMLElement; + wrapperHeight: any; + wrapperWidth: any; + wrapperObserver: ResizeObserver; + contentHeight: number; + contentWidth: number; + contentObserver: ResizeObserver; + targetScroll: any; + scroll: any; + lastScroll: any; + animate: Animate; + virtualScroll: any; + get scrollProperty(): string; + start(): void; + stopped: boolean; + stop(): void; + destroy(): void; + onWindowResize: () => void; + onWrapperResize: ([entry]: [any]) => void; + onContentResize: ([entry]: [any]) => void; + get limit(): number; + onVirtualScroll: ({ deltaY, deltaX, originalEvent: e }: { + deltaY: any; + deltaX: any; + originalEvent: any; + }) => void; + raf(now: any): void; + now: any; + isScrolling: boolean; + get velocity(): number; + setScroll(value: any): void; + onScroll: (e: any) => void; + notify(): void; + scrollTo(target: any, { offset, immediate, duration, easing, }?: { + offset?: number; + immediate?: boolean; + duration?: number; + easing?: (t: number) => number; + }): void; +} +declare class Animate { + to(target: any, { duration, easing, ...keys }?: { + duration?: number; + easing?: (t: any) => any; + }): void; + target: any; + fromKeys: {}; + toKeys: {}; + keys: string[]; + duration: number; + easing: (t: any) => any; + currentTime: any; + isRunning: boolean; + stop(): void; + raf(deltaTime: any): void; + get progress(): number; +} +export {}; diff --git a/dist/lenis.js b/dist/lenis.js index fc90485d..5a304731 100644 --- a/dist/lenis.js +++ b/dist/lenis.js @@ -1,2 +1,2 @@ -var t=require("tiny-emitter"),e=require("virtual-scroll");function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=/*#__PURE__*/i(t),r=/*#__PURE__*/i(e);function n(t,e){for(var i=0;i=0||(r[i]=t[i]);return r}(o,h);this.target=t,this.fromKeys=l({},a),this.toKeys=l({},a),this.keys=Object.keys(l({},a)),this.keys.forEach(function(e){i.fromKeys[e]=t[e]}),this.duration=n,this.easing=c,this.currentTime=0,this.isRunning=!0},e.stop=function(){this.isRunning=!1},e.raf=function(t){var e=this;if(this.isRunning){this.currentTime=Math.min(this.currentTime+t,this.duration);var i=this.easing(this.progress);this.keys.forEach(function(t){var o=e.fromKeys[t];e.target[t]=o+(e.toKeys[t]-o)*i}),1===i&&this.stop()}},s(t,[{key:"progress",get:function(){return this.currentTime/this.duration}}]),t}();module.exports=/*#__PURE__*/function(t){var e,i;function o(e){var i,o,n,s,l=void 0===e?{}:e,c=l.duration,a=void 0===c?1.2:c,h=l.easing,p=void 0===h?function(t){return Math.min(1,1.001-Math.pow(2,-10*t))}:h,d=l.smooth,f=void 0===d||d,v=l.mouseMultiplier,g=void 0===v?1:v,w=l.smoothTouch,m=void 0!==w&&w,y=l.touchMultiplier,b=void 0===y?2:y,S=l.direction,N=void 0===S?"vertical":S,O=l.gestureDirection,z=void 0===O?"vertical":O,R=l.infinite,W=void 0!==R&&R,M=l.wrapper,T=void 0===M?window:M,j=l.content,k=void 0===j?document.body:j;(s=t.call(this)||this).onWindowResize=function(){s.wrapperWidth=window.innerWidth,s.wrapperHeight=window.innerHeight},s.onWrapperResize=function(t){var e=t[0];if(e){var i=e.contentRect;s.wrapperWidth=i.width,s.wrapperHeight=i.height}},s.onContentResize=function(t){var e=t[0];if(e){var i=e.contentRect;s.contentWidth=i.width,s.contentHeight=i.height}},s.onVirtualScroll=function(t){var e=t.deltaY,i=t.deltaX,o=t.originalEvent,r=!!o.composedPath().find(function(t){return t.hasAttribute&&t.hasAttribute("data-lenis-prevent")});o.ctrlKey||r||(s.smooth=o.changedTouches?s.smoothTouch:s.options.smooth,s.stopped?o.preventDefault():s.smooth&&4!==o.buttons&&(s.smooth&&o.preventDefault(),s.targetScroll-="both"===s.gestureDirection?i+e:"horizontal"===s.gestureDirection?i:e,s.scrollTo(s.targetScroll)))},s.onScroll=function(t){s.isScrolling&&s.smooth||(s.targetScroll=s.scroll=s.lastScroll=s.wrapperNode[s.scrollProperty],s.notify())},window.lenisVersion="0.2.19",s.options={duration:a,easing:p,smooth:f,mouseMultiplier:g,smoothTouch:m,touchMultiplier:b,direction:N,gestureDirection:z,infinite:W,wrapper:T,content:k},s.duration=a,s.easing=p,s.smooth=f,s.mouseMultiplier=g,s.smoothTouch=m,s.touchMultiplier=b,s.direction=N,s.gestureDirection=z,s.infinite=W,s.wrapperNode=T,s.contentNode=k,s.wrapperNode.addEventListener("scroll",s.onScroll),s.wrapperNode===window?(s.wrapperNode.addEventListener("resize",s.onWindowResize),s.onWindowResize()):(s.wrapperHeight=s.wrapperNode.offsetHeight,s.wrapperWidth=s.wrapperNode.offsetWidth,s.wrapperObserver=new ResizeObserver(s.onWrapperResize),s.wrapperObserver.observe(s.wrapperNode)),s.contentHeight=s.contentNode.offsetHeight,s.contentWidth=s.contentNode.offsetWidth,s.contentObserver=new ResizeObserver(s.onContentResize),s.contentObserver.observe(s.contentNode),s.targetScroll=s.scroll=s.lastScroll=s.wrapperNode[s.scrollProperty],s.animate=new u;var H=(null==(i=navigator)||null==(o=i.userAgentData)?void 0:o.platform)||(null==(n=navigator)?void 0:n.platform)||"unknown";return s.virtualScroll=new r.default({el:s.wrapperNode,firefoxMultiplier:50,mouseMultiplier:s.mouseMultiplier*(H.includes("Win")?.84:.4),useKeyboard:!1,touchMultiplier:s.touchMultiplier,useTouch:!0,passive:!1}),s.virtualScroll.on(s.onVirtualScroll),s}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,c(e,i);var n=o.prototype;return n.start=function(){this.stopped=!1},n.stop=function(){this.stopped=!0,this.animate.stop()},n.destroy=function(){var t;this.wrapperNode===window&&this.wrapperNode.removeEventListener("resize",this.onWindowResize),this.wrapperNode.removeEventListener("scroll",this.onScroll),this.virtualScroll.destroy(),null==(t=this.wrapperObserver)||t.disconnect(),this.contentObserver.disconnect()},n.raf=function(t){var e=t-(this.now||0);this.now=t,!this.stopped&&this.smooth&&(this.lastScroll=this.scroll,this.animate.raf(.001*e),this.scroll===this.targetScroll&&(this.lastScroll=this.scroll),this.isScrolling&&(this.setScroll(this.scroll),this.notify()),this.isScrolling=this.scroll!==this.targetScroll)},n.setScroll=function(t){var e=this.infinite?a(t,this.limit):t;"horizontal"===this.direction?this.wrapperNode.scrollTo(e,0):this.wrapperNode.scrollTo(0,e)},n.notify=function(){var t=this.infinite?a(this.scroll,this.limit):this.scroll;this.emit("scroll",{scroll:t,limit:this.limit,velocity:this.velocity,direction:this.direction,progress:t/this.limit})},n.scrollTo=function(t,e){var i=void 0===e?{}:e,o=i.offset,r=void 0===o?0:o,n=i.immediate,s=void 0!==n&&n,l=i.duration,c=void 0===l?this.duration:l,a=i.easing,h=void 0===a?this.easing:a;if(null!=t){var u;if("number"==typeof t)u=t;else if("top"===t||"#top"===t)u=0;else if("bottom"===t)u=this.limit;else{var p;if("string"==typeof t)p=document.querySelector(t);else{if(null==t||!t.nodeType)return;p=t}if(!p)return;var d=0;if(this.wrapperNode!==window){var f=this.wrapperNode.getBoundingClientRect();d="horizontal"===this.direction?f.left:f.top}var v=p.getBoundingClientRect();u=("horizontal"===this.direction?v.left:v.top)+this.scroll-d}u+=r,this.targetScroll=this.infinite?u:Math.max(0,Math.min(u,this.limit)),!this.smooth||s?(this.scroll=this.lastScroll=this.targetScroll,this.setScroll(this.targetScroll)):this.animate.to(this,{duration:c,easing:h,scroll:this.targetScroll})}},s(o,[{key:"scrollProperty",get:function(){return this.wrapperNode===window?"horizontal"===this.direction?"scrollX":"scrollY":"horizontal"===this.direction?"scrollLeft":"scrollTop"}},{key:"limit",get:function(){return"horizontal"===this.direction?this.contentWidth-this.wrapperWidth:this.contentHeight-this.wrapperHeight}},{key:"velocity",get:function(){return this.scroll-this.lastScroll}}]),o}(o.default); +var t=require("tiny-emitter"),e=require("virtual-scroll");function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=/*#__PURE__*/i(t),r=/*#__PURE__*/i(e);function n(t,e){for(var i=0;i=0||(r[i]=t[i]);return r}(o,h);this.target=t,this.fromKeys=l({},c),this.toKeys=l({},c),this.keys=Object.keys(l({},c)),this.keys.forEach(function(e){i.fromKeys[e]=t[e]}),this.duration=n,this.easing=a,this.currentTime=0,this.isRunning=!0},e.stop=function(){this.isRunning=!1},e.raf=function(t){var e=this;if(this.isRunning){this.currentTime=Math.min(this.currentTime+t,this.duration);var i=this.easing(this.progress);this.keys.forEach(function(t){var o=e.fromKeys[t];e.target[t]=o+(e.toKeys[t]-o)*i}),1===i&&this.stop()}},s(t,[{key:"progress",get:function(){return this.currentTime/this.duration}}]),t}();module.exports=/*#__PURE__*/function(t){var e,i;function o(e){var i,o,n,s,l=void 0===e?{}:e,a=l.duration,c=void 0===a?1.2:a,h=l.easing,p=void 0===h?function(t){return Math.min(1,1.001-Math.pow(2,-10*t))}:h,d=l.smooth,f=void 0===d||d,v=l.mouseMultiplier,g=void 0===v?1:v,w=l.smoothTouch,m=void 0!==w&&w,y=l.touchMultiplier,b=void 0===y?2:y,S=l.direction,N=void 0===S?"vertical":S,O=l.gestureDirection,z=void 0===O?"vertical":O,R=l.infinite,W=void 0!==R&&R,M=l.wrapper,T=void 0===M?window:M,j=l.content,k=void 0===j?document.body:j;(s=t.call(this)||this).onWindowResize=function(){s.wrapperWidth=window.innerWidth,s.wrapperHeight=window.innerHeight},s.onWrapperResize=function(t){var e=t[0];if(e){var i=e.contentRect;s.wrapperWidth=i.width,s.wrapperHeight=i.height}},s.onContentResize=function(t){var e=t[0];if(e){var i=e.contentRect;s.contentWidth=i.width,s.contentHeight=i.height}},s.onVirtualScroll=function(t){var e=t.deltaY,i=t.deltaX,o=t.originalEvent,r=!!o.composedPath().find(function(t){return t.hasAttribute&&t.hasAttribute("data-lenis-prevent")});o.ctrlKey||r||(s.smooth=o.changedTouches?s.smoothTouch:s.options.smooth,s.stopped?o.preventDefault():s.smooth&&4!==o.buttons&&(s.smooth&&o.preventDefault(),s.targetScroll-="both"===s.gestureDirection?i+e:"horizontal"===s.gestureDirection?i:e,s.scrollTo(s.targetScroll)))},s.onScroll=function(t){s.isScrolling&&s.smooth||(s.targetScroll=s.scroll=s.lastScroll=s.wrapperNode[s.scrollProperty],s.notify())},window.lenisVersion="0.2.20",s.options={duration:c,easing:p,smooth:f,mouseMultiplier:g,smoothTouch:m,touchMultiplier:b,direction:N,gestureDirection:z,infinite:W,wrapper:T,content:k},s.duration=c,s.easing=p,s.smooth=f,s.mouseMultiplier=g,s.smoothTouch=m,s.touchMultiplier=b,s.direction=N,s.gestureDirection=z,s.infinite=W,s.wrapperNode=T,s.contentNode=k,s.wrapperNode.addEventListener("scroll",s.onScroll),s.wrapperNode===window?(s.wrapperNode.addEventListener("resize",s.onWindowResize),s.onWindowResize()):(s.wrapperHeight=s.wrapperNode.offsetHeight,s.wrapperWidth=s.wrapperNode.offsetWidth,s.wrapperObserver=new ResizeObserver(s.onWrapperResize),s.wrapperObserver.observe(s.wrapperNode)),s.contentHeight=s.contentNode.offsetHeight,s.contentWidth=s.contentNode.offsetWidth,s.contentObserver=new ResizeObserver(s.onContentResize),s.contentObserver.observe(s.contentNode),s.targetScroll=s.scroll=s.lastScroll=s.wrapperNode[s.scrollProperty],s.animate=new u;var H=(null==(i=navigator)||null==(o=i.userAgentData)?void 0:o.platform)||(null==(n=navigator)?void 0:n.platform)||"unknown";return s.virtualScroll=new r.default({el:s.wrapperNode,firefoxMultiplier:50,mouseMultiplier:s.mouseMultiplier*(H.includes("Win")?.84:.4),touchMultiplier:s.touchMultiplier,passive:!1}),s.virtualScroll.on(s.onVirtualScroll),s}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,a(e,i);var n=o.prototype;return n.start=function(){this.stopped=!1},n.stop=function(){this.stopped=!0,this.animate.stop()},n.destroy=function(){var t;this.wrapperNode===window&&this.wrapperNode.removeEventListener("resize",this.onWindowResize),this.wrapperNode.removeEventListener("scroll",this.onScroll),this.virtualScroll.destroy(),null==(t=this.wrapperObserver)||t.disconnect(),this.contentObserver.disconnect()},n.raf=function(t){var e=t-(this.now||0);this.now=t,!this.stopped&&this.smooth&&(this.lastScroll=this.scroll,this.animate.raf(.001*e),this.scroll===this.targetScroll&&(this.lastScroll=this.scroll),this.isScrolling&&(this.setScroll(this.scroll),this.notify()),this.isScrolling=this.scroll!==this.targetScroll)},n.setScroll=function(t){var e=this.infinite?c(t,this.limit):t;"horizontal"===this.direction?this.wrapperNode.scrollTo(e,0):this.wrapperNode.scrollTo(0,e)},n.notify=function(){var t=this.infinite?c(this.scroll,this.limit):this.scroll;this.emit("scroll",{scroll:t,limit:this.limit,velocity:this.velocity,direction:this.lastScroll t, ...keys } = {}) {\r\n this.target = target\r\n this.fromKeys = { ...keys }\r\n this.toKeys = { ...keys }\r\n this.keys = Object.keys({ ...keys })\r\n\r\n // get initial values\r\n this.keys.forEach((key) => {\r\n this.fromKeys[key] = target[key]\r\n })\r\n\r\n this.duration = duration\r\n this.easing = easing\r\n this.currentTime = 0\r\n this.isRunning = true\r\n }\r\n\r\n stop() {\r\n this.isRunning = false\r\n }\r\n\r\n raf(deltaTime) {\r\n if (!this.isRunning) return\r\n\r\n this.currentTime = Math.min(this.currentTime + deltaTime, this.duration)\r\n\r\n const progress = this.easing(this.progress)\r\n\r\n this.keys.forEach((key) => {\r\n const from = this.fromKeys[key]\r\n const to = this.toKeys[key]\r\n\r\n const value = from + (to - from) * progress\r\n\r\n this.target[key] = value\r\n })\r\n\r\n if (progress === 1) {\r\n this.stop()\r\n }\r\n }\r\n\r\n get progress() {\r\n return this.currentTime / this.duration\r\n }\r\n}\r\n\r\nexport default class Lenis extends EventEmitter {\r\n /**\r\n * @typedef {(t: number) => number} EasingFunction\r\n * @typedef {'vertical' | 'horizontal'} Direction\r\n * @typedef {'vertical' | 'horizontal' | 'both'} GestureDirection\r\n *\r\n * @typedef LenisOptions\r\n * @property {number} [duration]\r\n * @property {EasingFunction} [easing]\r\n * @property {boolean} [smooth]\r\n * @property {number} [mouseMultiplier]\r\n * @property {boolean} [smoothTouch]\r\n * @property {number} [touchMultiplier]\r\n * @property {Direction} [direction]\r\n * @property {GestureDirection} [gestureDirection]\r\n * @property {boolean} [infinite]\r\n * @property {Window | HTMLElement} [wrapper]\r\n * @property {HTMLElement} [content]\r\n *\r\n * @param {LenisOptions}\r\n */\r\n constructor({\r\n duration = 1.2,\r\n easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), // https://www.desmos.com/calculator/k2tgx2kn8t\r\n smooth = true,\r\n mouseMultiplier = 1,\r\n smoothTouch = false,\r\n touchMultiplier = 2,\r\n direction = 'vertical', // vertical, horizontal\r\n gestureDirection = 'vertical', // vertical, horizontal, both\r\n infinite = false,\r\n wrapper = window,\r\n content = document.body,\r\n } = {}) {\r\n super()\r\n\r\n window.lenisVersion = version\r\n\r\n this.options = {\r\n duration,\r\n easing,\r\n smooth,\r\n mouseMultiplier,\r\n smoothTouch,\r\n touchMultiplier,\r\n direction,\r\n gestureDirection,\r\n infinite,\r\n wrapper,\r\n content,\r\n }\r\n\r\n this.duration = duration\r\n this.easing = easing\r\n this.smooth = smooth\r\n this.mouseMultiplier = mouseMultiplier\r\n this.smoothTouch = smoothTouch\r\n this.touchMultiplier = touchMultiplier\r\n this.direction = direction\r\n this.gestureDirection = gestureDirection\r\n this.infinite = infinite\r\n this.wrapperNode = wrapper\r\n this.contentNode = content\r\n\r\n this.wrapperNode.addEventListener('scroll', this.onScroll)\r\n\r\n //observe wrapper node size\r\n if (this.wrapperNode === window) {\r\n this.wrapperNode.addEventListener('resize', this.onWindowResize)\r\n this.onWindowResize()\r\n } else {\r\n this.wrapperHeight = this.wrapperNode.offsetHeight\r\n this.wrapperWidth = this.wrapperNode.offsetWidth\r\n\r\n //observe wrapper node size\r\n this.wrapperObserver = new ResizeObserver(this.onWrapperResize)\r\n this.wrapperObserver.observe(this.wrapperNode)\r\n }\r\n\r\n this.contentHeight = this.contentNode.offsetHeight\r\n this.contentWidth = this.contentNode.offsetWidth\r\n\r\n //observe content node size\r\n this.contentObserver = new ResizeObserver(this.onContentResize)\r\n this.contentObserver.observe(this.contentNode)\r\n\r\n //set initial scroll position\r\n this.targetScroll =\r\n this.scroll =\r\n this.lastScroll =\r\n this.wrapperNode[this.scrollProperty]\r\n\r\n this.animate = new Animate()\r\n\r\n const platform =\r\n navigator?.userAgentData?.platform || navigator?.platform || 'unknown'\r\n\r\n // listen and normalize wheel event cross-browser\r\n this.virtualScroll = new VirtualScroll({\r\n el: this.wrapperNode,\r\n firefoxMultiplier: 50,\r\n mouseMultiplier:\r\n this.mouseMultiplier * (platform.includes('Win') ? 0.84 : 0.4),\r\n useKeyboard: false,\r\n touchMultiplier: this.touchMultiplier,\r\n useTouch: true,\r\n passive: false,\r\n })\r\n\r\n this.virtualScroll.on(this.onVirtualScroll)\r\n }\r\n\r\n get scrollProperty() {\r\n let property\r\n if (this.wrapperNode === window) {\r\n property = this.direction === 'horizontal' ? 'scrollX' : 'scrollY'\r\n } else {\r\n property = this.direction === 'horizontal' ? 'scrollLeft' : 'scrollTop'\r\n }\r\n return property\r\n }\r\n\r\n start() {\r\n this.stopped = false\r\n }\r\n\r\n stop() {\r\n this.stopped = true\r\n this.animate.stop()\r\n }\r\n\r\n destroy() {\r\n if (this.wrapperNode === window) {\r\n this.wrapperNode.removeEventListener('resize', this.onWindowResize)\r\n }\r\n this.wrapperNode.removeEventListener('scroll', this.onScroll)\r\n\r\n this.virtualScroll.destroy()\r\n this.wrapperObserver?.disconnect()\r\n this.contentObserver.disconnect()\r\n }\r\n\r\n onWindowResize = () => {\r\n this.wrapperWidth = window.innerWidth\r\n this.wrapperHeight = window.innerHeight\r\n }\r\n\r\n onWrapperResize = ([entry]) => {\r\n if (entry) {\r\n const rect = entry.contentRect\r\n this.wrapperWidth = rect.width\r\n this.wrapperHeight = rect.height\r\n }\r\n }\r\n\r\n onContentResize = ([entry]) => {\r\n if (entry) {\r\n const rect = entry.contentRect\r\n this.contentWidth = rect.width\r\n this.contentHeight = rect.height\r\n }\r\n }\r\n\r\n get limit() {\r\n return this.direction === 'horizontal'\r\n ? this.contentWidth - this.wrapperWidth\r\n : this.contentHeight - this.wrapperHeight\r\n }\r\n\r\n onVirtualScroll = ({ deltaY, deltaX, originalEvent: e }) => {\r\n const preventScroll = !!e\r\n .composedPath()\r\n .find(\r\n (node) => node.hasAttribute && node.hasAttribute('data-lenis-prevent')\r\n )\r\n\r\n if (e.ctrlKey || preventScroll) return\r\n\r\n // switch to smooth if event is touch and if smoothTouch=true\r\n this.smooth = !!e.changedTouches ? this.smoothTouch : this.options.smooth\r\n\r\n if (this.stopped) {\r\n e.preventDefault()\r\n return\r\n }\r\n\r\n if (!this.smooth) return\r\n\r\n // fix wheel holding scroll https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\r\n if (e.buttons === 4) return\r\n\r\n // prevent native wheel scrolling\r\n if (this.smooth) e.preventDefault()\r\n\r\n let delta = 0\r\n if (this.gestureDirection === 'both') {\r\n delta = deltaX + deltaY\r\n } else if (this.gestureDirection === 'horizontal') {\r\n delta = deltaX\r\n } else {\r\n // vertical\r\n delta = deltaY\r\n }\r\n\r\n this.targetScroll -= delta\r\n // this.targetScroll = clamp(0, this.targetScroll, this.limit)\r\n\r\n this.scrollTo(this.targetScroll)\r\n }\r\n\r\n raf(now) {\r\n const deltaTime = now - (this.now || 0)\r\n this.now = now\r\n\r\n if (this.stopped || !this.smooth) return\r\n\r\n this.lastScroll = this.scroll\r\n\r\n // where this.scroll is updated\r\n this.animate.raf(deltaTime * 0.001)\r\n\r\n if (this.scroll === this.targetScroll) {\r\n // if target reached velocity should be 0\r\n this.lastScroll = this.scroll\r\n }\r\n\r\n if (this.isScrolling) {\r\n this.setScroll(this.scroll)\r\n this.notify()\r\n }\r\n\r\n this.isScrolling = this.scroll !== this.targetScroll\r\n }\r\n\r\n get velocity() {\r\n return this.scroll - this.lastScroll\r\n }\r\n\r\n setScroll(value) {\r\n let scroll = this.infinite ? modulo(value, this.limit) : value\r\n\r\n this.direction === 'horizontal'\r\n ? this.wrapperNode.scrollTo(scroll, 0)\r\n : this.wrapperNode.scrollTo(0, scroll)\r\n }\r\n\r\n onScroll = (e) => {\r\n // if isScrolling false we can consider user isn't scrolling with wheel (cmd+F, keyboard or whatever). So we must scroll to value immediately\r\n if (!this.isScrolling || !this.smooth) {\r\n // where native scroll happens\r\n this.targetScroll =\r\n this.scroll =\r\n this.lastScroll =\r\n this.wrapperNode[this.scrollProperty]\r\n\r\n this.notify()\r\n }\r\n }\r\n\r\n notify() {\r\n let scroll = this.infinite ? modulo(this.scroll, this.limit) : this.scroll\r\n\r\n this.emit('scroll', {\r\n scroll,\r\n limit: this.limit,\r\n velocity: this.velocity,\r\n direction: this.direction,\r\n progress: scroll / this.limit,\r\n })\r\n }\r\n\r\n scrollTo(\r\n target,\r\n {\r\n offset = 0,\r\n immediate = false,\r\n duration = this.duration,\r\n easing = this.easing,\r\n } = {}\r\n ) {\r\n if (target === undefined || target === null) return\r\n let value\r\n\r\n if (typeof target === 'number') {\r\n value = target\r\n } else if (target === 'top' || target === '#top') {\r\n value = 0\r\n } else if (target === 'bottom') {\r\n value = this.limit\r\n } else {\r\n let node\r\n\r\n if (typeof target === 'string') {\r\n // CSS selector\r\n node = document.querySelector(target)\r\n } else if (target?.nodeType) {\r\n // Node element\r\n node = target\r\n } else {\r\n return\r\n }\r\n\r\n if (!node) return\r\n let wrapperOffset = 0\r\n\r\n if (this.wrapperNode !== window) {\r\n const wrapperRect = this.wrapperNode.getBoundingClientRect()\r\n wrapperOffset =\r\n this.direction === 'horizontal' ? wrapperRect.left : wrapperRect.top\r\n }\r\n\r\n const rect = node.getBoundingClientRect()\r\n\r\n value =\r\n (this.direction === 'horizontal' ? rect.left : rect.top) +\r\n this.scroll -\r\n wrapperOffset\r\n }\r\n\r\n value += offset\r\n\r\n if (this.infinite) {\r\n this.targetScroll = value\r\n } else {\r\n this.targetScroll = clamp(0, value, this.limit)\r\n }\r\n\r\n if (!this.smooth || immediate) {\r\n this.scroll = this.lastScroll = this.targetScroll\r\n this.setScroll(this.targetScroll)\r\n } else {\r\n this.animate.to(this, {\r\n duration,\r\n easing,\r\n scroll: this.targetScroll,\r\n })\r\n }\r\n }\r\n}\r\n"],"names":["modulo","value","max","v","to","Lenis","target","_this","this","_ref","_temp","duration","_ref$duration","easing","_ref$easing","t","keys","fromKeys","_extends","toKeys","Object","forEach","key","currentTime","isRunning","stop","raf","deltaTime","_this2","Math","min","progress","from","_temp2","_navigator","_navigator$userAgentD","_navigator2","_this3","_ref2","_ref2$duration","_ref2$easing","pow","_ref2$smooth","smooth","_ref2$mouseMultiplier","mouseMultiplier","_ref2$smoothTouch","smoothTouch","_ref2$touchMultiplier","touchMultiplier","_ref2$direction","direction","_ref2$gestureDirectio","gestureDirection","_ref2$infinite","infinite","_ref2$wrapper","wrapper","window","_ref2$content","content","document","body","_EventEmitter","call","onWindowResize","wrapperWidth","innerWidth","wrapperHeight","innerHeight","onWrapperResize","_ref3","entry","rect","contentRect","width","height","onContentResize","_ref4","contentWidth","contentHeight","onVirtualScroll","_ref5","deltaY","deltaX","e","originalEvent","preventScroll","composedPath","find","node","hasAttribute","ctrlKey","changedTouches","options","stopped","preventDefault","buttons","targetScroll","scrollTo","onScroll","isScrolling","scroll","lastScroll","wrapperNode","scrollProperty","notify","lenisVersion","contentNode","addEventListener","offsetHeight","offsetWidth","wrapperObserver","ResizeObserver","observe","contentObserver","animate","Animate","platform","navigator","userAgentData","virtualScroll","VirtualScroll","el","firefoxMultiplier","includes","useKeyboard","useTouch","passive","on","start","destroy","_this$wrapperObserver","removeEventListener","disconnect","now","setScroll","limit","emit","velocity","_temp3","_ref6$offset","_ref6","offset","_ref6$immediate","immediate","_ref6$duration","_ref6$easing","querySelector","nodeType","wrapperOffset","wrapperRect","getBoundingClientRect","left","top","get","EventEmitter"],"mappings":"6xBAgBO,SAAAA,EAAgBC,EAAOC,GAC5B,IAAKC,EAAGF,EAAQC,EAKhB,OAJIC,EAAI,IACNA,GAAKD,GAIRC,CAAA,4CCjBCC,WAAAA,SAAAA,IAAAA,CAAAA,IAAAA,EAAAA,EAAAA,UA+CmBC,OA/CnBD,EAAAA,GAAA,SAAGE,KAAuD,IAAAC,EAAAC,KAAAC,OAAA,IAAAC,EAAA,CAAI,QAAjDC,SAAAA,OAAW,IAAAC,EAAA,QAAGC,OAAAA,OAAS,IAAAC,EAAA,SAACC,GAAMA,OAAAA,CAAP,EAAaC,EAAAA,0IAC/CR,KAAKF,OAASA,EACdE,KAAKS,SAALC,EAAA,GAAqBF,GACrBR,KAAKW,OAAcH,EAAAA,CAAAA,EAAAA,GACnBR,KAAKQ,KAAOI,OAAOJ,KAAUA,EAAAA,CAAAA,EAAAA,IAG7BR,KAAKQ,KAAKK,QAAQ,SAACC,GACjBf,EAAKU,S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QAAQhH,GAAGI,KAAM,CACpBG,SAAAA,EACAE,OAAAA,EACAyF,OAAQ9F,KAAK0F,cAtD4B,CAyD9C,iCAjOD,WAOE,OALI1F,KAAKgG,cAAgB9C,OACO,eAAnBlD,KAAK2C,UAA6B,UAAY,UAE3B,eAAnB3C,KAAK2C,UAA6B,aAAe,WAG/D,GA2CD,CAAA7B,IAAA,QAAAqI,IAAA,WACE,MAA0B,eAAnBnJ,KAAK2C,UACR3C,KAAKuE,aAAevE,KAAK0D,aACzB1D,KAAKwE,cAAgBxE,KAAK4D,aAC/B,GAmED,CAAA9C,IAAA,WAAAqI,IAAA,WACE,OAAOnJ,KAAK8F,OAAS9F,KAAK+F,UAC3B,QA5OgCqD"} \ No newline at end of file +{"version":3,"file":"lenis.js","sources":["../src/maths.js","../src/lenis.js"],"sourcesContent":["export function clamp(min, input, max) {\n return Math.max(min, Math.min(input, max))\n}\n\nexport function mapRange(in_min, in_max, input, out_min, out_max) {\n return ((input - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min\n}\n\nexport function lerp(start, end, amt) {\n return (1 - amt) * start + amt * end\n}\n\nexport function truncate(value, decimals) {\n return parseFloat(value.toFixed(decimals))\n}\n\nexport function modulo(value, max) {\n let v = value % max\n if (v < 0) {\n v += max\n }\n\n return v\n}\n","import EventEmitter from 'tiny-emitter'\nimport VirtualScroll from 'virtual-scroll'\nimport { version } from '../package.json'\nimport { clamp, modulo } from './maths'\n\nclass Animate {\n to(target, { duration = 1, easing = (t) => t, ...keys } = {}) {\n this.target = target\n this.fromKeys = { ...keys }\n this.toKeys = { ...keys }\n this.keys = Object.keys({ ...keys })\n\n // get initial values\n this.keys.forEach((key) => {\n this.fromKeys[key] = target[key]\n })\n\n this.duration = duration\n this.easing = easing\n this.currentTime = 0\n this.isRunning = true\n }\n\n stop() {\n this.isRunning = false\n }\n\n raf(deltaTime) {\n if (!this.isRunning) return\n\n this.currentTime = Math.min(this.currentTime + deltaTime, this.duration)\n\n const progress = this.easing(this.progress)\n\n this.keys.forEach((key) => {\n const from = this.fromKeys[key]\n const to = this.toKeys[key]\n\n const value = from + (to - from) * progress\n\n this.target[key] = value\n })\n\n if (progress === 1) {\n this.stop()\n }\n }\n\n get progress() {\n return this.currentTime / this.duration\n }\n}\n\nexport default class Lenis extends EventEmitter {\n /**\n * @typedef {(t: number) => number} EasingFunction\n * @typedef {'vertical' | 'horizontal'} Direction\n * @typedef {'vertical' | 'horizontal' | 'both'} GestureDirection\n *\n * @typedef LenisOptions\n * @property {number} [duration]\n * @property {EasingFunction} [easing]\n * @property {boolean} [smooth]\n * @property {number} [mouseMultiplier]\n * @property {boolean} [smoothTouch]\n * @property {number} [touchMultiplier]\n * @property {Direction} [direction]\n * @property {GestureDirection} [gestureDirection]\n * @property {boolean} [infinite]\n * @property {Window | HTMLElement} [wrapper]\n * @property {HTMLElement} [content]\n *\n * @param {LenisOptions}\n */\n constructor({\n duration = 1.2,\n easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), // https://www.desmos.com/calculator/k2tgx2kn8t\n smooth = true,\n mouseMultiplier = 1,\n smoothTouch = false,\n touchMultiplier = 2,\n direction = 'vertical', // vertical, horizontal\n gestureDirection = 'vertical', // vertical, horizontal, both\n infinite = false,\n wrapper = window,\n content = document.body,\n } = {}) {\n super()\n\n window.lenisVersion = version\n\n this.options = {\n duration,\n easing,\n smooth,\n mouseMultiplier,\n smoothTouch,\n touchMultiplier,\n direction,\n gestureDirection,\n infinite,\n wrapper,\n content,\n }\n\n this.duration = duration\n this.easing = easing\n this.smooth = smooth\n this.mouseMultiplier = mouseMultiplier\n this.smoothTouch = smoothTouch\n this.touchMultiplier = touchMultiplier\n this.direction = direction\n this.gestureDirection = gestureDirection\n this.infinite = infinite\n this.wrapperNode = wrapper\n this.contentNode = content\n\n this.wrapperNode.addEventListener('scroll', this.onScroll)\n\n //observe wrapper node size\n if (this.wrapperNode === window) {\n this.wrapperNode.addEventListener('resize', this.onWindowResize)\n this.onWindowResize()\n } else {\n this.wrapperHeight = this.wrapperNode.offsetHeight\n this.wrapperWidth = this.wrapperNode.offsetWidth\n\n //observe wrapper node size\n this.wrapperObserver = new ResizeObserver(this.onWrapperResize)\n this.wrapperObserver.observe(this.wrapperNode)\n }\n\n this.contentHeight = this.contentNode.offsetHeight\n this.contentWidth = this.contentNode.offsetWidth\n\n //observe content node size\n this.contentObserver = new ResizeObserver(this.onContentResize)\n this.contentObserver.observe(this.contentNode)\n\n //set initial scroll position\n this.targetScroll =\n this.scroll =\n this.lastScroll =\n this.wrapperNode[this.scrollProperty]\n\n this.animate = new Animate()\n\n const platform =\n navigator?.userAgentData?.platform || navigator?.platform || 'unknown'\n\n // listen and normalize wheel event cross-browser\n this.virtualScroll = new VirtualScroll({\n el: this.wrapperNode,\n firefoxMultiplier: 50,\n mouseMultiplier:\n this.mouseMultiplier * (platform.includes('Win') ? 0.84 : 0.4),\n touchMultiplier: this.touchMultiplier,\n passive: false,\n })\n\n this.virtualScroll.on(this.onVirtualScroll)\n }\n\n get scrollProperty() {\n let property\n if (this.wrapperNode === window) {\n property = this.direction === 'horizontal' ? 'scrollX' : 'scrollY'\n } else {\n property = this.direction === 'horizontal' ? 'scrollLeft' : 'scrollTop'\n }\n return property\n }\n\n start() {\n this.stopped = false\n }\n\n stop() {\n this.stopped = true\n this.animate.stop()\n }\n\n destroy() {\n if (this.wrapperNode === window) {\n this.wrapperNode.removeEventListener('resize', this.onWindowResize)\n }\n this.wrapperNode.removeEventListener('scroll', this.onScroll)\n\n this.virtualScroll.destroy()\n this.wrapperObserver?.disconnect()\n this.contentObserver.disconnect()\n }\n\n onWindowResize = () => {\n this.wrapperWidth = window.innerWidth\n this.wrapperHeight = window.innerHeight\n }\n\n onWrapperResize = ([entry]) => {\n if (entry) {\n const rect = entry.contentRect\n this.wrapperWidth = rect.width\n this.wrapperHeight = rect.height\n }\n }\n\n onContentResize = ([entry]) => {\n if (entry) {\n const rect = entry.contentRect\n this.contentWidth = rect.width\n this.contentHeight = rect.height\n }\n }\n\n get limit() {\n return this.direction === 'horizontal'\n ? this.contentWidth - this.wrapperWidth\n : this.contentHeight - this.wrapperHeight\n }\n\n onVirtualScroll = ({ deltaY, deltaX, originalEvent: e }) => {\n const preventScroll = !!e\n .composedPath()\n .find(\n (node) => node.hasAttribute && node.hasAttribute('data-lenis-prevent')\n )\n\n if (e.ctrlKey || preventScroll) return\n\n // switch to smooth if event is touch and if smoothTouch=true\n this.smooth = !!e.changedTouches ? this.smoothTouch : this.options.smooth\n\n if (this.stopped) {\n e.preventDefault()\n return\n }\n\n if (!this.smooth) return\n\n // fix wheel holding scroll https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\n if (e.buttons === 4) return\n\n // prevent native wheel scrolling\n if (this.smooth) e.preventDefault()\n\n let delta = 0\n if (this.gestureDirection === 'both') {\n delta = deltaX + deltaY\n } else if (this.gestureDirection === 'horizontal') {\n delta = deltaX\n } else {\n // vertical\n delta = deltaY\n }\n\n this.targetScroll -= delta\n // this.targetScroll = clamp(0, this.targetScroll, this.limit)\n\n this.scrollTo(this.targetScroll)\n }\n\n raf(now) {\n const deltaTime = now - (this.now || 0)\n this.now = now\n\n if (this.stopped || !this.smooth) return\n\n this.lastScroll = this.scroll\n\n // where this.scroll is updated\n this.animate.raf(deltaTime * 0.001)\n\n if (this.scroll === this.targetScroll) {\n // if target reached velocity should be 0\n this.lastScroll = this.scroll\n }\n\n if (this.isScrolling) {\n this.setScroll(this.scroll)\n this.notify()\n }\n\n this.isScrolling = this.scroll !== this.targetScroll\n }\n\n get velocity() {\n return this.scroll - this.lastScroll\n }\n\n setScroll(value) {\n let scroll = this.infinite ? modulo(value, this.limit) : value\n\n this.direction === 'horizontal'\n ? this.wrapperNode.scrollTo(scroll, 0)\n : this.wrapperNode.scrollTo(0, scroll)\n }\n\n onScroll = (e) => {\n // if isScrolling false we can consider user isn't scrolling with wheel (cmd+F, keyboard or whatever). So we must scroll to value immediately\n if (!this.isScrolling || !this.smooth) {\n // where native scroll happens\n this.targetScroll =\n this.scroll =\n this.lastScroll =\n this.wrapperNode[this.scrollProperty]\n\n this.notify()\n }\n }\n\n notify() {\n let scroll = this.infinite ? modulo(this.scroll, this.limit) : this.scroll\n\n let direction = this.lastScroll < scroll ? 1 : -1\n\n this.emit('scroll', {\n scroll,\n limit: this.limit,\n velocity: this.velocity,\n direction,\n progress: scroll / this.limit,\n })\n }\n\n scrollTo(\n target,\n {\n offset = 0,\n immediate = false,\n duration = this.duration,\n easing = this.easing,\n } = {}\n ) {\n if (target === undefined || target === null) return\n let value\n\n if (typeof target === 'number') {\n value = target\n } else if (target === 'top' || target === '#top') {\n value = 0\n } else if (target === 'bottom') {\n value = this.limit\n } else {\n let node\n\n if (typeof target === 'string') {\n // CSS selector\n node = document.querySelector(target)\n } else if (target?.nodeType) {\n // Node element\n node = target\n } else {\n return\n }\n\n if (!node) return\n let wrapperOffset = 0\n\n if (this.wrapperNode !== window) {\n const wrapperRect = this.wrapperNode.getBoundingClientRect()\n wrapperOffset =\n this.direction === 'horizontal' ? wrapperRect.left : wrapperRect.top\n }\n\n const rect = node.getBoundingClientRect()\n\n value =\n (this.direction === 'horizontal' ? rect.left : rect.top) +\n this.scroll -\n wrapperOffset\n }\n\n value += offset\n\n if (this.infinite) {\n this.targetScroll = value\n } else {\n this.targetScroll = clamp(0, value, this.limit)\n }\n\n if (!this.smooth || immediate) {\n this.scroll = this.lastScroll = this.targetScroll\n this.setScroll(this.targetScroll)\n } else {\n this.animate.to(this, {\n duration,\n easing,\n scroll: this.targetScroll,\n })\n }\n }\n}\n"],"names":["modulo","value","max","v","Animate","_proto","prototype","to","target","_temp","_this","this","_ref","_ref$duration","duration","easing","_ref$easing","t","keys","_objectWithoutPropertiesLoose","_excluded","fromKeys","toKeys","Object","forEach","key","currentTime","isRunning","stop","raf","deltaTime","Math","min","progress","from","_this2","_createClass","get","_EventEmitter","Lenis","_temp2","_navigator","_navigator$userAgentD","_navigator2","_this3","_ref2","_ref2$duration","_ref2$easing","pow","_ref2$smooth","smooth","mouseMultiplier","_ref2$mouseMultiplier","smoothTouch","_ref2$smoothTouch","touchMultiplier","_ref2$touchMultiplier","direction","_ref2$direction","_ref2$gestureDirectio","gestureDirection","_ref2$infinite","infinite","wrapper","_ref2$wrapper","window","content","_ref2$content","document","body","onWindowResize","wrapperWidth","innerWidth","wrapperHeight","innerHeight","onWrapperResize","_ref3","entry","contentRect","rect","width","height","onContentResize","_ref4","contentWidth","contentHeight","onVirtualScroll","_ref5","deltaY","deltaX","e","originalEvent","preventScroll","composedPath","find","node","hasAttribute","ctrlKey","changedTouches","options","stopped","preventDefault","buttons","targetScroll","scrollTo","onScroll","isScrolling","scroll","lastScroll","wrapperNode","scrollProperty","notify","lenisVersion","contentNode","addEventListener","offsetHeight","offsetWidth","wrapperObserver","ResizeObserver","observe","contentObserver","animate","platform","navigator","userAgentData","virtualScroll","VirtualScroll","el","firefoxMultiplier","includes","passive","on","start","destroy","removeEventListener","_this$wrapperObserver","disconnect","_proto2","now","setScroll","limit","emit","velocity","_temp3","_ref6","_ref6$offset","offset","immediate","_ref6$immediate","_ref6$duration","_ref6$easing","querySelector","nodeType","getBoundingClientRect","wrapperOffset","wrapperRect","left","top","EventEmitter"],"mappings":"6xBAgBgBA,SAAAA,EAAOC,EAAOC,GAC5B,IAAKC,EAAGF,EAAQC,EAKhB,OAJIC,EAAI,IACNA,GAAKD,GAITC,CAAA,6BClBaC,eAAA,WAAA,SAAAA,IAAA,CAAA,IAAAC,EAAAD,EAAAE,iBAAAD,EACXE,GAAA,SAAGC,EAA2DC,GAAA,IAAAC,EAAAC,KAAAC,OAAA,IAAAH,EAAJ,CAAE,EAAAA,EAAAI,EAAAD,EAA/CE,SAAAA,OAAQ,IAAAD,EAAG,EAAGE,EAAAA,EAAAA,EAAAA,OAAAA,OAAM,IAAAC,EAAG,SAACC,GAAC,OAAMA,CAAA,EAAAD,EAAKE,oIAAIC,CAAAP,EAAAQ,GACnDT,KAAKH,OAASA,EACdG,KAAK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sB,EAAK6E,KAAO7E,EAAK8E,KACpDlJ,KAAKgG,OACL+C,CACJ,CAEAzJ,GAASiJ,EAGPvI,KAAK4F,aADH5F,KAAKmD,SACa7D,EDtXjB8B,KAAK7B,ICwXkB,EDxXT6B,KAAKC,ICwXO/B,EAAOU,KAAKiI,SAGtCjI,KAAKuC,QAAUiG,GAClBxI,KAAKgG,OAAShG,KAAKiG,WAAajG,KAAK4F,aACrC5F,KAAKgI,UAAUhI,KAAK4F,eAEpB5F,KAAK8G,QAAQlH,GAAGI,KAAM,CACpBG,SAAAA,EACAC,OAAAA,EACA4F,OAAQhG,KAAK4F,cArDjB,CAwDF,EAACnE,EAAAG,EAAA,CAAA,CAAAd,IAAA,iBAAAY,IAnOD,WAOE,OALI1B,KAAKkG,cAAgB5C,OACO,eAAnBtD,KAAK8C,UAA6B,UAAY,UAE3B,eAAnB9C,KAAK8C,UAA6B,aAAe,WAGhE,GA2CA,CAAAhC,IAAA,QAAAY,IAAA,WACE,MAA0B,oBAAdoB,UACR9C,KAAKyE,aAAezE,KAAK4D,aACzB5D,KAAK0E,cAAgB1E,KAAK8D,aAChC,GAmEA,CAAAhD,IAAA,WAAAY,IAAA,WACE,YAAYsE,OAAShG,KAAKiG,UAC5B,KAACrE,CAAA,CA1OuB,CAASuH,EAAY"} \ No newline at end of file diff --git a/dist/lenis.mjs b/dist/lenis.mjs index ac4d620c..a6a34a22 100644 --- a/dist/lenis.mjs +++ b/dist/lenis.mjs @@ -1,2 +1,2 @@ -import t from"tiny-emitter";import i from"virtual-scroll";function e(t,i){for(var e=0;e=0||(r[e]=t[e]);return r}(o,l);this.target=t,this.fromKeys=r({},h),this.toKeys=r({},h),this.keys=Object.keys(r({},h)),this.keys.forEach(function(i){e.fromKeys[i]=t[i]}),this.duration=s,this.easing=a,this.currentTime=0,this.isRunning=!0},i.stop=function(){this.isRunning=!1},i.raf=function(t){var i=this;if(this.isRunning){this.currentTime=Math.min(this.currentTime+t,this.duration);var e=this.easing(this.progress);this.keys.forEach(function(t){var o=i.fromKeys[t];i.target[t]=o+(i.toKeys[t]-o)*e}),1===e&&this.stop()}},o(t,[{key:"progress",get:function(){return this.currentTime/this.duration}}]),t}(),a=/*#__PURE__*/function(t){var e,r;function l(e){var o,r,n,s,l=void 0===e?{}:e,a=l.duration,h=void 0===a?1.2:a,u=l.easing,p=void 0===u?function(t){return Math.min(1,1.001-Math.pow(2,-10*t))}:u,d=l.smooth,f=void 0===d||d,v=l.mouseMultiplier,g=void 0===v?1:v,w=l.smoothTouch,m=void 0!==w&&w,y=l.touchMultiplier,b=void 0===y?2:y,S=l.direction,N=void 0===S?"vertical":S,O=l.gestureDirection,z=void 0===O?"vertical":O,R=l.infinite,W=void 0!==R&&R,M=l.wrapper,T=void 0===M?window:M,k=l.content,j=void 0===k?document.body:k;(s=t.call(this)||this).onWindowResize=function(){s.wrapperWidth=window.innerWidth,s.wrapperHeight=window.innerHeight},s.onWrapperResize=function(t){var i=t[0];if(i){var e=i.contentRect;s.wrapperWidth=e.width,s.wrapperHeight=e.height}},s.onContentResize=function(t){var i=t[0];if(i){var e=i.contentRect;s.contentWidth=e.width,s.contentHeight=e.height}},s.onVirtualScroll=function(t){var i=t.deltaY,e=t.deltaX,o=t.originalEvent,r=!!o.composedPath().find(function(t){return t.hasAttribute&&t.hasAttribute("data-lenis-prevent")});o.ctrlKey||r||(s.smooth=o.changedTouches?s.smoothTouch:s.options.smooth,s.stopped?o.preventDefault():s.smooth&&4!==o.buttons&&(s.smooth&&o.preventDefault(),s.targetScroll-="both"===s.gestureDirection?e+i:"horizontal"===s.gestureDirection?e:i,s.scrollTo(s.targetScroll)))},s.onScroll=function(t){s.isScrolling&&s.smooth||(s.targetScroll=s.scroll=s.lastScroll=s.wrapperNode[s.scrollProperty],s.notify())},window.lenisVersion="0.2.19",s.options={duration:h,easing:p,smooth:f,mouseMultiplier:g,smoothTouch:m,touchMultiplier:b,direction:N,gestureDirection:z,infinite:W,wrapper:T,content:j},s.duration=h,s.easing=p,s.smooth=f,s.mouseMultiplier=g,s.smoothTouch=m,s.touchMultiplier=b,s.direction=N,s.gestureDirection=z,s.infinite=W,s.wrapperNode=T,s.contentNode=j,s.wrapperNode.addEventListener("scroll",s.onScroll),s.wrapperNode===window?(s.wrapperNode.addEventListener("resize",s.onWindowResize),s.onWindowResize()):(s.wrapperHeight=s.wrapperNode.offsetHeight,s.wrapperWidth=s.wrapperNode.offsetWidth,s.wrapperObserver=new ResizeObserver(s.onWrapperResize),s.wrapperObserver.observe(s.wrapperNode)),s.contentHeight=s.contentNode.offsetHeight,s.contentWidth=s.contentNode.offsetWidth,s.contentObserver=new ResizeObserver(s.onContentResize),s.contentObserver.observe(s.contentNode),s.targetScroll=s.scroll=s.lastScroll=s.wrapperNode[s.scrollProperty],s.animate=new c;var H=(null==(o=navigator)||null==(r=o.userAgentData)?void 0:r.platform)||(null==(n=navigator)?void 0:n.platform)||"unknown";return s.virtualScroll=new i({el:s.wrapperNode,firefoxMultiplier:50,mouseMultiplier:s.mouseMultiplier*(H.includes("Win")?.84:.4),useKeyboard:!1,touchMultiplier:s.touchMultiplier,useTouch:!0,passive:!1}),s.virtualScroll.on(s.onVirtualScroll),s}r=t,(e=l).prototype=Object.create(r.prototype),e.prototype.constructor=e,n(e,r);var a=l.prototype;return a.start=function(){this.stopped=!1},a.stop=function(){this.stopped=!0,this.animate.stop()},a.destroy=function(){var t;this.wrapperNode===window&&this.wrapperNode.removeEventListener("resize",this.onWindowResize),this.wrapperNode.removeEventListener("scroll",this.onScroll),this.virtualScroll.destroy(),null==(t=this.wrapperObserver)||t.disconnect(),this.contentObserver.disconnect()},a.raf=function(t){var i=t-(this.now||0);this.now=t,!this.stopped&&this.smooth&&(this.lastScroll=this.scroll,this.animate.raf(.001*i),this.scroll===this.targetScroll&&(this.lastScroll=this.scroll),this.isScrolling&&(this.setScroll(this.scroll),this.notify()),this.isScrolling=this.scroll!==this.targetScroll)},a.setScroll=function(t){var i=this.infinite?s(t,this.limit):t;"horizontal"===this.direction?this.wrapperNode.scrollTo(i,0):this.wrapperNode.scrollTo(0,i)},a.notify=function(){var t=this.infinite?s(this.scroll,this.limit):this.scroll;this.emit("scroll",{scroll:t,limit:this.limit,velocity:this.velocity,direction:this.direction,progress:t/this.limit})},a.scrollTo=function(t,i){var e=void 0===i?{}:i,o=e.offset,r=void 0===o?0:o,n=e.immediate,s=void 0!==n&&n,l=e.duration,c=void 0===l?this.duration:l,a=e.easing,h=void 0===a?this.easing:a;if(null!=t){var u;if("number"==typeof t)u=t;else if("top"===t||"#top"===t)u=0;else if("bottom"===t)u=this.limit;else{var p;if("string"==typeof t)p=document.querySelector(t);else{if(null==t||!t.nodeType)return;p=t}if(!p)return;var d=0;if(this.wrapperNode!==window){var f=this.wrapperNode.getBoundingClientRect();d="horizontal"===this.direction?f.left:f.top}var v=p.getBoundingClientRect();u=("horizontal"===this.direction?v.left:v.top)+this.scroll-d}u+=r,this.targetScroll=this.infinite?u:Math.max(0,Math.min(u,this.limit)),!this.smooth||s?(this.scroll=this.lastScroll=this.targetScroll,this.setScroll(this.targetScroll)):this.animate.to(this,{duration:c,easing:h,scroll:this.targetScroll})}},o(l,[{key:"scrollProperty",get:function(){return this.wrapperNode===window?"horizontal"===this.direction?"scrollX":"scrollY":"horizontal"===this.direction?"scrollLeft":"scrollTop"}},{key:"limit",get:function(){return"horizontal"===this.direction?this.contentWidth-this.wrapperWidth:this.contentHeight-this.wrapperHeight}},{key:"velocity",get:function(){return this.scroll-this.lastScroll}}]),l}(t);export{a as default}; +import t from"tiny-emitter";import i from"virtual-scroll";function e(t,i){for(var e=0;e=0||(r[e]=t[e]);return r}(o,l);this.target=t,this.fromKeys=r({},h),this.toKeys=r({},h),this.keys=Object.keys(r({},h)),this.keys.forEach(function(i){e.fromKeys[i]=t[i]}),this.duration=s,this.easing=a,this.currentTime=0,this.isRunning=!0},i.stop=function(){this.isRunning=!1},i.raf=function(t){var i=this;if(this.isRunning){this.currentTime=Math.min(this.currentTime+t,this.duration);var e=this.easing(this.progress);this.keys.forEach(function(t){var o=i.fromKeys[t];i.target[t]=o+(i.toKeys[t]-o)*e}),1===e&&this.stop()}},o(t,[{key:"progress",get:function(){return this.currentTime/this.duration}}]),t}(),a=/*#__PURE__*/function(t){var e,r;function l(e){var o,r,n,s,l=void 0===e?{}:e,a=l.duration,h=void 0===a?1.2:a,p=l.easing,u=void 0===p?function(t){return Math.min(1,1.001-Math.pow(2,-10*t))}:p,d=l.smooth,f=void 0===d||d,v=l.mouseMultiplier,g=void 0===v?1:v,w=l.smoothTouch,m=void 0!==w&&w,y=l.touchMultiplier,b=void 0===y?2:y,S=l.direction,N=void 0===S?"vertical":S,O=l.gestureDirection,z=void 0===O?"vertical":O,R=l.infinite,W=void 0!==R&&R,M=l.wrapper,T=void 0===M?window:M,k=l.content,j=void 0===k?document.body:k;(s=t.call(this)||this).onWindowResize=function(){s.wrapperWidth=window.innerWidth,s.wrapperHeight=window.innerHeight},s.onWrapperResize=function(t){var i=t[0];if(i){var e=i.contentRect;s.wrapperWidth=e.width,s.wrapperHeight=e.height}},s.onContentResize=function(t){var i=t[0];if(i){var e=i.contentRect;s.contentWidth=e.width,s.contentHeight=e.height}},s.onVirtualScroll=function(t){var i=t.deltaY,e=t.deltaX,o=t.originalEvent,r=!!o.composedPath().find(function(t){return t.hasAttribute&&t.hasAttribute("data-lenis-prevent")});o.ctrlKey||r||(s.smooth=o.changedTouches?s.smoothTouch:s.options.smooth,s.stopped?o.preventDefault():s.smooth&&4!==o.buttons&&(s.smooth&&o.preventDefault(),s.targetScroll-="both"===s.gestureDirection?e+i:"horizontal"===s.gestureDirection?e:i,s.scrollTo(s.targetScroll)))},s.onScroll=function(t){s.isScrolling&&s.smooth||(s.targetScroll=s.scroll=s.lastScroll=s.wrapperNode[s.scrollProperty],s.notify())},window.lenisVersion="0.2.20",s.options={duration:h,easing:u,smooth:f,mouseMultiplier:g,smoothTouch:m,touchMultiplier:b,direction:N,gestureDirection:z,infinite:W,wrapper:T,content:j},s.duration=h,s.easing=u,s.smooth=f,s.mouseMultiplier=g,s.smoothTouch=m,s.touchMultiplier=b,s.direction=N,s.gestureDirection=z,s.infinite=W,s.wrapperNode=T,s.contentNode=j,s.wrapperNode.addEventListener("scroll",s.onScroll),s.wrapperNode===window?(s.wrapperNode.addEventListener("resize",s.onWindowResize),s.onWindowResize()):(s.wrapperHeight=s.wrapperNode.offsetHeight,s.wrapperWidth=s.wrapperNode.offsetWidth,s.wrapperObserver=new ResizeObserver(s.onWrapperResize),s.wrapperObserver.observe(s.wrapperNode)),s.contentHeight=s.contentNode.offsetHeight,s.contentWidth=s.contentNode.offsetWidth,s.contentObserver=new ResizeObserver(s.onContentResize),s.contentObserver.observe(s.contentNode),s.targetScroll=s.scroll=s.lastScroll=s.wrapperNode[s.scrollProperty],s.animate=new c;var H=(null==(o=navigator)||null==(r=o.userAgentData)?void 0:r.platform)||(null==(n=navigator)?void 0:n.platform)||"unknown";return s.virtualScroll=new i({el:s.wrapperNode,firefoxMultiplier:50,mouseMultiplier:s.mouseMultiplier*(H.includes("Win")?.84:.4),touchMultiplier:s.touchMultiplier,passive:!1}),s.virtualScroll.on(s.onVirtualScroll),s}r=t,(e=l).prototype=Object.create(r.prototype),e.prototype.constructor=e,n(e,r);var a=l.prototype;return a.start=function(){this.stopped=!1},a.stop=function(){this.stopped=!0,this.animate.stop()},a.destroy=function(){var t;this.wrapperNode===window&&this.wrapperNode.removeEventListener("resize",this.onWindowResize),this.wrapperNode.removeEventListener("scroll",this.onScroll),this.virtualScroll.destroy(),null==(t=this.wrapperObserver)||t.disconnect(),this.contentObserver.disconnect()},a.raf=function(t){var i=t-(this.now||0);this.now=t,!this.stopped&&this.smooth&&(this.lastScroll=this.scroll,this.animate.raf(.001*i),this.scroll===this.targetScroll&&(this.lastScroll=this.scroll),this.isScrolling&&(this.setScroll(this.scroll),this.notify()),this.isScrolling=this.scroll!==this.targetScroll)},a.setScroll=function(t){var i=this.infinite?s(t,this.limit):t;"horizontal"===this.direction?this.wrapperNode.scrollTo(i,0):this.wrapperNode.scrollTo(0,i)},a.notify=function(){var t=this.infinite?s(this.scroll,this.limit):this.scroll;this.emit("scroll",{scroll:t,limit:this.limit,velocity:this.velocity,direction:this.lastScroll t, ...keys } = {}) {\r\n this.target = target\r\n this.fromKeys = { ...keys }\r\n this.toKeys = { ...keys }\r\n this.keys = Object.keys({ ...keys })\r\n\r\n // get initial values\r\n this.keys.forEach((key) => {\r\n this.fromKeys[key] = target[key]\r\n })\r\n\r\n this.duration = duration\r\n this.easing = easing\r\n this.currentTime = 0\r\n this.isRunning = true\r\n }\r\n\r\n stop() {\r\n this.isRunning = false\r\n }\r\n\r\n raf(deltaTime) {\r\n if (!this.isRunning) return\r\n\r\n this.currentTime = Math.min(this.currentTime + deltaTime, this.duration)\r\n\r\n const progress = this.easing(this.progress)\r\n\r\n this.keys.forEach((key) => {\r\n const from = this.fromKeys[key]\r\n const to = this.toKeys[key]\r\n\r\n const value = from + (to - from) * progress\r\n\r\n this.target[key] = value\r\n })\r\n\r\n if (progress === 1) {\r\n this.stop()\r\n }\r\n }\r\n\r\n get progress() {\r\n return this.currentTime / this.duration\r\n }\r\n}\r\n\r\nexport default class Lenis extends EventEmitter {\r\n /**\r\n * @typedef {(t: number) => number} EasingFunction\r\n * @typedef {'vertical' | 'horizontal'} Direction\r\n * @typedef {'vertical' | 'horizontal' | 'both'} GestureDirection\r\n *\r\n * @typedef LenisOptions\r\n * @property {number} [duration]\r\n * @property {EasingFunction} [easing]\r\n * @property {boolean} [smooth]\r\n * @property {number} [mouseMultiplier]\r\n * @property {boolean} [smoothTouch]\r\n * @property {number} [touchMultiplier]\r\n * @property {Direction} [direction]\r\n * @property {GestureDirection} [gestureDirection]\r\n * @property {boolean} [infinite]\r\n * @property {Window | HTMLElement} [wrapper]\r\n * @property {HTMLElement} [content]\r\n *\r\n * @param {LenisOptions}\r\n */\r\n constructor({\r\n duration = 1.2,\r\n easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), // https://www.desmos.com/calculator/k2tgx2kn8t\r\n smooth = true,\r\n mouseMultiplier = 1,\r\n smoothTouch = false,\r\n touchMultiplier = 2,\r\n direction = 'vertical', // vertical, horizontal\r\n gestureDirection = 'vertical', // vertical, horizontal, both\r\n infinite = false,\r\n wrapper = window,\r\n content = document.body,\r\n } = {}) {\r\n super()\r\n\r\n window.lenisVersion = version\r\n\r\n this.options = {\r\n duration,\r\n easing,\r\n smooth,\r\n mouseMultiplier,\r\n smoothTouch,\r\n touchMultiplier,\r\n direction,\r\n gestureDirection,\r\n infinite,\r\n wrapper,\r\n content,\r\n }\r\n\r\n this.duration = duration\r\n this.easing = easing\r\n this.smooth = smooth\r\n this.mouseMultiplier = mouseMultiplier\r\n this.smoothTouch = smoothTouch\r\n this.touchMultiplier = touchMultiplier\r\n this.direction = direction\r\n this.gestureDirection = gestureDirection\r\n this.infinite = infinite\r\n this.wrapperNode = wrapper\r\n this.contentNode = content\r\n\r\n this.wrapperNode.addEventListener('scroll', this.onScroll)\r\n\r\n //observe wrapper node size\r\n if (this.wrapperNode === window) {\r\n this.wrapperNode.addEventListener('resize', this.onWindowResize)\r\n this.onWindowResize()\r\n } else {\r\n this.wrapperHeight = this.wrapperNode.offsetHeight\r\n this.wrapperWidth = this.wrapperNode.offsetWidth\r\n\r\n //observe wrapper node size\r\n this.wrapperObserver = new ResizeObserver(this.onWrapperResize)\r\n this.wrapperObserver.observe(this.wrapperNode)\r\n }\r\n\r\n this.contentHeight = this.contentNode.offsetHeight\r\n this.contentWidth = this.contentNode.offsetWidth\r\n\r\n //observe content node size\r\n this.contentObserver = new ResizeObserver(this.onContentResize)\r\n this.contentObserver.observe(this.contentNode)\r\n\r\n //set initial scroll position\r\n this.targetScroll =\r\n this.scroll =\r\n this.lastScroll =\r\n this.wrapperNode[this.scrollProperty]\r\n\r\n this.animate = new Animate()\r\n\r\n const platform =\r\n navigator?.userAgentData?.platform || navigator?.platform || 'unknown'\r\n\r\n // listen and normalize wheel event cross-browser\r\n this.virtualScroll = new VirtualScroll({\r\n el: this.wrapperNode,\r\n firefoxMultiplier: 50,\r\n mouseMultiplier:\r\n this.mouseMultiplier * (platform.includes('Win') ? 0.84 : 0.4),\r\n useKeyboard: false,\r\n touchMultiplier: this.touchMultiplier,\r\n useTouch: true,\r\n passive: false,\r\n })\r\n\r\n this.virtualScroll.on(this.onVirtualScroll)\r\n }\r\n\r\n get scrollProperty() {\r\n let property\r\n if (this.wrapperNode === window) {\r\n property = this.direction === 'horizontal' ? 'scrollX' : 'scrollY'\r\n } else {\r\n property = this.direction === 'horizontal' ? 'scrollLeft' : 'scrollTop'\r\n }\r\n return property\r\n }\r\n\r\n start() {\r\n this.stopped = false\r\n }\r\n\r\n stop() {\r\n this.stopped = true\r\n this.animate.stop()\r\n }\r\n\r\n destroy() {\r\n if (this.wrapperNode === window) {\r\n this.wrapperNode.removeEventListener('resize', this.onWindowResize)\r\n }\r\n this.wrapperNode.removeEventListener('scroll', this.onScroll)\r\n\r\n this.virtualScroll.destroy()\r\n this.wrapperObserver?.disconnect()\r\n this.contentObserver.disconnect()\r\n }\r\n\r\n onWindowResize = () => {\r\n this.wrapperWidth = window.innerWidth\r\n this.wrapperHeight = window.innerHeight\r\n }\r\n\r\n onWrapperResize = ([entry]) => {\r\n if (entry) {\r\n const rect = entry.contentRect\r\n this.wrapperWidth = rect.width\r\n this.wrapperHeight = rect.height\r\n }\r\n }\r\n\r\n onContentResize = ([entry]) => {\r\n if (entry) {\r\n const rect = entry.contentRect\r\n this.contentWidth = rect.width\r\n this.contentHeight = rect.height\r\n }\r\n }\r\n\r\n get limit() {\r\n return this.direction === 'horizontal'\r\n ? this.contentWidth - this.wrapperWidth\r\n : this.contentHeight - this.wrapperHeight\r\n }\r\n\r\n onVirtualScroll = ({ deltaY, deltaX, originalEvent: e }) => {\r\n const preventScroll = !!e\r\n .composedPath()\r\n .find(\r\n (node) => node.hasAttribute && node.hasAttribute('data-lenis-prevent')\r\n )\r\n\r\n if (e.ctrlKey || preventScroll) return\r\n\r\n // switch to smooth if event is touch and if smoothTouch=true\r\n this.smooth = !!e.changedTouches ? this.smoothTouch : this.options.smooth\r\n\r\n if (this.stopped) {\r\n e.preventDefault()\r\n return\r\n }\r\n\r\n if (!this.smooth) return\r\n\r\n // fix wheel holding scroll https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\r\n if (e.buttons === 4) return\r\n\r\n // prevent native wheel scrolling\r\n if (this.smooth) e.preventDefault()\r\n\r\n let delta = 0\r\n if (this.gestureDirection === 'both') {\r\n delta = deltaX + deltaY\r\n } else if (this.gestureDirection === 'horizontal') {\r\n delta = deltaX\r\n } else {\r\n // vertical\r\n delta = deltaY\r\n }\r\n\r\n this.targetScroll -= delta\r\n // this.targetScroll = clamp(0, this.targetScroll, this.limit)\r\n\r\n this.scrollTo(this.targetScroll)\r\n }\r\n\r\n raf(now) {\r\n const deltaTime = now - (this.now || 0)\r\n this.now = now\r\n\r\n if (this.stopped || !this.smooth) return\r\n\r\n this.lastScroll = this.scroll\r\n\r\n // where this.scroll is updated\r\n this.animate.raf(deltaTime * 0.001)\r\n\r\n if (this.scroll === this.targetScroll) {\r\n // if target reached velocity should be 0\r\n this.lastScroll = this.scroll\r\n }\r\n\r\n if (this.isScrolling) {\r\n this.setScroll(this.scroll)\r\n this.notify()\r\n }\r\n\r\n this.isScrolling = this.scroll !== this.targetScroll\r\n }\r\n\r\n get velocity() {\r\n return this.scroll - this.lastScroll\r\n }\r\n\r\n setScroll(value) {\r\n let scroll = this.infinite ? modulo(value, this.limit) : value\r\n\r\n this.direction === 'horizontal'\r\n ? this.wrapperNode.scrollTo(scroll, 0)\r\n : this.wrapperNode.scrollTo(0, scroll)\r\n }\r\n\r\n onScroll = (e) => {\r\n // if isScrolling false we can consider user isn't scrolling with wheel (cmd+F, keyboard or whatever). So we must scroll to value immediately\r\n if (!this.isScrolling || !this.smooth) {\r\n // where native scroll happens\r\n this.targetScroll =\r\n this.scroll =\r\n this.lastScroll =\r\n this.wrapperNode[this.scrollProperty]\r\n\r\n this.notify()\r\n }\r\n }\r\n\r\n notify() {\r\n let scroll = this.infinite ? modulo(this.scroll, this.limit) : this.scroll\r\n\r\n this.emit('scroll', {\r\n scroll,\r\n limit: this.limit,\r\n velocity: this.velocity,\r\n direction: this.direction,\r\n progress: scroll / this.limit,\r\n })\r\n }\r\n\r\n scrollTo(\r\n target,\r\n {\r\n offset = 0,\r\n immediate = false,\r\n duration = this.duration,\r\n easing = this.easing,\r\n } = {}\r\n ) {\r\n if (target === undefined || target === null) return\r\n let value\r\n\r\n if (typeof target === 'number') {\r\n value = target\r\n } else if (target === 'top' || target === '#top') {\r\n value = 0\r\n } else if (target === 'bottom') {\r\n value = this.limit\r\n } else {\r\n let node\r\n\r\n if (typeof target === 'string') {\r\n // CSS selector\r\n node = document.querySelector(target)\r\n } else if (target?.nodeType) {\r\n // Node element\r\n node = target\r\n } else {\r\n return\r\n }\r\n\r\n if (!node) return\r\n let wrapperOffset = 0\r\n\r\n if (this.wrapperNode !== window) {\r\n const wrapperRect = this.wrapperNode.getBoundingClientRect()\r\n wrapperOffset =\r\n this.direction === 'horizontal' ? wrapperRect.left : wrapperRect.top\r\n }\r\n\r\n const rect = node.getBoundingClientRect()\r\n\r\n value =\r\n (this.direction === 'horizontal' ? rect.left : rect.top) +\r\n this.scroll -\r\n wrapperOffset\r\n }\r\n\r\n value += offset\r\n\r\n if (this.infinite) {\r\n this.targetScroll = value\r\n } else {\r\n this.targetScroll = clamp(0, value, this.limit)\r\n }\r\n\r\n if (!this.smooth || immediate) {\r\n this.scroll = this.lastScroll = this.targetScroll\r\n this.setScroll(this.targetScroll)\r\n } else {\r\n this.animate.to(this, {\r\n duration,\r\n easing,\r\n scroll: this.targetScroll,\r\n })\r\n }\r\n }\r\n}\r\n"],"names":["modulo","value","max","v","to","Lenis","target","_this","this","_ref","_temp","duration","_ref$duration","easing","_ref$easing","t","keys","fromKeys","_extends","toKeys","Object","forEach","key","currentTime","isRunning","stop","raf","deltaTime","_this2","Math","min","progress","from","_temp2","_navigator","_navigator$userAgentD","_navigator2","_this3","_ref2","_ref2$duration","_ref2$easing","pow","_ref2$smooth","smooth","_ref2$mouseMultiplier","mouseMultiplier","_ref2$smoothTouch","smoothTouch","_ref2$touchMultiplier","touchMultiplier","_ref2$direction","direction","_ref2$gestureDirectio","gestureDirection","_ref2$infinite","infinite","_ref2$wrapper","wrapper","window","_ref2$content","content","document","body","_EventEmitter","call","onWindowResize","wrapperWidth","innerWidth","wrapperHeight","innerHeight","onWrapperResize","_ref3","entry","rect","contentRect","width","height","onContentResize","_ref4","contentWidth","contentHeight","onVirtualScroll","_ref5","deltaY","deltaX","e","originalEvent","preventScroll","composedPath","find","node","hasAttribute","ctrlKey","changedTouches","options","stopped","preventDefault","buttons","targetScroll","scrollTo","onScroll","isScrolling","scroll","lastScroll","wrapperNode","scrollProperty","notify","lenisVersion","contentNode","addEventListener","offsetHeight","offsetWidth","wrapperObserver","ResizeObserver","observe","contentObserver","animate","Animate","platform","navigator","userAgentData","virtualScroll","VirtualScroll","el","firefoxMultiplier","includes","useKeyboard","useTouch","passive","on","start","destroy","_this$wrapperObserver","removeEventListener","disconnect","now","setScroll","limit","emit","velocity","_temp3","_ref6$offset","_ref6","offset","_ref6$immediate","immediate","_ref6$duration","_ref6$easing","querySelector","nodeType","wrapperOffset","wrapperRect","getBoundingClientRect","left","top","get","EventEmitter"],"mappings":"yqBAgBO,SAAAA,EAAgBC,EAAOC,GAC5B,IAAKC,EAAGF,EAAQC,EAKhB,OAJIC,EAAI,IACNA,GAAKD,GAIRC,CAAA,4CCjBCC,WAAAA,SAAAA,IAAAA,CAAAA,IAAAA,EAAAA,EAAAA,UA+CmBC,OA/CnBD,EAAAA,GAAA,SAAGE,KAAuD,IAAAC,EAAAC,KAAAC,OAAA,IAAAC,EAAA,CAAI,QAAjDC,SAAAA,OAAW,IAAAC,EAAA,QAAGC,OAAAA,OAAS,IAAAC,EAAA,SAACC,GAAMA,OAAAA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EAGPvI,KAAK0F,aADH1F,KAAK+C,SACatD,EDtXjB4B,KAAK3B,ICwXkB,EDxXT2B,KAAKC,ICwXO7B,EAAOO,KAAKiI,SAGtCjI,KAAKmC,QAAUsG,GAClBzI,KAAK8F,OAAS9F,KAAK+F,WAAa/F,KAAK0F,aACrC1F,KAAKgI,UAAUhI,KAAK0F,eAEpB1F,KAAK4G,QAAQhH,GAAGI,KAAM,CACpBG,SAAAA,EACAE,OAAAA,EACAyF,OAAQ9F,KAAK0F,cAtD4B,CAyD9C,iCAjOD,WAOE,OALI1F,KAAKgG,cAAgB9C,OACO,eAAnBlD,KAAK2C,UAA6B,UAAY,UAE3B,eAAnB3C,KAAK2C,UAA6B,aAAe,WAG/D,GA2CD,CAAA7B,IAAA,QAAAqI,IAAA,WACE,MAA0B,eAAnBnJ,KAAK2C,UACR3C,KAAKuE,aAAevE,KAAK0D,aACzB1D,KAAKwE,cAAgBxE,KAAK4D,aAC/B,GAmED,CAAA9C,IAAA,WAAAqI,IAAA,WACE,OAAOnJ,KAAK8F,OAAS9F,KAAK+F,UAC3B,QA5OgCqD"} \ No newline at end of file +{"version":3,"file":"lenis.mjs","sources":["../src/maths.js","../src/lenis.js"],"sourcesContent":["export function clamp(min, input, max) {\n return Math.max(min, Math.min(input, max))\n}\n\nexport function mapRange(in_min, in_max, input, out_min, out_max) {\n return ((input - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min\n}\n\nexport function lerp(start, end, amt) {\n return (1 - amt) * start + amt * end\n}\n\nexport function truncate(value, decimals) {\n return parseFloat(value.toFixed(decimals))\n}\n\nexport function modulo(value, max) {\n let v = value % max\n if (v < 0) {\n v += max\n }\n\n return v\n}\n","import EventEmitter from 'tiny-emitter'\nimport VirtualScroll from 'virtual-scroll'\nimport { version } from '../package.json'\nimport { clamp, modulo } from './maths'\n\nclass Animate {\n to(target, { duration = 1, easing = (t) => t, ...keys } = {}) {\n this.target = target\n this.fromKeys = { ...keys }\n this.toKeys = { ...keys }\n this.keys = Object.keys({ ...keys })\n\n // get initial values\n this.keys.forEach((key) => {\n this.fromKeys[key] = target[key]\n })\n\n this.duration = duration\n this.easing = easing\n this.currentTime = 0\n this.isRunning = true\n }\n\n stop() {\n this.isRunning = false\n }\n\n raf(deltaTime) {\n if (!this.isRunning) return\n\n this.currentTime = Math.min(this.currentTime + deltaTime, this.duration)\n\n const progress = this.easing(this.progress)\n\n this.keys.forEach((key) => {\n const from = this.fromKeys[key]\n const to = this.toKeys[key]\n\n const value = from + (to - from) * progress\n\n this.target[key] = value\n })\n\n if (progress === 1) {\n this.stop()\n }\n }\n\n get progress() {\n return this.currentTime / this.duration\n }\n}\n\nexport default class Lenis extends EventEmitter {\n /**\n * @typedef {(t: number) => number} EasingFunction\n * @typedef {'vertical' | 'horizontal'} Direction\n * @typedef {'vertical' | 'horizontal' | 'both'} GestureDirection\n *\n * @typedef LenisOptions\n * @property {number} [duration]\n * @property {EasingFunction} [easing]\n * @property {boolean} [smooth]\n * @property {number} [mouseMultiplier]\n * @property {boolean} [smoothTouch]\n * @property {number} [touchMultiplier]\n * @property {Direction} [direction]\n * @property {GestureDirection} [gestureDirection]\n * @property {boolean} [infinite]\n * @property {Window | HTMLElement} [wrapper]\n * @property {HTMLElement} [content]\n *\n * @param {LenisOptions}\n */\n constructor({\n duration = 1.2,\n easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), // https://www.desmos.com/calculator/k2tgx2kn8t\n smooth = true,\n mouseMultiplier = 1,\n smoothTouch = false,\n touchMultiplier = 2,\n direction = 'vertical', // vertical, horizontal\n gestureDirection = 'vertical', // vertical, horizontal, both\n infinite = false,\n wrapper = window,\n content = document.body,\n } = {}) {\n super()\n\n window.lenisVersion = version\n\n this.options = {\n duration,\n easing,\n smooth,\n mouseMultiplier,\n smoothTouch,\n touchMultiplier,\n direction,\n gestureDirection,\n infinite,\n wrapper,\n content,\n }\n\n this.duration = duration\n this.easing = easing\n this.smooth = smooth\n this.mouseMultiplier = mouseMultiplier\n this.smoothTouch = smoothTouch\n this.touchMultiplier = touchMultiplier\n this.direction = direction\n this.gestureDirection = gestureDirection\n this.infinite = infinite\n this.wrapperNode = wrapper\n this.contentNode = content\n\n this.wrapperNode.addEventListener('scroll', this.onScroll)\n\n //observe wrapper node size\n if (this.wrapperNode === window) {\n this.wrapperNode.addEventListener('resize', this.onWindowResize)\n this.onWindowResize()\n } else {\n this.wrapperHeight = this.wrapperNode.offsetHeight\n this.wrapperWidth = this.wrapperNode.offsetWidth\n\n //observe wrapper node size\n this.wrapperObserver = new ResizeObserver(this.onWrapperResize)\n this.wrapperObserver.observe(this.wrapperNode)\n }\n\n this.contentHeight = this.contentNode.offsetHeight\n this.contentWidth = this.contentNode.offsetWidth\n\n //observe content node size\n this.contentObserver = new ResizeObserver(this.onContentResize)\n this.contentObserver.observe(this.contentNode)\n\n //set initial scroll position\n this.targetScroll =\n this.scroll =\n this.lastScroll =\n this.wrapperNode[this.scrollProperty]\n\n this.animate = new Animate()\n\n const platform =\n navigator?.userAgentData?.platform || navigator?.platform || 'unknown'\n\n // listen and normalize wheel event cross-browser\n this.virtualScroll = new VirtualScroll({\n el: this.wrapperNode,\n firefoxMultiplier: 50,\n mouseMultiplier:\n this.mouseMultiplier * (platform.includes('Win') ? 0.84 : 0.4),\n touchMultiplier: this.touchMultiplier,\n passive: false,\n })\n\n this.virtualScroll.on(this.onVirtualScroll)\n }\n\n get scrollProperty() {\n let property\n if (this.wrapperNode === window) {\n property = this.direction === 'horizontal' ? 'scrollX' : 'scrollY'\n } else {\n property = this.direction === 'horizontal' ? 'scrollLeft' : 'scrollTop'\n }\n return property\n }\n\n start() {\n this.stopped = false\n }\n\n stop() {\n this.stopped = true\n this.animate.stop()\n }\n\n destroy() {\n if (this.wrapperNode === window) {\n this.wrapperNode.removeEventListener('resize', this.onWindowResize)\n }\n this.wrapperNode.removeEventListener('scroll', this.onScroll)\n\n this.virtualScroll.destroy()\n this.wrapperObserver?.disconnect()\n this.contentObserver.disconnect()\n }\n\n onWindowResize = () => {\n this.wrapperWidth = window.innerWidth\n this.wrapperHeight = window.innerHeight\n }\n\n onWrapperResize = ([entry]) => {\n if (entry) {\n const rect = entry.contentRect\n this.wrapperWidth = rect.width\n this.wrapperHeight = rect.height\n }\n }\n\n onContentResize = ([entry]) => {\n if (entry) {\n const rect = entry.contentRect\n this.contentWidth = rect.width\n this.contentHeight = rect.height\n }\n }\n\n get limit() {\n return this.direction === 'horizontal'\n ? this.contentWidth - this.wrapperWidth\n : this.contentHeight - this.wrapperHeight\n }\n\n onVirtualScroll = ({ deltaY, deltaX, originalEvent: e }) => {\n const preventScroll = !!e\n .composedPath()\n .find(\n (node) => node.hasAttribute && node.hasAttribute('data-lenis-prevent')\n )\n\n if (e.ctrlKey || preventScroll) return\n\n // switch to smooth if event is touch and if smoothTouch=true\n this.smooth = !!e.changedTouches ? this.smoothTouch : this.options.smooth\n\n if (this.stopped) {\n e.preventDefault()\n return\n }\n\n if (!this.smooth) return\n\n // fix wheel holding scroll https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\n if (e.buttons === 4) return\n\n // prevent native wheel scrolling\n if (this.smooth) e.preventDefault()\n\n let delta = 0\n if (this.gestureDirection === 'both') {\n delta = deltaX + deltaY\n } else if (this.gestureDirection === 'horizontal') {\n delta = deltaX\n } else {\n // vertical\n delta = deltaY\n }\n\n this.targetScroll -= delta\n // this.targetScroll = clamp(0, this.targetScroll, this.limit)\n\n this.scrollTo(this.targetScroll)\n }\n\n raf(now) {\n const deltaTime = now - (this.now || 0)\n this.now = now\n\n if (this.stopped || !this.smooth) return\n\n this.lastScroll = this.scroll\n\n // where this.scroll is updated\n this.animate.raf(deltaTime * 0.001)\n\n if (this.scroll === this.targetScroll) {\n // if target reached velocity should be 0\n this.lastScroll = this.scroll\n }\n\n if (this.isScrolling) {\n this.setScroll(this.scroll)\n this.notify()\n }\n\n this.isScrolling = this.scroll !== this.targetScroll\n }\n\n get velocity() {\n return this.scroll - this.lastScroll\n }\n\n setScroll(value) {\n let scroll = this.infinite ? modulo(value, this.limit) : value\n\n this.direction === 'horizontal'\n ? this.wrapperNode.scrollTo(scroll, 0)\n : this.wrapperNode.scrollTo(0, scroll)\n }\n\n onScroll = (e) => {\n // if isScrolling false we can consider user isn't scrolling with wheel (cmd+F, keyboard or whatever). So we must scroll to value immediately\n if (!this.isScrolling || !this.smooth) {\n // where native scroll happens\n this.targetScroll =\n this.scroll =\n this.lastScroll =\n this.wrapperNode[this.scrollProperty]\n\n this.notify()\n }\n }\n\n notify() {\n let scroll = this.infinite ? modulo(this.scroll, this.limit) : this.scroll\n\n let direction = this.lastScroll < scroll ? 1 : -1\n\n this.emit('scroll', {\n scroll,\n limit: this.limit,\n velocity: this.velocity,\n direction,\n progress: scroll / this.limit,\n })\n }\n\n scrollTo(\n target,\n {\n offset = 0,\n immediate = false,\n duration = this.duration,\n easing = this.easing,\n } = {}\n ) {\n if (target === undefined || target === null) return\n let value\n\n if (typeof target === 'number') {\n value = target\n } else if (target === 'top' || target === '#top') {\n value = 0\n } else if (target === 'bottom') {\n value = this.limit\n } else {\n let node\n\n if (typeof target === 'string') {\n // CSS selector\n node = document.querySelector(target)\n } else if (target?.nodeType) {\n // Node element\n node = target\n } else {\n return\n }\n\n if (!node) return\n let wrapperOffset = 0\n\n if (this.wrapperNode !== window) {\n const wrapperRect = this.wrapperNode.getBoundingClientRect()\n wrapperOffset =\n this.direction === 'horizontal' ? wrapperRect.left : wrapperRect.top\n }\n\n const rect = node.getBoundingClientRect()\n\n value =\n (this.direction === 'horizontal' ? rect.left : rect.top) +\n this.scroll -\n wrapperOffset\n }\n\n value += offset\n\n if (this.infinite) {\n this.targetScroll = value\n } else {\n this.targetScroll = clamp(0, value, this.limit)\n }\n\n if (!this.smooth || immediate) {\n this.scroll = this.lastScroll = this.targetScroll\n this.setScroll(this.targetScroll)\n } else {\n this.animate.to(this, {\n duration,\n easing,\n scroll: this.targetScroll,\n })\n }\n }\n}\n"],"names":["modulo","value","max","v","Animate","_proto","prototype","to","target","_temp","_this","this","_ref","_ref$duration","duration","easing","_ref$easing","t","keys","_objectWithoutPropertiesLoose","_excluded","fromKeys","toKeys","Object","forEach","key","currentTime","isRunning","stop","raf","deltaTime","Math","min","progress","from","_this2","_createClass","get","Lenis","_EventEmitter","_temp2","_navigator","_navigator$userAgentD","_navigator2","_this3","_ref2","_ref2$duration","_ref2$easing","pow","_ref2$smooth","smooth","mouseMultiplier","_ref2$mouseMultiplier","smoothTouch","_ref2$smoothTouch","touchMultiplier","_ref2$touchMultiplier","direction","_ref2$direction","_ref2$gestureDirectio","gestureDirection","_ref2$infinite","infinite","wrapper","_ref2$wrapper","window","content","_ref2$content","document","body","onWindowResize","wrapperWidth","innerWidth","wrapperHeight","innerHeight","onWrapperResize","_ref3","entry","contentRect","rect","width","height","onContentResize","_ref4","contentWidth","contentHeight","onVirtualScroll","_ref5","deltaY","deltaX","e","originalEvent","preventScroll","composedPath","find","node","hasAttribute","ctrlKey","changedTouches","options","stopped","preventDefault","buttons","targetScroll","scrollTo","onScroll","isScrolling","scroll","lastScroll","wrapperNode","scrollProperty","notify","lenisVersion","contentNode","addEventListener","offsetHeight","offsetWidth","wrapperObserver","ResizeObserver","observe","contentObserver","animate","platform","navigator","userAgentData","virtualScroll","VirtualScroll","el","firefoxMultiplier","includes","passive","on","start","destroy","removeEventListener","_this$wrapperObserver","disconnect","_proto2","now","setScroll","limit","emit","velocity","_temp3","_ref6","_ref6$offset","offset","immediate","_ref6$immediate","_ref6$duration","_ref6$easing","querySelector","nodeType","getBoundingClientRect","wrapperOffset","wrapperRect","left","top","EventEmitter"],"mappings":"yqBAgBgBA,SAAAA,EAAOC,EAAOC,GAC5B,IAAKC,EAAGF,EAAQC,EAKhB,OAJIC,EAAI,IACNA,GAAKD,GAITC,CAAA,6BClBaC,eAAA,WAAA,SAAAA,IAAA,CAAA,IAAAC,EAAAD,EAAAE,iBAAAD,EACXE,GAAA,SAAGC,EAA2DC,GAAA,IAAAC,EAAAC,KA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AEA,IAAKuF,EAAM,OACX,MAAoB,EAEpB,GAAIpF,KAAKkG,cAAgB5C,OAAQ,CAC/B,MAAoBtD,KAAKkG,YAAY4C,wBACrCC,EACqB,eAAnB/I,KAAK8C,UAA6BkG,EAAYC,KAAOD,EAAYE,GACrE,CAEA,MAAa9D,EAAK0D,wBAElBxJ,GACsB,eAAnBU,KAAK8C,UAA6BsB,EAAK6E,KAAO7E,EAAK8E,KACpDlJ,KAAKgG,OACL+C,CACJ,CAEAzJ,GAASiJ,EAGPvI,KAAK4F,aADH5F,KAAKmD,SACa7D,EDtXjB8B,KAAK7B,ICwXkB,EDxXT6B,KAAKC,ICwXO/B,EAAOU,KAAKiI,SAGtCjI,KAAKuC,QAAUiG,GAClBxI,KAAKgG,OAAShG,KAAKiG,WAAajG,KAAK4F,aACrC5F,KAAKgI,UAAUhI,KAAK4F,eAEpB5F,KAAK8G,QAAQlH,GAAGI,KAAM,CACpBG,SAAAA,EACAC,OAAAA,EACA4F,OAAQhG,KAAK4F,cArDjB,CAwDF,EAACnE,EAAAE,EAAA,CAAA,CAAAb,IAAA,iBAAAY,IAnOD,WAOE,OALI1B,KAAKkG,cAAgB5C,OACO,eAAnBtD,KAAK8C,UAA6B,UAAY,UAE3B,eAAnB9C,KAAK8C,UAA6B,aAAe,WAGhE,GA2CA,CAAAhC,IAAA,QAAAY,IAAA,WACE,MAA0B,oBAAdoB,UACR9C,KAAKyE,aAAezE,KAAK4D,aACzB5D,KAAK0E,cAAgB1E,KAAK8D,aAChC,GAmEA,CAAAhD,IAAA,WAAAY,IAAA,WACE,YAAYsE,OAAShG,KAAKiG,UAC5B,KAACtE,CAAA,CA1OuB,CAASwH"} \ No newline at end of file diff --git a/dist/lenis.modern.mjs b/dist/lenis.modern.mjs index 447c7ecd..ff88201b 100644 --- a/dist/lenis.modern.mjs +++ b/dist/lenis.modern.mjs @@ -1,2 +1,2 @@ -import t from"tiny-emitter";import i from"virtual-scroll";function e(){return e=Object.assign?Object.assign.bind():function(t){for(var i=1;it)}=i,n=function(t,i){if(null==t)return{};var e,s,r={},o=Object.keys(t);for(s=0;s=0||(r[e]=t[e]);return r}(i,r);this.target=t,this.fromKeys=e({},n),this.toKeys=e({},n),this.keys=Object.keys(e({},n)),this.keys.forEach(i=>{this.fromKeys[i]=t[i]}),this.duration=s,this.easing=o,this.currentTime=0,this.isRunning=!0}stop(){this.isRunning=!1}raf(t){if(!this.isRunning)return;this.currentTime=Math.min(this.currentTime+t,this.duration);const i=this.easing(this.progress);this.keys.forEach(t=>{const e=this.fromKeys[t];this.target[t]=e+(this.toKeys[t]-e)*i}),1===i&&this.stop()}get progress(){return this.currentTime/this.duration}}class n extends t{constructor({duration:t=1.2,easing:e=(t=>Math.min(1,1.001-Math.pow(2,-10*t))),smooth:s=!0,mouseMultiplier:r=1,smoothTouch:n=!1,touchMultiplier:h=2,direction:l="vertical",gestureDirection:c="vertical",infinite:a=!1,wrapper:p=window,content:u=document.body}={}){var d,f,g;super(),this.onWindowResize=()=>{this.wrapperWidth=window.innerWidth,this.wrapperHeight=window.innerHeight},this.onWrapperResize=([t])=>{if(t){const i=t.contentRect;this.wrapperWidth=i.width,this.wrapperHeight=i.height}},this.onContentResize=([t])=>{if(t){const i=t.contentRect;this.contentWidth=i.width,this.contentHeight=i.height}},this.onVirtualScroll=({deltaY:t,deltaX:i,originalEvent:e})=>{const s=!!e.composedPath().find(t=>t.hasAttribute&&t.hasAttribute("data-lenis-prevent"));if(e.ctrlKey||s)return;if(this.smooth=e.changedTouches?this.smoothTouch:this.options.smooth,this.stopped)return void e.preventDefault();if(!this.smooth)return;if(4===e.buttons)return;this.smooth&&e.preventDefault();let r=0;r="both"===this.gestureDirection?i+t:"horizontal"===this.gestureDirection?i:t,this.targetScroll-=r,this.scrollTo(this.targetScroll)},this.onScroll=t=>{this.isScrolling&&this.smooth||(this.targetScroll=this.scroll=this.lastScroll=this.wrapperNode[this.scrollProperty],this.notify())},window.lenisVersion="0.2.19",this.options={duration:t,easing:e,smooth:s,mouseMultiplier:r,smoothTouch:n,touchMultiplier:h,direction:l,gestureDirection:c,infinite:a,wrapper:p,content:u},this.duration=t,this.easing=e,this.smooth=s,this.mouseMultiplier=r,this.smoothTouch=n,this.touchMultiplier=h,this.direction=l,this.gestureDirection=c,this.infinite=a,this.wrapperNode=p,this.contentNode=u,this.wrapperNode.addEventListener("scroll",this.onScroll),this.wrapperNode===window?(this.wrapperNode.addEventListener("resize",this.onWindowResize),this.onWindowResize()):(this.wrapperHeight=this.wrapperNode.offsetHeight,this.wrapperWidth=this.wrapperNode.offsetWidth,this.wrapperObserver=new ResizeObserver(this.onWrapperResize),this.wrapperObserver.observe(this.wrapperNode)),this.contentHeight=this.contentNode.offsetHeight,this.contentWidth=this.contentNode.offsetWidth,this.contentObserver=new ResizeObserver(this.onContentResize),this.contentObserver.observe(this.contentNode),this.targetScroll=this.scroll=this.lastScroll=this.wrapperNode[this.scrollProperty],this.animate=new o;const w=(null==(d=navigator)||null==(f=d.userAgentData)?void 0:f.platform)||(null==(g=navigator)?void 0:g.platform)||"unknown";this.virtualScroll=new i({el:this.wrapperNode,firefoxMultiplier:50,mouseMultiplier:this.mouseMultiplier*(w.includes("Win")?.84:.4),useKeyboard:!1,touchMultiplier:this.touchMultiplier,useTouch:!0,passive:!1}),this.virtualScroll.on(this.onVirtualScroll)}get scrollProperty(){let t;return t=this.wrapperNode===window?"horizontal"===this.direction?"scrollX":"scrollY":"horizontal"===this.direction?"scrollLeft":"scrollTop",t}start(){this.stopped=!1}stop(){this.stopped=!0,this.animate.stop()}destroy(){var t;this.wrapperNode===window&&this.wrapperNode.removeEventListener("resize",this.onWindowResize),this.wrapperNode.removeEventListener("scroll",this.onScroll),this.virtualScroll.destroy(),null==(t=this.wrapperObserver)||t.disconnect(),this.contentObserver.disconnect()}get limit(){return"horizontal"===this.direction?this.contentWidth-this.wrapperWidth:this.contentHeight-this.wrapperHeight}raf(t){const i=t-(this.now||0);this.now=t,!this.stopped&&this.smooth&&(this.lastScroll=this.scroll,this.animate.raf(.001*i),this.scroll===this.targetScroll&&(this.lastScroll=this.scroll),this.isScrolling&&(this.setScroll(this.scroll),this.notify()),this.isScrolling=this.scroll!==this.targetScroll)}get velocity(){return this.scroll-this.lastScroll}setScroll(t){let i=this.infinite?s(t,this.limit):t;"horizontal"===this.direction?this.wrapperNode.scrollTo(i,0):this.wrapperNode.scrollTo(0,i)}notify(){let t=this.infinite?s(this.scroll,this.limit):this.scroll;this.emit("scroll",{scroll:t,limit:this.limit,velocity:this.velocity,direction:this.direction,progress:t/this.limit})}scrollTo(t,{offset:i=0,immediate:e=!1,duration:s=this.duration,easing:r=this.easing}={}){if(null==t)return;let o;if("number"==typeof t)o=t;else if("top"===t||"#top"===t)o=0;else if("bottom"===t)o=this.limit;else{let i;if("string"==typeof t)i=document.querySelector(t);else{if(null==t||!t.nodeType)return;i=t}if(!i)return;let e=0;if(this.wrapperNode!==window){const t=this.wrapperNode.getBoundingClientRect();e="horizontal"===this.direction?t.left:t.top}const s=i.getBoundingClientRect();o=("horizontal"===this.direction?s.left:s.top)+this.scroll-e}o+=i,this.targetScroll=this.infinite?o:Math.max(0,Math.min(o,this.limit)),!this.smooth||e?(this.scroll=this.lastScroll=this.targetScroll,this.setScroll(this.targetScroll)):this.animate.to(this,{duration:s,easing:r,scroll:this.targetScroll})}}export{n as default}; +import t from"tiny-emitter";import i from"virtual-scroll";function e(){return e=Object.assign?Object.assign.bind():function(t){for(var i=1;it)}=i,n=function(t,i){if(null==t)return{};var e,s,r={},o=Object.keys(t);for(s=0;s=0||(r[e]=t[e]);return r}(i,r);this.target=t,this.fromKeys=e({},n),this.toKeys=e({},n),this.keys=Object.keys(e({},n)),this.keys.forEach(i=>{this.fromKeys[i]=t[i]}),this.duration=s,this.easing=o,this.currentTime=0,this.isRunning=!0}stop(){this.isRunning=!1}raf(t){if(!this.isRunning)return;this.currentTime=Math.min(this.currentTime+t,this.duration);const i=this.easing(this.progress);this.keys.forEach(t=>{const e=this.fromKeys[t];this.target[t]=e+(this.toKeys[t]-e)*i}),1===i&&this.stop()}get progress(){return this.currentTime/this.duration}}class n extends t{constructor({duration:t=1.2,easing:e=(t=>Math.min(1,1.001-Math.pow(2,-10*t))),smooth:s=!0,mouseMultiplier:r=1,smoothTouch:n=!1,touchMultiplier:h=2,direction:l="vertical",gestureDirection:c="vertical",infinite:a=!1,wrapper:p=window,content:d=document.body}={}){var u,f,g;super(),this.onWindowResize=()=>{this.wrapperWidth=window.innerWidth,this.wrapperHeight=window.innerHeight},this.onWrapperResize=([t])=>{if(t){const i=t.contentRect;this.wrapperWidth=i.width,this.wrapperHeight=i.height}},this.onContentResize=([t])=>{if(t){const i=t.contentRect;this.contentWidth=i.width,this.contentHeight=i.height}},this.onVirtualScroll=({deltaY:t,deltaX:i,originalEvent:e})=>{const s=!!e.composedPath().find(t=>t.hasAttribute&&t.hasAttribute("data-lenis-prevent"));if(e.ctrlKey||s)return;if(this.smooth=e.changedTouches?this.smoothTouch:this.options.smooth,this.stopped)return void e.preventDefault();if(!this.smooth)return;if(4===e.buttons)return;this.smooth&&e.preventDefault();let r=0;r="both"===this.gestureDirection?i+t:"horizontal"===this.gestureDirection?i:t,this.targetScroll-=r,this.scrollTo(this.targetScroll)},this.onScroll=t=>{this.isScrolling&&this.smooth||(this.targetScroll=this.scroll=this.lastScroll=this.wrapperNode[this.scrollProperty],this.notify())},window.lenisVersion="0.2.20",this.options={duration:t,easing:e,smooth:s,mouseMultiplier:r,smoothTouch:n,touchMultiplier:h,direction:l,gestureDirection:c,infinite:a,wrapper:p,content:d},this.duration=t,this.easing=e,this.smooth=s,this.mouseMultiplier=r,this.smoothTouch=n,this.touchMultiplier=h,this.direction=l,this.gestureDirection=c,this.infinite=a,this.wrapperNode=p,this.contentNode=d,this.wrapperNode.addEventListener("scroll",this.onScroll),this.wrapperNode===window?(this.wrapperNode.addEventListener("resize",this.onWindowResize),this.onWindowResize()):(this.wrapperHeight=this.wrapperNode.offsetHeight,this.wrapperWidth=this.wrapperNode.offsetWidth,this.wrapperObserver=new ResizeObserver(this.onWrapperResize),this.wrapperObserver.observe(this.wrapperNode)),this.contentHeight=this.contentNode.offsetHeight,this.contentWidth=this.contentNode.offsetWidth,this.contentObserver=new ResizeObserver(this.onContentResize),this.contentObserver.observe(this.contentNode),this.targetScroll=this.scroll=this.lastScroll=this.wrapperNode[this.scrollProperty],this.animate=new o;const w=(null==(u=navigator)||null==(f=u.userAgentData)?void 0:f.platform)||(null==(g=navigator)?void 0:g.platform)||"unknown";this.virtualScroll=new i({el:this.wrapperNode,firefoxMultiplier:50,mouseMultiplier:this.mouseMultiplier*(w.includes("Win")?.84:.4),touchMultiplier:this.touchMultiplier,passive:!1}),this.virtualScroll.on(this.onVirtualScroll)}get scrollProperty(){let t;return t=this.wrapperNode===window?"horizontal"===this.direction?"scrollX":"scrollY":"horizontal"===this.direction?"scrollLeft":"scrollTop",t}start(){this.stopped=!1}stop(){this.stopped=!0,this.animate.stop()}destroy(){var t;this.wrapperNode===window&&this.wrapperNode.removeEventListener("resize",this.onWindowResize),this.wrapperNode.removeEventListener("scroll",this.onScroll),this.virtualScroll.destroy(),null==(t=this.wrapperObserver)||t.disconnect(),this.contentObserver.disconnect()}get limit(){return"horizontal"===this.direction?this.contentWidth-this.wrapperWidth:this.contentHeight-this.wrapperHeight}raf(t){const i=t-(this.now||0);this.now=t,!this.stopped&&this.smooth&&(this.lastScroll=this.scroll,this.animate.raf(.001*i),this.scroll===this.targetScroll&&(this.lastScroll=this.scroll),this.isScrolling&&(this.setScroll(this.scroll),this.notify()),this.isScrolling=this.scroll!==this.targetScroll)}get velocity(){return this.scroll-this.lastScroll}setScroll(t){let i=this.infinite?s(t,this.limit):t;"horizontal"===this.direction?this.wrapperNode.scrollTo(i,0):this.wrapperNode.scrollTo(0,i)}notify(){let t=this.infinite?s(this.scroll,this.limit):this.scroll;this.emit("scroll",{scroll:t,limit:this.limit,velocity:this.velocity,direction:this.lastScroll t, ...keys } = {}) {\r\n this.target = target\r\n this.fromKeys = { ...keys }\r\n this.toKeys = { ...keys }\r\n this.keys = Object.keys({ ...keys })\r\n\r\n // get initial values\r\n this.keys.forEach((key) => {\r\n this.fromKeys[key] = target[key]\r\n })\r\n\r\n this.duration = duration\r\n this.easing = easing\r\n this.currentTime = 0\r\n this.isRunning = true\r\n }\r\n\r\n stop() {\r\n this.isRunning = false\r\n }\r\n\r\n raf(deltaTime) {\r\n if (!this.isRunning) return\r\n\r\n this.currentTime = Math.min(this.currentTime + deltaTime, this.duration)\r\n\r\n const progress = this.easing(this.progress)\r\n\r\n this.keys.forEach((key) => {\r\n const from = this.fromKeys[key]\r\n const to = this.toKeys[key]\r\n\r\n const value = from + (to - from) * progress\r\n\r\n this.target[key] = value\r\n })\r\n\r\n if (progress === 1) {\r\n this.stop()\r\n }\r\n }\r\n\r\n get progress() {\r\n return this.currentTime / this.duration\r\n }\r\n}\r\n\r\nexport default class Lenis extends EventEmitter {\r\n /**\r\n * @typedef {(t: number) => number} EasingFunction\r\n * @typedef {'vertical' | 'horizontal'} Direction\r\n * @typedef {'vertical' | 'horizontal' | 'both'} GestureDirection\r\n *\r\n * @typedef LenisOptions\r\n * @property {number} [duration]\r\n * @property {EasingFunction} [easing]\r\n * @property {boolean} [smooth]\r\n * @property {number} [mouseMultiplier]\r\n * @property {boolean} [smoothTouch]\r\n * @property {number} [touchMultiplier]\r\n * @property {Direction} [direction]\r\n * @property {GestureDirection} [gestureDirection]\r\n * @property {boolean} [infinite]\r\n * @property {Window | HTMLElement} [wrapper]\r\n * @property {HTMLElement} [content]\r\n *\r\n * @param {LenisOptions}\r\n */\r\n constructor({\r\n duration = 1.2,\r\n easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), // https://www.desmos.com/calculator/k2tgx2kn8t\r\n smooth = true,\r\n mouseMultiplier = 1,\r\n smoothTouch = false,\r\n touchMultiplier = 2,\r\n direction = 'vertical', // vertical, horizontal\r\n gestureDirection = 'vertical', // vertical, horizontal, both\r\n infinite = false,\r\n wrapper = window,\r\n content = document.body,\r\n } = {}) {\r\n super()\r\n\r\n window.lenisVersion = version\r\n\r\n this.options = {\r\n duration,\r\n easing,\r\n smooth,\r\n mouseMultiplier,\r\n smoothTouch,\r\n touchMultiplier,\r\n direction,\r\n gestureDirection,\r\n infinite,\r\n wrapper,\r\n content,\r\n }\r\n\r\n this.duration = duration\r\n this.easing = easing\r\n this.smooth = smooth\r\n this.mouseMultiplier = mouseMultiplier\r\n this.smoothTouch = smoothTouch\r\n this.touchMultiplier = touchMultiplier\r\n this.direction = direction\r\n this.gestureDirection = gestureDirection\r\n this.infinite = infinite\r\n this.wrapperNode = wrapper\r\n this.contentNode = content\r\n\r\n this.wrapperNode.addEventListener('scroll', this.onScroll)\r\n\r\n //observe wrapper node size\r\n if (this.wrapperNode === window) {\r\n this.wrapperNode.addEventListener('resize', this.onWindowResize)\r\n this.onWindowResize()\r\n } else {\r\n this.wrapperHeight = this.wrapperNode.offsetHeight\r\n this.wrapperWidth = this.wrapperNode.offsetWidth\r\n\r\n //observe wrapper node size\r\n this.wrapperObserver = new ResizeObserver(this.onWrapperResize)\r\n this.wrapperObserver.observe(this.wrapperNode)\r\n }\r\n\r\n this.contentHeight = this.contentNode.offsetHeight\r\n this.contentWidth = this.contentNode.offsetWidth\r\n\r\n //observe content node size\r\n this.contentObserver = new ResizeObserver(this.onContentResize)\r\n this.contentObserver.observe(this.contentNode)\r\n\r\n //set initial scroll position\r\n this.targetScroll =\r\n this.scroll =\r\n this.lastScroll =\r\n this.wrapperNode[this.scrollProperty]\r\n\r\n this.animate = new Animate()\r\n\r\n const platform =\r\n navigator?.userAgentData?.platform || navigator?.platform || 'unknown'\r\n\r\n // listen and normalize wheel event cross-browser\r\n this.virtualScroll = new VirtualScroll({\r\n el: this.wrapperNode,\r\n firefoxMultiplier: 50,\r\n mouseMultiplier:\r\n this.mouseMultiplier * (platform.includes('Win') ? 0.84 : 0.4),\r\n useKeyboard: false,\r\n touchMultiplier: this.touchMultiplier,\r\n useTouch: true,\r\n passive: false,\r\n })\r\n\r\n this.virtualScroll.on(this.onVirtualScroll)\r\n }\r\n\r\n get scrollProperty() {\r\n let property\r\n if (this.wrapperNode === window) {\r\n property = this.direction === 'horizontal' ? 'scrollX' : 'scrollY'\r\n } else {\r\n property = this.direction === 'horizontal' ? 'scrollLeft' : 'scrollTop'\r\n }\r\n return property\r\n }\r\n\r\n start() {\r\n this.stopped = false\r\n }\r\n\r\n stop() {\r\n this.stopped = true\r\n this.animate.stop()\r\n }\r\n\r\n destroy() {\r\n if (this.wrapperNode === window) {\r\n this.wrapperNode.removeEventListener('resize', this.onWindowResize)\r\n }\r\n this.wrapperNode.removeEventListener('scroll', this.onScroll)\r\n\r\n this.virtualScroll.destroy()\r\n this.wrapperObserver?.disconnect()\r\n this.contentObserver.disconnect()\r\n }\r\n\r\n onWindowResize = () => {\r\n this.wrapperWidth = window.innerWidth\r\n this.wrapperHeight = window.innerHeight\r\n }\r\n\r\n onWrapperResize = ([entry]) => {\r\n if (entry) {\r\n const rect = entry.contentRect\r\n this.wrapperWidth = rect.width\r\n this.wrapperHeight = rect.height\r\n }\r\n }\r\n\r\n onContentResize = ([entry]) => {\r\n if (entry) {\r\n const rect = entry.contentRect\r\n this.contentWidth = rect.width\r\n this.contentHeight = rect.height\r\n }\r\n }\r\n\r\n get limit() {\r\n return this.direction === 'horizontal'\r\n ? this.contentWidth - this.wrapperWidth\r\n : this.contentHeight - this.wrapperHeight\r\n }\r\n\r\n onVirtualScroll = ({ deltaY, deltaX, originalEvent: e }) => {\r\n const preventScroll = !!e\r\n .composedPath()\r\n .find(\r\n (node) => node.hasAttribute && node.hasAttribute('data-lenis-prevent')\r\n )\r\n\r\n if (e.ctrlKey || preventScroll) return\r\n\r\n // switch to smooth if event is touch and if smoothTouch=true\r\n this.smooth = !!e.changedTouches ? this.smoothTouch : this.options.smooth\r\n\r\n if (this.stopped) {\r\n e.preventDefault()\r\n return\r\n }\r\n\r\n if (!this.smooth) return\r\n\r\n // fix wheel holding scroll https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\r\n if (e.buttons === 4) return\r\n\r\n // prevent native wheel scrolling\r\n if (this.smooth) e.preventDefault()\r\n\r\n let delta = 0\r\n if (this.gestureDirection === 'both') {\r\n delta = deltaX + deltaY\r\n } else if (this.gestureDirection === 'horizontal') {\r\n delta = deltaX\r\n } else {\r\n // vertical\r\n delta = deltaY\r\n }\r\n\r\n this.targetScroll -= delta\r\n // this.targetScroll = clamp(0, this.targetScroll, this.limit)\r\n\r\n this.scrollTo(this.targetScroll)\r\n }\r\n\r\n raf(now) {\r\n const deltaTime = now - (this.now || 0)\r\n this.now = now\r\n\r\n if (this.stopped || !this.smooth) return\r\n\r\n this.lastScroll = this.scroll\r\n\r\n // where this.scroll is updated\r\n this.animate.raf(deltaTime * 0.001)\r\n\r\n if (this.scroll === this.targetScroll) {\r\n // if target reached velocity should be 0\r\n this.lastScroll = this.scroll\r\n }\r\n\r\n if (this.isScrolling) {\r\n this.setScroll(this.scroll)\r\n this.notify()\r\n }\r\n\r\n this.isScrolling = this.scroll !== this.targetScroll\r\n }\r\n\r\n get velocity() {\r\n return this.scroll - this.lastScroll\r\n }\r\n\r\n setScroll(value) {\r\n let scroll = this.infinite ? modulo(value, this.limit) : value\r\n\r\n this.direction === 'horizontal'\r\n ? this.wrapperNode.scrollTo(scroll, 0)\r\n : this.wrapperNode.scrollTo(0, scroll)\r\n }\r\n\r\n onScroll = (e) => {\r\n // if isScrolling false we can consider user isn't scrolling with wheel (cmd+F, keyboard or whatever). So we must scroll to value immediately\r\n if (!this.isScrolling || !this.smooth) {\r\n // where native scroll happens\r\n this.targetScroll =\r\n this.scroll =\r\n this.lastScroll =\r\n this.wrapperNode[this.scrollProperty]\r\n\r\n this.notify()\r\n }\r\n }\r\n\r\n notify() {\r\n let scroll = this.infinite ? modulo(this.scroll, this.limit) : this.scroll\r\n\r\n this.emit('scroll', {\r\n scroll,\r\n limit: this.limit,\r\n velocity: this.velocity,\r\n direction: this.direction,\r\n progress: scroll / this.limit,\r\n })\r\n }\r\n\r\n scrollTo(\r\n target,\r\n {\r\n offset = 0,\r\n immediate = false,\r\n duration = this.duration,\r\n easing = this.easing,\r\n } = {}\r\n ) {\r\n if (target === undefined || target === null) return\r\n let value\r\n\r\n if (typeof target === 'number') {\r\n value = target\r\n } else if (target === 'top' || target === '#top') {\r\n value = 0\r\n } else if (target === 'bottom') {\r\n value = this.limit\r\n } else {\r\n let node\r\n\r\n if (typeof target === 'string') {\r\n // CSS selector\r\n node = document.querySelector(target)\r\n } else if (target?.nodeType) {\r\n // Node element\r\n node = target\r\n } else {\r\n return\r\n }\r\n\r\n if (!node) return\r\n let wrapperOffset = 0\r\n\r\n if (this.wrapperNode !== window) {\r\n const wrapperRect = this.wrapperNode.getBoundingClientRect()\r\n wrapperOffset =\r\n this.direction === 'horizontal' ? wrapperRect.left : wrapperRect.top\r\n }\r\n\r\n const rect = node.getBoundingClientRect()\r\n\r\n value =\r\n (this.direction === 'horizontal' ? rect.left : rect.top) +\r\n this.scroll -\r\n wrapperOffset\r\n }\r\n\r\n value += offset\r\n\r\n if (this.infinite) {\r\n this.targetScroll = value\r\n } else {\r\n this.targetScroll = clamp(0, value, this.limit)\r\n }\r\n\r\n if (!this.smooth || immediate) {\r\n this.scroll = this.lastScroll = this.targetScroll\r\n this.setScroll(this.targetScroll)\r\n } else {\r\n this.animate.to(this, {\r\n duration,\r\n easing,\r\n scroll: this.targetScroll,\r\n })\r\n }\r\n }\r\n}\r\n"],"names":["modulo","value","max","v","_excluded","to","target","_ref","duration","easing","t","keys","this","fromKeys","_extends","toKeys","Object","forEach","key","currentTime","isRunning","stop","raf","deltaTime","Math","min","progress","from","EventEmitter","constructor","pow","smooth","mouseMultiplier","smoothTouch","touchMultiplier","direction","gestureDirection","infinite","wrapper","window","content","document","body","_navigator","_navigator$userAgentD","_navigator2","super","onWindowResize","wrapperWidth","innerWidth","wrapperHeight","innerHeight","onWrapperResize","entry","rect","contentRect","width","height","onContentResize","contentWidth","contentHeight","onVirtualScroll","deltaY","deltaX","originalEvent","e","composedPath","find","node","hasAttribute","ctrlKey","preventScroll","changedTouches","options","stopped","preventDefault","buttons","delta","targetScroll","scrollTo","onScroll","isScrolling","scroll","lastScroll","wrapperNode","scrollProperty","notify","lenisVersion","contentNode","addEventListener","offsetHeight","offsetWidth","wrapperObserver","ResizeObserver","observe","contentObserver","animate","navigator","userAgentData","platform","virtualScroll","VirtualScroll","el","firefoxMultiplier","includes","useKeyboard","useTouch","passive","on","property","start","destroy","_this$wrapperObserver","removeEventListener","disconnect","limit","now","setScroll","emit","velocity","offset","immediate","querySelector","nodeType","wrapperRect","getBoundingClientRect","wrapperOffset","left","top"],"mappings":"8RAgBO,SAAAA,EAAgBC,EAAOC,GAC5B,IAAKC,EAAGF,EAAQC,EAKhB,OAJIC,EAAI,IACNA,GAAKD,GAIRC,CAAA,CCvBD,MAAAC,EAAA,CAAA,WAAA,UAKA,QACEC,GAAGC,EAAQC,EAA+C,QAA/CC,SAAEA,EAAW,EAAbC,OAAgBA,EAAUC,IAAMA,IAAMC,EAAAA,0IAC/CC,KAAKN,OAASA,EACdM,KAAKC,SAALC,EAAA,CAAA,EAAqBH,GACrBC,KAAKG,OAALD,EAAA,CAAA,EAAmBH,GACnBC,KAAKD,KAAOK,OAAOL,UAAUA,IAG7BC,KAAKD,KAAKM,QAASC,IACjBN,KAAKC,SAASK,GAAOZ,EAAOY,EAAD,GAG7BN,KAAKJ,SAAWA,EAChBI,KAAKH,OAASA,EACdG,KAAKO,YAAc,EACnBP,KAAKQ,WAAY,CAClB,CAEDC,OACET,KAAKQ,WAAY,CAClB,CAEDE,IAAIC,GACF,IAAKX,KAAKQ,UAAW,OAErBR,KAAKO,YAAcK,KAAKC,IAAIb,KAAKO,YAAcI,EAAWX,KAAKJ,UAE/D,MAAMkB,EAAWd,KAAKH,OAAOG,KAAKc,UAElCd,KAAKD,KAAKM,QAASC,IACjB,QAAaN,KAAKC,SAASK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AAGhH,KAAKwE,YAAYyC,wBACrCC,EACqB,eAAnBlH,KAAKuB,UAA6ByF,EAAYG,KAAOH,EAAYI,GACpE,CAED,MAAM1E,EAAOc,EAAKyD,wBAElB5H,GACsB,eAAnBW,KAAKuB,UAA6BmB,EAAKyE,KAAOzE,EAAK0E,KACpDpH,KAAKsE,OACL4C,CACH,CAED7H,GAASuH,EAGP5G,KAAKkE,aADHlE,KAAKyB,SACapC,EDtXjBuB,KAAKtB,ICwXkB,EDxXTsB,KAAKC,ICwXOxB,EAAOW,KAAKuG,SAGtCvG,KAAKmB,QAAU0F,GAClB7G,KAAKsE,OAAStE,KAAKuE,WAAavE,KAAKkE,aACrClE,KAAKyG,UAAUzG,KAAKkE,eAEpBlE,KAAKoF,QAAQ3F,GAAGO,KAAM,CACpBJ,WACAC,SACAyE,OAAQtE,KAAKkE,cAGlB"} \ No newline at end of file +{"version":3,"file":"lenis.modern.mjs","sources":["../src/maths.js","../src/lenis.js"],"sourcesContent":["export function clamp(min, input, max) {\n return Math.max(min, Math.min(input, max))\n}\n\nexport function mapRange(in_min, in_max, input, out_min, out_max) {\n return ((input - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min\n}\n\nexport function lerp(start, end, amt) {\n return (1 - amt) * start + amt * end\n}\n\nexport function truncate(value, decimals) {\n return parseFloat(value.toFixed(decimals))\n}\n\nexport function modulo(value, max) {\n let v = value % max\n if (v < 0) {\n v += max\n }\n\n return v\n}\n","import EventEmitter from 'tiny-emitter'\nimport VirtualScroll from 'virtual-scroll'\nimport { version } from '../package.json'\nimport { clamp, modulo } from './maths'\n\nclass Animate {\n to(target, { duration = 1, easing = (t) => t, ...keys } = {}) {\n this.target = target\n this.fromKeys = { ...keys }\n this.toKeys = { ...keys }\n this.keys = Object.keys({ ...keys })\n\n // get initial values\n this.keys.forEach((key) => {\n this.fromKeys[key] = target[key]\n })\n\n this.duration = duration\n this.easing = easing\n this.currentTime = 0\n this.isRunning = true\n }\n\n stop() {\n this.isRunning = false\n }\n\n raf(deltaTime) {\n if (!this.isRunning) return\n\n this.currentTime = Math.min(this.currentTime + deltaTime, this.duration)\n\n const progress = this.easing(this.progress)\n\n this.keys.forEach((key) => {\n const from = this.fromKeys[key]\n const to = this.toKeys[key]\n\n const value = from + (to - from) * progress\n\n this.target[key] = value\n })\n\n if (progress === 1) {\n this.stop()\n }\n }\n\n get progress() {\n return this.currentTime / this.duration\n }\n}\n\nexport default class Lenis extends EventEmitter {\n /**\n * @typedef {(t: number) => number} EasingFunction\n * @typedef {'vertical' | 'horizontal'} Direction\n * @typedef {'vertical' | 'horizontal' | 'both'} GestureDirection\n *\n * @typedef LenisOptions\n * @property {number} [duration]\n * @property {EasingFunction} [easing]\n * @property {boolean} [smooth]\n * @property {number} [mouseMultiplier]\n * @property {boolean} [smoothTouch]\n * @property {number} [touchMultiplier]\n * @property {Direction} [direction]\n * @property {GestureDirection} [gestureDirection]\n * @property {boolean} [infinite]\n * @property {Window | HTMLElement} [wrapper]\n * @property {HTMLElement} [content]\n *\n * @param {LenisOptions}\n */\n constructor({\n duration = 1.2,\n easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), // https://www.desmos.com/calculator/k2tgx2kn8t\n smooth = true,\n mouseMultiplier = 1,\n smoothTouch = false,\n touchMultiplier = 2,\n direction = 'vertical', // vertical, horizontal\n gestureDirection = 'vertical', // vertical, horizontal, both\n infinite = false,\n wrapper = window,\n content = document.body,\n } = {}) {\n super()\n\n window.lenisVersion = version\n\n this.options = {\n duration,\n easing,\n smooth,\n mouseMultiplier,\n smoothTouch,\n touchMultiplier,\n direction,\n gestureDirection,\n infinite,\n wrapper,\n content,\n }\n\n this.duration = duration\n this.easing = easing\n this.smooth = smooth\n this.mouseMultiplier = mouseMultiplier\n this.smoothTouch = smoothTouch\n this.touchMultiplier = touchMultiplier\n this.direction = direction\n this.gestureDirection = gestureDirection\n this.infinite = infinite\n this.wrapperNode = wrapper\n this.contentNode = content\n\n this.wrapperNode.addEventListener('scroll', this.onScroll)\n\n //observe wrapper node size\n if (this.wrapperNode === window) {\n this.wrapperNode.addEventListener('resize', this.onWindowResize)\n this.onWindowResize()\n } else {\n this.wrapperHeight = this.wrapperNode.offsetHeight\n this.wrapperWidth = this.wrapperNode.offsetWidth\n\n //observe wrapper node size\n this.wrapperObserver = new ResizeObserver(this.onWrapperResize)\n this.wrapperObserver.observe(this.wrapperNode)\n }\n\n this.contentHeight = this.contentNode.offsetHeight\n this.contentWidth = this.contentNode.offsetWidth\n\n //observe content node size\n this.contentObserver = new ResizeObserver(this.onContentResize)\n this.contentObserver.observe(this.contentNode)\n\n //set initial scroll position\n this.targetScroll =\n this.scroll =\n this.lastScroll =\n this.wrapperNode[this.scrollProperty]\n\n this.animate = new Animate()\n\n const platform =\n navigator?.userAgentData?.platform || navigator?.platform || 'unknown'\n\n // listen and normalize wheel event cross-browser\n this.virtualScroll = new VirtualScroll({\n el: this.wrapperNode,\n firefoxMultiplier: 50,\n mouseMultiplier:\n this.mouseMultiplier * (platform.includes('Win') ? 0.84 : 0.4),\n touchMultiplier: this.touchMultiplier,\n passive: false,\n })\n\n this.virtualScroll.on(this.onVirtualScroll)\n }\n\n get scrollProperty() {\n let property\n if (this.wrapperNode === window) {\n property = this.direction === 'horizontal' ? 'scrollX' : 'scrollY'\n } else {\n property = this.direction === 'horizontal' ? 'scrollLeft' : 'scrollTop'\n }\n return property\n }\n\n start() {\n this.stopped = false\n }\n\n stop() {\n this.stopped = true\n this.animate.stop()\n }\n\n destroy() {\n if (this.wrapperNode === window) {\n this.wrapperNode.removeEventListener('resize', this.onWindowResize)\n }\n this.wrapperNode.removeEventListener('scroll', this.onScroll)\n\n this.virtualScroll.destroy()\n this.wrapperObserver?.disconnect()\n this.contentObserver.disconnect()\n }\n\n onWindowResize = () => {\n this.wrapperWidth = window.innerWidth\n this.wrapperHeight = window.innerHeight\n }\n\n onWrapperResize = ([entry]) => {\n if (entry) {\n const rect = entry.contentRect\n this.wrapperWidth = rect.width\n this.wrapperHeight = rect.height\n }\n }\n\n onContentResize = ([entry]) => {\n if (entry) {\n const rect = entry.contentRect\n this.contentWidth = rect.width\n this.contentHeight = rect.height\n }\n }\n\n get limit() {\n return this.direction === 'horizontal'\n ? this.contentWidth - this.wrapperWidth\n : this.contentHeight - this.wrapperHeight\n }\n\n onVirtualScroll = ({ deltaY, deltaX, originalEvent: e }) => {\n const preventScroll = !!e\n .composedPath()\n .find(\n (node) => node.hasAttribute && node.hasAttribute('data-lenis-prevent')\n )\n\n if (e.ctrlKey || preventScroll) return\n\n // switch to smooth if event is touch and if smoothTouch=true\n this.smooth = !!e.changedTouches ? this.smoothTouch : this.options.smooth\n\n if (this.stopped) {\n e.preventDefault()\n return\n }\n\n if (!this.smooth) return\n\n // fix wheel holding scroll https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\n if (e.buttons === 4) return\n\n // prevent native wheel scrolling\n if (this.smooth) e.preventDefault()\n\n let delta = 0\n if (this.gestureDirection === 'both') {\n delta = deltaX + deltaY\n } else if (this.gestureDirection === 'horizontal') {\n delta = deltaX\n } else {\n // vertical\n delta = deltaY\n }\n\n this.targetScroll -= delta\n // this.targetScroll = clamp(0, this.targetScroll, this.limit)\n\n this.scrollTo(this.targetScroll)\n }\n\n raf(now) {\n const deltaTime = now - (this.now || 0)\n this.now = now\n\n if (this.stopped || !this.smooth) return\n\n this.lastScroll = this.scroll\n\n // where this.scroll is updated\n this.animate.raf(deltaTime * 0.001)\n\n if (this.scroll === this.targetScroll) {\n // if target reached velocity should be 0\n this.lastScroll = this.scroll\n }\n\n if (this.isScrolling) {\n this.setScroll(this.scroll)\n this.notify()\n }\n\n this.isScrolling = this.scroll !== this.targetScroll\n }\n\n get velocity() {\n return this.scroll - this.lastScroll\n }\n\n setScroll(value) {\n let scroll = this.infinite ? modulo(value, this.limit) : value\n\n this.direction === 'horizontal'\n ? this.wrapperNode.scrollTo(scroll, 0)\n : this.wrapperNode.scrollTo(0, scroll)\n }\n\n onScroll = (e) => {\n // if isScrolling false we can consider user isn't scrolling with wheel (cmd+F, keyboard or whatever). So we must scroll to value immediately\n if (!this.isScrolling || !this.smooth) {\n // where native scroll happens\n this.targetScroll =\n this.scroll =\n this.lastScroll =\n this.wrapperNode[this.scrollProperty]\n\n this.notify()\n }\n }\n\n notify() {\n let scroll = this.infinite ? modulo(this.scroll, this.limit) : this.scroll\n\n let direction = this.lastScroll < scroll ? 1 : -1\n\n this.emit('scroll', {\n scroll,\n limit: this.limit,\n velocity: this.velocity,\n direction,\n progress: scroll / this.limit,\n })\n }\n\n scrollTo(\n target,\n {\n offset = 0,\n immediate = false,\n duration = this.duration,\n easing = this.easing,\n } = {}\n ) {\n if (target === undefined || target === null) return\n let value\n\n if (typeof target === 'number') {\n value = target\n } else if (target === 'top' || target === '#top') {\n value = 0\n } else if (target === 'bottom') {\n value = this.limit\n } else {\n let node\n\n if (typeof target === 'string') {\n // CSS selector\n node = document.querySelector(target)\n } else if (target?.nodeType) {\n // Node element\n node = target\n } else {\n return\n }\n\n if (!node) return\n let wrapperOffset = 0\n\n if (this.wrapperNode !== window) {\n const wrapperRect = this.wrapperNode.getBoundingClientRect()\n wrapperOffset =\n this.direction === 'horizontal' ? wrapperRect.left : wrapperRect.top\n }\n\n const rect = node.getBoundingClientRect()\n\n value =\n (this.direction === 'horizontal' ? rect.left : rect.top) +\n this.scroll -\n wrapperOffset\n }\n\n value += offset\n\n if (this.infinite) {\n this.targetScroll = value\n } else {\n this.targetScroll = clamp(0, value, this.limit)\n }\n\n if (!this.smooth || immediate) {\n this.scroll = this.lastScroll = this.targetScroll\n this.setScroll(this.targetScroll)\n } else {\n this.animate.to(this, {\n duration,\n easing,\n scroll: this.targetScroll,\n })\n }\n }\n}\n"],"names":["modulo","value","max","v","Animate","to","target","_ref","duration","easing","t","keys","_objectWithoutPropertiesLoose","_excluded","this","fromKeys","toKeys","Object","_extends","forEach","key","currentTime","isRunning","stop","raf","deltaTime","Math","min","progress","from","Lenis","EventEmitter","constructor","pow","smooth","mouseMultiplier","smoothTouch","touchMultiplier","direction","gestureDirection","infinite","wrapper","window","content","document","body","super","onWindowResize","wrapperWidth","innerWidth","wrapperHeight","innerHeight","onWrapperResize","entry","rect","contentRect","width","height","onContentResize","contentWidth","contentHeight","onVirtualScroll","deltaY","deltaX","originalEvent","e","preventScroll","composedPath","find","node","hasAttribute","ctrlKey","changedTouches","options","stopped","preventDefault","buttons","delta","targetScroll","scrollTo","onScroll","isScrolling","scroll","lastScroll","wrapperNode","scrollProperty","notify","lenisVersion","contentNode","addEventListener","offsetHeight","offsetWidth","wrapperObserver","ResizeObserver","observe","contentObserver","animate","platform","_navigator","navigator","_navigator$userAgentD","userAgentData","_navigator2","virtualScroll","VirtualScroll","el","firefoxMultiplier","includes","passive","on","property","start","destroy","_this$wrapperObserver","removeEventListener","disconnect","limit","now","setScroll","velocity","emit","offset","immediate","querySelector","nodeType","wrapperOffset","wrapperRect","getBoundingClientRect","left","top"],"mappings":"8RAgBgBA,SAAAA,EAAOC,EAAOC,GAC5B,IAAKC,EAAGF,EAAQC,EAKhB,OAJIC,EAAI,IACNA,GAAKD,GAITC,CAAA,+BClBA,MAAMC,EACJC,GAAGC,EAAQC,EAA+C,IAA/C,IAAAC,SAAEA,EAAW,EAACC,OAAEA,EAAUC,IAAMA,IAAYH,EAANI,oIAAIC,CAAAL,EAAAM,GACnDC,KAAKR,OAASA,EACdQ,KAAKC,SAAgBJ,EAAAA,CAAAA,EAAAA,GACrBG,KAAKE,OAAcL,EAAAA,CAAAA,EAAAA,GACnBG,KAAKH,KAAOM,OAAON,KAAIO,EAAA,CAAA,EAAMP,IAG7BG,KAAKH,KAAKQ,QAASC,IACjBN,KAAKC,SAASK,GAAOd,EAAOc,EAAG,GAGjCN,KAAKN,SAAWA,EAChBM,KAAKL,OAASA,EACdK,KAAKO,YAAc,EACnBP,KAAKQ,WAAY,CACnB,CAEAC,OACET,KAAKQ,WAAY,CACnB,CAEAE,IAAIC,GACF,IAAKX,KAAKQ,UAAW,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AS+E,cAAcrH,WACf,MAANA,IAAAA,EAAQsH,SAIjB,OAFAvD,EAAO/D,CAGT,CAEA,IAAK+D,EAAM,OACX,IAAIwD,EAAgB,EAEpB,GAAI/G,KAAKsE,cAAgB1C,OAAQ,CAC/B,MAAMoF,EAAchH,KAAKsE,YAAY2C,wBACrCF,EACqB,eAAnB/G,KAAKwB,UAA6BwF,EAAYE,KAAOF,EAAYG,GACrE,CAEA,MAAM3E,EAAOe,EAAK0D,wBAElB9H,GACsB,eAAnBa,KAAKwB,UAA6BgB,EAAK0E,KAAO1E,EAAK2E,KACpDnH,KAAKoE,OACL2C,CACJ,CAEA5H,GAASwH,EAGP3G,KAAKgE,aADHhE,KAAK0B,SACavC,EDtXjByB,KAAKxB,ICwXkB,EDxXTwB,KAAKC,ICwXO1B,EAAOa,KAAKsG,SAGtCtG,KAAKoB,QAAUwF,GAClB5G,KAAKoE,OAASpE,KAAKqE,WAAarE,KAAKgE,aACrChE,KAAKwG,UAAUxG,KAAKgE,eAEpBhE,KAAKkF,QAAQ3F,GAAGS,KAAM,CACpBN,WACAC,SACAyE,OAAQpE,KAAKgE,cAGnB"} \ No newline at end of file diff --git a/dist/lenis.umd.js b/dist/lenis.umd.js index d8eb7a57..a9470074 100644 --- a/dist/lenis.umd.js +++ b/dist/lenis.umd.js @@ -1,3 +1,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("tiny-emitter"),require("virtual-scroll")):"function"==typeof define&&define.amd?define(["tiny-emitter","virtual-scroll"],e):(t||self).lenis=e(t.tinyEmitter,t.virtualScroll)}(this,function(t,e){function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=/*#__PURE__*/i(t),r=/*#__PURE__*/i(e);function n(t,e){for(var i=0;i=0||(r[i]=t[i]);return r}(o,h);this.target=t,this.fromKeys=l({},a),this.toKeys=l({},a),this.keys=Object.keys(l({},a)),this.keys.forEach(function(e){i.fromKeys[e]=t[e]}),this.duration=n,this.easing=c,this.currentTime=0,this.isRunning=!0},e.stop=function(){this.isRunning=!1},e.raf=function(t){var e=this;if(this.isRunning){this.currentTime=Math.min(this.currentTime+t,this.duration);var i=this.easing(this.progress);this.keys.forEach(function(t){var o=e.fromKeys[t];e.target[t]=o+(e.toKeys[t]-o)*i}),1===i&&this.stop()}},s(t,[{key:"progress",get:function(){return this.currentTime/this.duration}}]),t}();/*#__PURE__*/ -return function(t){var e,i;function o(e){var i,o,n,s,l=void 0===e?{}:e,c=l.duration,a=void 0===c?1.2:c,h=l.easing,p=void 0===h?function(t){return Math.min(1,1.001-Math.pow(2,-10*t))}:h,d=l.smooth,f=void 0===d||d,v=l.mouseMultiplier,g=void 0===v?1:v,w=l.smoothTouch,m=void 0!==w&&w,y=l.touchMultiplier,b=void 0===y?2:y,S=l.direction,N=void 0===S?"vertical":S,O=l.gestureDirection,z=void 0===O?"vertical":O,T=l.infinite,R=void 0!==T&&T,W=l.wrapper,M=void 0===W?window:W,j=l.content,k=void 0===j?document.body:j;(s=t.call(this)||this).onWindowResize=function(){s.wrapperWidth=window.innerWidth,s.wrapperHeight=window.innerHeight},s.onWrapperResize=function(t){var e=t[0];if(e){var i=e.contentRect;s.wrapperWidth=i.width,s.wrapperHeight=i.height}},s.onContentResize=function(t){var e=t[0];if(e){var i=e.contentRect;s.contentWidth=i.width,s.contentHeight=i.height}},s.onVirtualScroll=function(t){var e=t.deltaY,i=t.deltaX,o=t.originalEvent,r=!!o.composedPath().find(function(t){return t.hasAttribute&&t.hasAttribute("data-lenis-prevent")});o.ctrlKey||r||(s.smooth=o.changedTouches?s.smoothTouch:s.options.smooth,s.stopped?o.preventDefault():s.smooth&&4!==o.buttons&&(s.smooth&&o.preventDefault(),s.targetScroll-="both"===s.gestureDirection?i+e:"horizontal"===s.gestureDirection?i:e,s.scrollTo(s.targetScroll)))},s.onScroll=function(t){s.isScrolling&&s.smooth||(s.targetScroll=s.scroll=s.lastScroll=s.wrapperNode[s.scrollProperty],s.notify())},window.lenisVersion="0.2.19",s.options={duration:a,easing:p,smooth:f,mouseMultiplier:g,smoothTouch:m,touchMultiplier:b,direction:N,gestureDirection:z,infinite:R,wrapper:M,content:k},s.duration=a,s.easing=p,s.smooth=f,s.mouseMultiplier=g,s.smoothTouch=m,s.touchMultiplier=b,s.direction=N,s.gestureDirection=z,s.infinite=R,s.wrapperNode=M,s.contentNode=k,s.wrapperNode.addEventListener("scroll",s.onScroll),s.wrapperNode===window?(s.wrapperNode.addEventListener("resize",s.onWindowResize),s.onWindowResize()):(s.wrapperHeight=s.wrapperNode.offsetHeight,s.wrapperWidth=s.wrapperNode.offsetWidth,s.wrapperObserver=new ResizeObserver(s.onWrapperResize),s.wrapperObserver.observe(s.wrapperNode)),s.contentHeight=s.contentNode.offsetHeight,s.contentWidth=s.contentNode.offsetWidth,s.contentObserver=new ResizeObserver(s.onContentResize),s.contentObserver.observe(s.contentNode),s.targetScroll=s.scroll=s.lastScroll=s.wrapperNode[s.scrollProperty],s.animate=new u;var H=(null==(i=navigator)||null==(o=i.userAgentData)?void 0:o.platform)||(null==(n=navigator)?void 0:n.platform)||"unknown";return s.virtualScroll=new r.default({el:s.wrapperNode,firefoxMultiplier:50,mouseMultiplier:s.mouseMultiplier*(H.includes("Win")?.84:.4),useKeyboard:!1,touchMultiplier:s.touchMultiplier,useTouch:!0,passive:!1}),s.virtualScroll.on(s.onVirtualScroll),s}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,c(e,i);var n=o.prototype;return n.start=function(){this.stopped=!1},n.stop=function(){this.stopped=!0,this.animate.stop()},n.destroy=function(){var t;this.wrapperNode===window&&this.wrapperNode.removeEventListener("resize",this.onWindowResize),this.wrapperNode.removeEventListener("scroll",this.onScroll),this.virtualScroll.destroy(),null==(t=this.wrapperObserver)||t.disconnect(),this.contentObserver.disconnect()},n.raf=function(t){var e=t-(this.now||0);this.now=t,!this.stopped&&this.smooth&&(this.lastScroll=this.scroll,this.animate.raf(.001*e),this.scroll===this.targetScroll&&(this.lastScroll=this.scroll),this.isScrolling&&(this.setScroll(this.scroll),this.notify()),this.isScrolling=this.scroll!==this.targetScroll)},n.setScroll=function(t){var e=this.infinite?a(t,this.limit):t;"horizontal"===this.direction?this.wrapperNode.scrollTo(e,0):this.wrapperNode.scrollTo(0,e)},n.notify=function(){var t=this.infinite?a(this.scroll,this.limit):this.scroll;this.emit("scroll",{scroll:t,limit:this.limit,velocity:this.velocity,direction:this.direction,progress:t/this.limit})},n.scrollTo=function(t,e){var i=void 0===e?{}:e,o=i.offset,r=void 0===o?0:o,n=i.immediate,s=void 0!==n&&n,l=i.duration,c=void 0===l?this.duration:l,a=i.easing,h=void 0===a?this.easing:a;if(null!=t){var u;if("number"==typeof t)u=t;else if("top"===t||"#top"===t)u=0;else if("bottom"===t)u=this.limit;else{var p;if("string"==typeof t)p=document.querySelector(t);else{if(null==t||!t.nodeType)return;p=t}if(!p)return;var d=0;if(this.wrapperNode!==window){var f=this.wrapperNode.getBoundingClientRect();d="horizontal"===this.direction?f.left:f.top}var v=p.getBoundingClientRect();u=("horizontal"===this.direction?v.left:v.top)+this.scroll-d}u+=r,this.targetScroll=this.infinite?u:Math.max(0,Math.min(u,this.limit)),!this.smooth||s?(this.scroll=this.lastScroll=this.targetScroll,this.setScroll(this.targetScroll)):this.animate.to(this,{duration:c,easing:h,scroll:this.targetScroll})}},s(o,[{key:"scrollProperty",get:function(){return this.wrapperNode===window?"horizontal"===this.direction?"scrollX":"scrollY":"horizontal"===this.direction?"scrollLeft":"scrollTop"}},{key:"limit",get:function(){return"horizontal"===this.direction?this.contentWidth-this.wrapperWidth:this.contentHeight-this.wrapperHeight}},{key:"velocity",get:function(){return this.scroll-this.lastScroll}}]),o}(o.default)}); +return function(t){var e,i;function o(e){var i,o,n,s,l=void 0===e?{}:e,c=l.duration,a=void 0===c?1.2:c,h=l.easing,p=void 0===h?function(t){return Math.min(1,1.001-Math.pow(2,-10*t))}:h,d=l.smooth,f=void 0===d||d,v=l.mouseMultiplier,g=void 0===v?1:v,w=l.smoothTouch,m=void 0!==w&&w,y=l.touchMultiplier,b=void 0===y?2:y,S=l.direction,N=void 0===S?"vertical":S,O=l.gestureDirection,z=void 0===O?"vertical":O,R=l.infinite,T=void 0!==R&&R,W=l.wrapper,M=void 0===W?window:W,j=l.content,k=void 0===j?document.body:j;(s=t.call(this)||this).onWindowResize=function(){s.wrapperWidth=window.innerWidth,s.wrapperHeight=window.innerHeight},s.onWrapperResize=function(t){var e=t[0];if(e){var i=e.contentRect;s.wrapperWidth=i.width,s.wrapperHeight=i.height}},s.onContentResize=function(t){var e=t[0];if(e){var i=e.contentRect;s.contentWidth=i.width,s.contentHeight=i.height}},s.onVirtualScroll=function(t){var e=t.deltaY,i=t.deltaX,o=t.originalEvent,r=!!o.composedPath().find(function(t){return t.hasAttribute&&t.hasAttribute("data-lenis-prevent")});o.ctrlKey||r||(s.smooth=o.changedTouches?s.smoothTouch:s.options.smooth,s.stopped?o.preventDefault():s.smooth&&4!==o.buttons&&(s.smooth&&o.preventDefault(),s.targetScroll-="both"===s.gestureDirection?i+e:"horizontal"===s.gestureDirection?i:e,s.scrollTo(s.targetScroll)))},s.onScroll=function(t){s.isScrolling&&s.smooth||(s.targetScroll=s.scroll=s.lastScroll=s.wrapperNode[s.scrollProperty],s.notify())},window.lenisVersion="0.2.20",s.options={duration:a,easing:p,smooth:f,mouseMultiplier:g,smoothTouch:m,touchMultiplier:b,direction:N,gestureDirection:z,infinite:T,wrapper:M,content:k},s.duration=a,s.easing=p,s.smooth=f,s.mouseMultiplier=g,s.smoothTouch=m,s.touchMultiplier=b,s.direction=N,s.gestureDirection=z,s.infinite=T,s.wrapperNode=M,s.contentNode=k,s.wrapperNode.addEventListener("scroll",s.onScroll),s.wrapperNode===window?(s.wrapperNode.addEventListener("resize",s.onWindowResize),s.onWindowResize()):(s.wrapperHeight=s.wrapperNode.offsetHeight,s.wrapperWidth=s.wrapperNode.offsetWidth,s.wrapperObserver=new ResizeObserver(s.onWrapperResize),s.wrapperObserver.observe(s.wrapperNode)),s.contentHeight=s.contentNode.offsetHeight,s.contentWidth=s.contentNode.offsetWidth,s.contentObserver=new ResizeObserver(s.onContentResize),s.contentObserver.observe(s.contentNode),s.targetScroll=s.scroll=s.lastScroll=s.wrapperNode[s.scrollProperty],s.animate=new u;var H=(null==(i=navigator)||null==(o=i.userAgentData)?void 0:o.platform)||(null==(n=navigator)?void 0:n.platform)||"unknown";return s.virtualScroll=new r.default({el:s.wrapperNode,firefoxMultiplier:50,mouseMultiplier:s.mouseMultiplier*(H.includes("Win")?.84:.4),touchMultiplier:s.touchMultiplier,passive:!1}),s.virtualScroll.on(s.onVirtualScroll),s}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,c(e,i);var n=o.prototype;return n.start=function(){this.stopped=!1},n.stop=function(){this.stopped=!0,this.animate.stop()},n.destroy=function(){var t;this.wrapperNode===window&&this.wrapperNode.removeEventListener("resize",this.onWindowResize),this.wrapperNode.removeEventListener("scroll",this.onScroll),this.virtualScroll.destroy(),null==(t=this.wrapperObserver)||t.disconnect(),this.contentObserver.disconnect()},n.raf=function(t){var e=t-(this.now||0);this.now=t,!this.stopped&&this.smooth&&(this.lastScroll=this.scroll,this.animate.raf(.001*e),this.scroll===this.targetScroll&&(this.lastScroll=this.scroll),this.isScrolling&&(this.setScroll(this.scroll),this.notify()),this.isScrolling=this.scroll!==this.targetScroll)},n.setScroll=function(t){var e=this.infinite?a(t,this.limit):t;"horizontal"===this.direction?this.wrapperNode.scrollTo(e,0):this.wrapperNode.scrollTo(0,e)},n.notify=function(){var t=this.infinite?a(this.scroll,this.limit):this.scroll;this.emit("scroll",{scroll:t,limit:this.limit,velocity:this.velocity,direction:this.lastScroll t, ...keys } = {}) {\r\n this.target = target\r\n this.fromKeys = { ...keys }\r\n this.toKeys = { ...keys }\r\n this.keys = Object.keys({ ...keys })\r\n\r\n // get initial values\r\n this.keys.forEach((key) => {\r\n this.fromKeys[key] = target[key]\r\n })\r\n\r\n this.duration = duration\r\n this.easing = easing\r\n this.currentTime = 0\r\n this.isRunning = true\r\n }\r\n\r\n stop() {\r\n this.isRunning = false\r\n }\r\n\r\n raf(deltaTime) {\r\n if (!this.isRunning) return\r\n\r\n this.currentTime = Math.min(this.currentTime + deltaTime, this.duration)\r\n\r\n const progress = this.easing(this.progress)\r\n\r\n this.keys.forEach((key) => {\r\n const from = this.fromKeys[key]\r\n const to = this.toKeys[key]\r\n\r\n const value = from + (to - from) * progress\r\n\r\n this.target[key] = value\r\n })\r\n\r\n if (progress === 1) {\r\n this.stop()\r\n }\r\n }\r\n\r\n get progress() {\r\n return this.currentTime / this.duration\r\n }\r\n}\r\n\r\nexport default class Lenis extends EventEmitter {\r\n /**\r\n * @typedef {(t: number) => number} EasingFunction\r\n * @typedef {'vertical' | 'horizontal'} Direction\r\n * @typedef {'vertical' | 'horizontal' | 'both'} GestureDirection\r\n *\r\n * @typedef LenisOptions\r\n * @property {number} [duration]\r\n * @property {EasingFunction} [easing]\r\n * @property {boolean} [smooth]\r\n * @property {number} [mouseMultiplier]\r\n * @property {boolean} [smoothTouch]\r\n * @property {number} [touchMultiplier]\r\n * @property {Direction} [direction]\r\n * @property {GestureDirection} [gestureDirection]\r\n * @property {boolean} [infinite]\r\n * @property {Window | HTMLElement} [wrapper]\r\n * @property {HTMLElement} [content]\r\n *\r\n * @param {LenisOptions}\r\n */\r\n constructor({\r\n duration = 1.2,\r\n easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), // https://www.desmos.com/calculator/k2tgx2kn8t\r\n smooth = true,\r\n mouseMultiplier = 1,\r\n smoothTouch = false,\r\n touchMultiplier = 2,\r\n direction = 'vertical', // vertical, horizontal\r\n gestureDirection = 'vertical', // vertical, horizontal, both\r\n infinite = false,\r\n wrapper = window,\r\n content = document.body,\r\n } = {}) {\r\n super()\r\n\r\n window.lenisVersion = version\r\n\r\n this.options = {\r\n duration,\r\n easing,\r\n smooth,\r\n mouseMultiplier,\r\n smoothTouch,\r\n touchMultiplier,\r\n direction,\r\n gestureDirection,\r\n infinite,\r\n wrapper,\r\n content,\r\n }\r\n\r\n this.duration = duration\r\n this.easing = easing\r\n this.smooth = smooth\r\n this.mouseMultiplier = mouseMultiplier\r\n this.smoothTouch = smoothTouch\r\n this.touchMultiplier = touchMultiplier\r\n this.direction = direction\r\n this.gestureDirection = gestureDirection\r\n this.infinite = infinite\r\n this.wrapperNode = wrapper\r\n this.contentNode = content\r\n\r\n this.wrapperNode.addEventListener('scroll', this.onScroll)\r\n\r\n //observe wrapper node size\r\n if (this.wrapperNode === window) {\r\n this.wrapperNode.addEventListener('resize', this.onWindowResize)\r\n this.onWindowResize()\r\n } else {\r\n this.wrapperHeight = this.wrapperNode.offsetHeight\r\n this.wrapperWidth = this.wrapperNode.offsetWidth\r\n\r\n //observe wrapper node size\r\n this.wrapperObserver = new ResizeObserver(this.onWrapperResize)\r\n this.wrapperObserver.observe(this.wrapperNode)\r\n }\r\n\r\n this.contentHeight = this.contentNode.offsetHeight\r\n this.contentWidth = this.contentNode.offsetWidth\r\n\r\n //observe content node size\r\n this.contentObserver = new ResizeObserver(this.onContentResize)\r\n this.contentObserver.observe(this.contentNode)\r\n\r\n //set initial scroll position\r\n this.targetScroll =\r\n this.scroll =\r\n this.lastScroll =\r\n this.wrapperNode[this.scrollProperty]\r\n\r\n this.animate = new Animate()\r\n\r\n const platform =\r\n navigator?.userAgentData?.platform || navigator?.platform || 'unknown'\r\n\r\n // listen and normalize wheel event cross-browser\r\n this.virtualScroll = new VirtualScroll({\r\n el: this.wrapperNode,\r\n firefoxMultiplier: 50,\r\n mouseMultiplier:\r\n this.mouseMultiplier * (platform.includes('Win') ? 0.84 : 0.4),\r\n useKeyboard: false,\r\n touchMultiplier: this.touchMultiplier,\r\n useTouch: true,\r\n passive: false,\r\n })\r\n\r\n this.virtualScroll.on(this.onVirtualScroll)\r\n }\r\n\r\n get scrollProperty() {\r\n let property\r\n if (this.wrapperNode === window) {\r\n property = this.direction === 'horizontal' ? 'scrollX' : 'scrollY'\r\n } else {\r\n property = this.direction === 'horizontal' ? 'scrollLeft' : 'scrollTop'\r\n }\r\n return property\r\n }\r\n\r\n start() {\r\n this.stopped = false\r\n }\r\n\r\n stop() {\r\n this.stopped = true\r\n this.animate.stop()\r\n }\r\n\r\n destroy() {\r\n if (this.wrapperNode === window) {\r\n this.wrapperNode.removeEventListener('resize', this.onWindowResize)\r\n }\r\n this.wrapperNode.removeEventListener('scroll', this.onScroll)\r\n\r\n this.virtualScroll.destroy()\r\n this.wrapperObserver?.disconnect()\r\n this.contentObserver.disconnect()\r\n }\r\n\r\n onWindowResize = () => {\r\n this.wrapperWidth = window.innerWidth\r\n this.wrapperHeight = window.innerHeight\r\n }\r\n\r\n onWrapperResize = ([entry]) => {\r\n if (entry) {\r\n const rect = entry.contentRect\r\n this.wrapperWidth = rect.width\r\n this.wrapperHeight = rect.height\r\n }\r\n }\r\n\r\n onContentResize = ([entry]) => {\r\n if (entry) {\r\n const rect = entry.contentRect\r\n this.contentWidth = rect.width\r\n this.contentHeight = rect.height\r\n }\r\n }\r\n\r\n get limit() {\r\n return this.direction === 'horizontal'\r\n ? this.contentWidth - this.wrapperWidth\r\n : this.contentHeight - this.wrapperHeight\r\n }\r\n\r\n onVirtualScroll = ({ deltaY, deltaX, originalEvent: e }) => {\r\n const preventScroll = !!e\r\n .composedPath()\r\n .find(\r\n (node) => node.hasAttribute && node.hasAttribute('data-lenis-prevent')\r\n )\r\n\r\n if (e.ctrlKey || preventScroll) return\r\n\r\n // switch to smooth if event is touch and if smoothTouch=true\r\n this.smooth = !!e.changedTouches ? this.smoothTouch : this.options.smooth\r\n\r\n if (this.stopped) {\r\n e.preventDefault()\r\n return\r\n }\r\n\r\n if (!this.smooth) return\r\n\r\n // fix wheel holding scroll https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\r\n if (e.buttons === 4) return\r\n\r\n // prevent native wheel scrolling\r\n if (this.smooth) e.preventDefault()\r\n\r\n let delta = 0\r\n if (this.gestureDirection === 'both') {\r\n delta = deltaX + deltaY\r\n } else if (this.gestureDirection === 'horizontal') {\r\n delta = deltaX\r\n } else {\r\n // vertical\r\n delta = deltaY\r\n }\r\n\r\n this.targetScroll -= delta\r\n // this.targetScroll = clamp(0, this.targetScroll, this.limit)\r\n\r\n this.scrollTo(this.targetScroll)\r\n }\r\n\r\n raf(now) {\r\n const deltaTime = now - (this.now || 0)\r\n this.now = now\r\n\r\n if (this.stopped || !this.smooth) return\r\n\r\n this.lastScroll = this.scroll\r\n\r\n // where this.scroll is updated\r\n this.animate.raf(deltaTime * 0.001)\r\n\r\n if (this.scroll === this.targetScroll) {\r\n // if target reached velocity should be 0\r\n this.lastScroll = this.scroll\r\n }\r\n\r\n if (this.isScrolling) {\r\n this.setScroll(this.scroll)\r\n this.notify()\r\n }\r\n\r\n this.isScrolling = this.scroll !== this.targetScroll\r\n }\r\n\r\n get velocity() {\r\n return this.scroll - this.lastScroll\r\n }\r\n\r\n setScroll(value) {\r\n let scroll = this.infinite ? modulo(value, this.limit) : value\r\n\r\n this.direction === 'horizontal'\r\n ? this.wrapperNode.scrollTo(scroll, 0)\r\n : this.wrapperNode.scrollTo(0, scroll)\r\n }\r\n\r\n onScroll = (e) => {\r\n // if isScrolling false we can consider user isn't scrolling with wheel (cmd+F, keyboard or whatever). So we must scroll to value immediately\r\n if (!this.isScrolling || !this.smooth) {\r\n // where native scroll happens\r\n this.targetScroll =\r\n this.scroll =\r\n this.lastScroll =\r\n this.wrapperNode[this.scrollProperty]\r\n\r\n this.notify()\r\n }\r\n }\r\n\r\n notify() {\r\n let scroll = this.infinite ? modulo(this.scroll, this.limit) : this.scroll\r\n\r\n this.emit('scroll', {\r\n scroll,\r\n limit: this.limit,\r\n velocity: this.velocity,\r\n direction: this.direction,\r\n progress: scroll / this.limit,\r\n })\r\n }\r\n\r\n scrollTo(\r\n target,\r\n {\r\n offset = 0,\r\n immediate = false,\r\n duration = this.duration,\r\n easing = this.easing,\r\n } = {}\r\n ) {\r\n if (target === undefined || target === null) return\r\n let value\r\n\r\n if (typeof target === 'number') {\r\n value = target\r\n } else if (target === 'top' || target === '#top') {\r\n value = 0\r\n } else if (target === 'bottom') {\r\n value = this.limit\r\n } else {\r\n let node\r\n\r\n if (typeof target === 'string') {\r\n // CSS selector\r\n node = document.querySelector(target)\r\n } else if (target?.nodeType) {\r\n // Node element\r\n node = target\r\n } else {\r\n return\r\n }\r\n\r\n if (!node) return\r\n let wrapperOffset = 0\r\n\r\n if (this.wrapperNode !== window) {\r\n const wrapperRect = this.wrapperNode.getBoundingClientRect()\r\n wrapperOffset =\r\n this.direction === 'horizontal' ? wrapperRect.left : wrapperRect.top\r\n }\r\n\r\n const rect = node.getBoundingClientRect()\r\n\r\n value =\r\n (this.direction === 'horizontal' ? rect.left : rect.top) +\r\n this.scroll -\r\n wrapperOffset\r\n }\r\n\r\n value += offset\r\n\r\n if (this.infinite) {\r\n this.targetScroll = value\r\n } else {\r\n this.targetScroll = clamp(0, value, this.limit)\r\n }\r\n\r\n if (!this.smooth || immediate) {\r\n this.scroll = this.lastScroll = this.targetScroll\r\n this.setScroll(this.targetScroll)\r\n } else {\r\n this.animate.to(this, {\r\n duration,\r\n easing,\r\n scroll: this.targetScroll,\r\n })\r\n }\r\n }\r\n}\r\n"],"names":["modulo","value","max","v","to","Lenis","target","_this","this","_ref","_temp","duration","_ref$duration","easing","_ref$easing","t","keys","fromKeys","_extends","toKeys","Object","forEach","key","currentTime","isRunning","stop","raf","deltaTime","_this2","Math","min","progress","from","_temp2","_navigator","_navigator$userAgentD","_navigator2","_this3","_ref2","_ref2$duration","_ref2$easing","pow","_ref2$smooth","smooth","_ref2$mouseMultiplier","mouseMultiplier","_ref2$smoothTouch","smoothTouch","_ref2$touchMultiplier","touchMultiplier","_ref2$direction","direction","_ref2$gestureDirectio","gestureDirection","_ref2$infinite","infinite","_ref2$wrapper","wrapper","window","_ref2$content","content","document","body","_EventEmitter","call","onWindowResize","wrapperWidth","innerWidth","wrapperHeight","innerHeight","onWrapperResize","_ref3","entry","rect","contentRect","width","height","onContentResize","_ref4","contentWidth","contentHeight","onVirtualScroll","_ref5","deltaY","deltaX","e","originalEvent","preventScroll","composedPath","find","node","hasAttribute","ctrlKey","changedTouches","options","stopped","preventDefault","buttons","targetScroll","scrollTo","onScroll","isScrolling","scroll","lastScroll","wrapperNode","scrollProperty","notify","lenisVersion","contentNode","addEventListener","offsetHeight","offsetWidth","wrapperObserver","ResizeObserver","observe","contentObserver","animate","Animate","platform","navigator","userAgentData","virtualScroll","VirtualScroll","el","firefoxMultiplier","includes","useKeyboard","useTouch","passive","on","start","destroy","_this$wrapperObserver","removeEventListener","disconnect","now","setScroll","limit","emit","velocity","_temp3","_ref6$offset","_ref6","offset","_ref6$immediate","immediate","_ref6$duration","_ref6$easing","querySelector","nodeType","wrapperOffset","wrapperRect","getBoundingClientRect","left","top","get","EventEmitter"],"mappings":"8iCAgBO,SAAAA,EAAgBC,EAAOC,GAC5B,IAAKC,EAAGF,EAAQC,EAKhB,OAJIC,EAAI,IACNA,GAAKD,GAIRC,CAAA,4CCjBCC,WAAAA,SAAAA,IAAAA,CAAAA,IAAAA,EAAAA,EAAAA,UA+CmBC,OA/CnBD,EAAAA,GAAA,SAAGE,KAAuD,IAAAC,EAAAC,KAAAC,OAAA,IAAAC,EAAA,CAAI,QAAjDC,SAAAA,OAAW,IAAAC,EAAA,QAAGC,OAAAA,OAAS,IAAAC,EAAA,SAACC,GAAMA,OAAAA,CAAP,EAAaC,EAAAA,0IAC/CR,KAAKF,OAASA,EACdE,KAAKS,SAALC,EAAA,GAAqBF,GACrBR,KAAKW,OAAcH,EAAAA,CAAAA,EAAAA,GACnBR,KAAKQ,KAAOI,OAAOJ,KAAUA,EAAAA,CAAAA,EAAAA,IAG7BR,KAAKQ,KAAKK,QAAQ,SAACC,GACjBf,EAAKU,SAASK,GAAOhB,EAAOgB,EAC7B,GAEDd,KAAKG,SAAWA,EAChBH,KAAKK,OAASA,EACdL,KAAKe,Y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yD9C,iCAjOD,WAOE,OALI1F,KAAKgG,cAAgB9C,OACO,eAAnBlD,KAAK2C,UAA6B,UAAY,UAE3B,eAAnB3C,KAAK2C,UAA6B,aAAe,WAG/D,GA2CD,CAAA7B,IAAA,QAAAqI,IAAA,WACE,MAA0B,eAAnBnJ,KAAK2C,UACR3C,KAAKuE,aAAevE,KAAK0D,aACzB1D,KAAKwE,cAAgBxE,KAAK4D,aAC/B,GAmED,CAAA9C,IAAA,WAAAqI,IAAA,WACE,OAAOnJ,KAAK8F,OAAS9F,KAAK+F,UAC3B,QA5OgCqD"} \ No newline at end of file +{"version":3,"file":"lenis.umd.js","sources":["../src/maths.js","../src/lenis.js"],"sourcesContent":["export function clamp(min, input, max) {\n return Math.max(min, Math.min(input, max))\n}\n\nexport function mapRange(in_min, in_max, input, out_min, out_max) {\n return ((input - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min\n}\n\nexport function lerp(start, end, amt) {\n return (1 - amt) * start + amt * end\n}\n\nexport function truncate(value, decimals) {\n return parseFloat(value.toFixed(decimals))\n}\n\nexport function modulo(value, max) {\n let v = value % max\n if (v < 0) {\n v += max\n }\n\n return v\n}\n","import EventEmitter from 'tiny-emitter'\nimport VirtualScroll from 'virtual-scroll'\nimport { version } from '../package.json'\nimport { clamp, modulo } from './maths'\n\nclass Animate {\n to(target, { duration = 1, easing = (t) => t, ...keys } = {}) {\n this.target = target\n this.fromKeys = { ...keys }\n this.toKeys = { ...keys }\n this.keys = Object.keys({ ...keys })\n\n // get initial values\n this.keys.forEach((key) => {\n this.fromKeys[key] = target[key]\n })\n\n this.duration = duration\n this.easing = easing\n this.currentTime = 0\n this.isRunning = true\n }\n\n stop() {\n this.isRunning = false\n }\n\n raf(deltaTime) {\n if (!this.isRunning) return\n\n this.currentTime = Math.min(this.currentTime + deltaTime, this.duration)\n\n const progress = this.easing(this.progress)\n\n this.keys.forEach((key) => {\n const from = this.fromKeys[key]\n const to = this.toKeys[key]\n\n const value = from + (to - from) * progress\n\n this.target[key] = value\n })\n\n if (progress === 1) {\n this.stop()\n }\n }\n\n get progress() {\n return this.currentTime / this.duration\n }\n}\n\nexport default class Lenis extends EventEmitter {\n /**\n * @typedef {(t: number) => number} EasingFunction\n * @typedef {'vertical' | 'horizontal'} Direction\n * @typedef {'vertical' | 'horizontal' | 'both'} GestureDirection\n *\n * @typedef LenisOptions\n * @property {number} [duration]\n * @property {EasingFunction} [easing]\n * @property {boolean} [smooth]\n * @property {number} [mouseMultiplier]\n * @property {boolean} [smoothTouch]\n * @property {number} [touchMultiplier]\n * @property {Direction} [direction]\n * @property {GestureDirection} [gestureDirection]\n * @property {boolean} [infinite]\n * @property {Window | HTMLElement} [wrapper]\n * @property {HTMLElement} [content]\n *\n * @param {LenisOptions}\n */\n constructor({\n duration = 1.2,\n easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), // https://www.desmos.com/calculator/k2tgx2kn8t\n smooth = true,\n mouseMultiplier = 1,\n smoothTouch = false,\n touchMultiplier = 2,\n direction = 'vertical', // vertical, horizontal\n gestureDirection = 'vertical', // vertical, horizontal, both\n infinite = false,\n wrapper = window,\n content = document.body,\n } = {}) {\n super()\n\n window.lenisVersion = version\n\n this.options = {\n duration,\n easing,\n smooth,\n mouseMultiplier,\n smoothTouch,\n touchMultiplier,\n direction,\n gestureDirection,\n infinite,\n wrapper,\n content,\n }\n\n this.duration = duration\n this.easing = easing\n this.smooth = smooth\n this.mouseMultiplier = mouseMultiplier\n this.smoothTouch = smoothTouch\n this.touchMultiplier = touchMultiplier\n this.direction = direction\n this.gestureDirection = gestureDirection\n this.infinite = infinite\n this.wrapperNode = wrapper\n this.contentNode = content\n\n this.wrapperNode.addEventListener('scroll', this.onScroll)\n\n //observe wrapper node size\n if (this.wrapperNode === window) {\n this.wrapperNode.addEventListener('resize', this.onWindowResize)\n this.onWindowResize()\n } else {\n this.wrapperHeight = this.wrapperNode.offsetHeight\n this.wrapperWidth = this.wrapperNode.offsetWidth\n\n //observe wrapper node size\n this.wrapperObserver = new ResizeObserver(this.onWrapperResize)\n this.wrapperObserver.observe(this.wrapperNode)\n }\n\n this.contentHeight = this.contentNode.offsetHeight\n this.contentWidth = this.contentNode.offsetWidth\n\n //observe content node size\n this.contentObserver = new ResizeObserver(this.onContentResize)\n this.contentObserver.observe(this.contentNode)\n\n //set initial scroll position\n this.targetScroll =\n this.scroll =\n this.lastScroll =\n this.wrapperNode[this.scrollProperty]\n\n this.animate = new Animate()\n\n const platform =\n navigator?.userAgentData?.platform || navigator?.platform || 'unknown'\n\n // listen and normalize wheel event cross-browser\n this.virtualScroll = new VirtualScroll({\n el: this.wrapperNode,\n firefoxMultiplier: 50,\n mouseMultiplier:\n this.mouseMultiplier * (platform.includes('Win') ? 0.84 : 0.4),\n touchMultiplier: this.touchMultiplier,\n passive: false,\n })\n\n this.virtualScroll.on(this.onVirtualScroll)\n }\n\n get scrollProperty() {\n let property\n if (this.wrapperNode === window) {\n property = this.direction === 'horizontal' ? 'scrollX' : 'scrollY'\n } else {\n property = this.direction === 'horizontal' ? 'scrollLeft' : 'scrollTop'\n }\n return property\n }\n\n start() {\n this.stopped = false\n }\n\n stop() {\n this.stopped = true\n this.animate.stop()\n }\n\n destroy() {\n if (this.wrapperNode === window) {\n this.wrapperNode.removeEventListener('resize', this.onWindowResize)\n }\n this.wrapperNode.removeEventListener('scroll', this.onScroll)\n\n this.virtualScroll.destroy()\n this.wrapperObserver?.disconnect()\n this.contentObserver.disconnect()\n }\n\n onWindowResize = () => {\n this.wrapperWidth = window.innerWidth\n this.wrapperHeight = window.innerHeight\n }\n\n onWrapperResize = ([entry]) => {\n if (entry) {\n const rect = entry.contentRect\n this.wrapperWidth = rect.width\n this.wrapperHeight = rect.height\n }\n }\n\n onContentResize = ([entry]) => {\n if (entry) {\n const rect = entry.contentRect\n this.contentWidth = rect.width\n this.contentHeight = rect.height\n }\n }\n\n get limit() {\n return this.direction === 'horizontal'\n ? this.contentWidth - this.wrapperWidth\n : this.contentHeight - this.wrapperHeight\n }\n\n onVirtualScroll = ({ deltaY, deltaX, originalEvent: e }) => {\n const preventScroll = !!e\n .composedPath()\n .find(\n (node) => node.hasAttribute && node.hasAttribute('data-lenis-prevent')\n )\n\n if (e.ctrlKey || preventScroll) return\n\n // switch to smooth if event is touch and if smoothTouch=true\n this.smooth = !!e.changedTouches ? this.smoothTouch : this.options.smooth\n\n if (this.stopped) {\n e.preventDefault()\n return\n }\n\n if (!this.smooth) return\n\n // fix wheel holding scroll https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\n if (e.buttons === 4) return\n\n // prevent native wheel scrolling\n if (this.smooth) e.preventDefault()\n\n let delta = 0\n if (this.gestureDirection === 'both') {\n delta = deltaX + deltaY\n } else if (this.gestureDirection === 'horizontal') {\n delta = deltaX\n } else {\n // vertical\n delta = deltaY\n }\n\n this.targetScroll -= delta\n // this.targetScroll = clamp(0, this.targetScroll, this.limit)\n\n this.scrollTo(this.targetScroll)\n }\n\n raf(now) {\n const deltaTime = now - (this.now || 0)\n this.now = now\n\n if (this.stopped || !this.smooth) return\n\n this.lastScroll = this.scroll\n\n // where this.scroll is updated\n this.animate.raf(deltaTime * 0.001)\n\n if (this.scroll === this.targetScroll) {\n // if target reached velocity should be 0\n this.lastScroll = this.scroll\n }\n\n if (this.isScrolling) {\n this.setScroll(this.scroll)\n this.notify()\n }\n\n this.isScrolling = this.scroll !== this.targetScroll\n }\n\n get velocity() {\n return this.scroll - this.lastScroll\n }\n\n setScroll(value) {\n let scroll = this.infinite ? modulo(value, this.limit) : value\n\n this.direction === 'horizontal'\n ? this.wrapperNode.scrollTo(scroll, 0)\n : this.wrapperNode.scrollTo(0, scroll)\n }\n\n onScroll = (e) => {\n // if isScrolling false we can consider user isn't scrolling with wheel (cmd+F, keyboard or whatever). So we must scroll to value immediately\n if (!this.isScrolling || !this.smooth) {\n // where native scroll happens\n this.targetScroll =\n this.scroll =\n this.lastScroll =\n this.wrapperNode[this.scrollProperty]\n\n this.notify()\n }\n }\n\n notify() {\n let scroll = this.infinite ? modulo(this.scroll, this.limit) : this.scroll\n\n let direction = this.lastScroll < scroll ? 1 : -1\n\n this.emit('scroll', {\n scroll,\n limit: this.limit,\n velocity: this.velocity,\n direction,\n progress: scroll / this.limit,\n })\n }\n\n scrollTo(\n target,\n {\n offset = 0,\n immediate = false,\n duration = this.duration,\n easing = this.easing,\n } = {}\n ) {\n if (target === undefined || target === null) return\n let value\n\n if (typeof target === 'number') {\n value = target\n } else if (target === 'top' || target === '#top') {\n value = 0\n } else if (target === 'bottom') {\n value = this.limit\n } else {\n let node\n\n if (typeof target === 'string') {\n // CSS selector\n node = document.querySelector(target)\n } else if (target?.nodeType) {\n // Node element\n node = target\n } else {\n return\n }\n\n if (!node) return\n let wrapperOffset = 0\n\n if (this.wrapperNode !== window) {\n const wrapperRect = this.wrapperNode.getBoundingClientRect()\n wrapperOffset =\n this.direction === 'horizontal' ? wrapperRect.left : wrapperRect.top\n }\n\n const rect = node.getBoundingClientRect()\n\n value =\n (this.direction === 'horizontal' ? rect.left : rect.top) +\n this.scroll -\n wrapperOffset\n }\n\n value += offset\n\n if (this.infinite) {\n this.targetScroll = value\n } else {\n this.targetScroll = clamp(0, value, this.limit)\n }\n\n if (!this.smooth || immediate) {\n this.scroll = this.lastScroll = this.targetScroll\n this.setScroll(this.targetScroll)\n } else {\n this.animate.to(this, {\n duration,\n easing,\n scroll: this.targetScroll,\n })\n }\n }\n}\n"],"names":["modulo","value","max","v","Animate","_proto","prototype","to","target","_temp","_this","this","_ref","_ref$duration","duration","easing","_ref$easing","t","keys","_objectWithoutPropertiesLoose","_excluded","fromKeys","toKeys","Object","forEach","key","currentTime","isRunning","stop","raf","deltaTime","Math","min","progress","from","_this2","_createClass","get","_EventEmitter","Lenis","_temp2","_navigator","_navigator$userAgentD","_navigator2","_this3","_ref2","_ref2$duration","_ref2$easing","pow","_ref2$smooth","smooth","mouseMultiplier","_ref2$mouseMultiplier","smoothTouch","_ref2$smoothTouch","touchMultiplier","_ref2$touchMultiplier","direction","_ref2$direction","_ref2$gestureDirectio","gestureDirection","_ref2$infinite","infinite","wrapper","_ref2$wrapper","window","content","_ref2$content","document","body","onWindowResize","wrapperWidth","innerWidth","wrapperHeight","innerHeight","onWrapperResize","_ref3","entry","contentRect","rect","width","height","onContentResize","_ref4","contentWidth","contentHeight","onVirtualScroll","_ref5","deltaY","deltaX","e","originalEvent","preventScroll","composedPath","find","node","hasAttribute","ctrlKey","changedTouches","options","stopped","preventDefault","buttons","targetScroll","scrollTo","onScroll","isScrolling","scroll","lastScroll","wrapperNode","scrollProperty","notify","lenisVersion","contentNode","addEventListener","offsetHeight","offsetWidth","wrapperObserver","ResizeObserver","observe","contentObserver","animate","platform","navigator","userAgentData","virtualScroll","VirtualScroll","el","firefoxMultiplier","includes","passive","on","start","destroy","removeEventListener","_this$wrapperObserver","disconnect","_proto2","now","setScroll","limit","emit","velocity","_temp3","_ref6","_ref6$offset","offset","immediate","_ref6$immediate","_ref6$duration","_ref6$easing","querySelector","nodeType","getBoundingClientRect","wrapperOffset","wrapperRect","left","top","EventEmitter"],"mappings":"8iCAgBgBA,SAAAA,EAAOC,EAAOC,GAC5B,IAAKC,EAAGF,EAAQC,EAKhB,OAJIC,EAAI,IACNA,GAAKD,GAITC,CAAA,6BClBaC,eAAA,WAAA,SAAAA,IAAA,CAAA,IAAAC,EAAAD,EAAAE,iBAAAD,EACXE,GAAA,SAAGC,EAA2DC,GAAA,IAAAC,EAAAC,KAAAC,OAAA,IAAAH,EAAJ,CAAE,EAAAA,EAAAI,EAAAD,EAA/CE,SAAAA,OAAQ,IAAAD,EAAG,EAAGE,EAAAA,EAAAA,EAAAA,OAAAA,OAAM,IAAAC,EAAG,SAACC,GAAC,OAAMA,CAAA,EAAAD,EAAKE,oIAAIC,CAAAP,EAAAQ,GACnDT,KAAKH,OAASA,EACdG,KAAKU,SAAgBH,EAAAA,GAAAA,GACrBP,KAAKW,YAAcJ,GACnBP,KAAKO,KAAOK,OAAOL,KAAU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vI,KAAK4F,aADH5F,KAAKmD,SACa7D,EDtXjB8B,KAAK7B,ICwXkB,EDxXT6B,KAAKC,ICwXO/B,EAAOU,KAAKiI,SAGtCjI,KAAKuC,QAAUiG,GAClBxI,KAAKgG,OAAShG,KAAKiG,WAAajG,KAAK4F,aACrC5F,KAAKgI,UAAUhI,KAAK4F,eAEpB5F,KAAK8G,QAAQlH,GAAGI,KAAM,CACpBG,SAAAA,EACAC,OAAAA,EACA4F,OAAQhG,KAAK4F,cArDjB,CAwDF,EAACnE,EAAAG,EAAA,CAAA,CAAAd,IAAA,iBAAAY,IAnOD,WAOE,OALI1B,KAAKkG,cAAgB5C,OACO,eAAnBtD,KAAK8C,UAA6B,UAAY,UAE3B,eAAnB9C,KAAK8C,UAA6B,aAAe,WAGhE,GA2CA,CAAAhC,IAAA,QAAAY,IAAA,WACE,MAA0B,oBAAdoB,UACR9C,KAAKyE,aAAezE,KAAK4D,aACzB5D,KAAK0E,cAAgB1E,KAAK8D,aAChC,GAmEA,CAAAhD,IAAA,WAAAY,IAAA,WACE,YAAYsE,OAAShG,KAAKiG,UAC5B,KAACrE,CAAA,CA1OuB,CAASuH,EAAY"} \ No newline at end of file diff --git a/package.json b/package.json index b68c230c..31609165 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@studio-freight/lenis", - "version": "0.2.19", + "version": "0.2.20", "description": "Lenis is a smooth scroll library to normalize the scrolling experience across devices", "files": [ "dist"