diff --git a/README.md b/README.md index ffeb02ed..c5b246e3 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ import Lenis from 'lenis' using scripts: ```html - + ``` diff --git a/dist/lenis.js b/dist/lenis.js index 20b4d208..7ce64890 100644 --- a/dist/lenis.js +++ b/dist/lenis.js @@ -4,7 +4,7 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Lenis = factory()); })(this, (function () { 'use strict'; - var version = "1.1.0"; + var version = "1.1.1"; // Clamp a value between a minimum and maximum value function clamp(min, input, max) { @@ -377,9 +377,10 @@ // catch if scrolling on nested scroll elements let composedPath = event.composedPath(); composedPath = composedPath.slice(0, composedPath.indexOf(this.rootElement)); // remove parents elements + const prevent = this.options.prevent; if (!!composedPath.find((node) => { var _a, _b, _c, _d, _e; - return this.options.prevent(node) || + return (typeof prevent === 'function' ? prevent === null || prevent === void 0 ? void 0 : prevent(node) : prevent) || ((_a = node.hasAttribute) === null || _a === void 0 ? void 0 : _a.call(node, 'data-lenis-prevent')) || (isTouch && ((_b = node.hasAttribute) === null || _b === void 0 ? void 0 : _b.call(node, 'data-lenis-prevent-touch'))) || (isWheel && ((_c = node.hasAttribute) === null || _c === void 0 ? void 0 : _c.call(node, 'data-lenis-prevent-wheel'))) || diff --git a/dist/lenis.js.map b/dist/lenis.js.map index 860f3fac..7f10b1b3 100644 --- a/dist/lenis.js.map +++ b/dist/lenis.js.map @@ -1 +1 @@ -{"version":3,"file":"lenis.js","sources":["../src/maths.js","../src/animate.js","../src/debounce.js","../src/dimensions.js","../src/emitter.js","../src/virtual-scroll.js","../src/index.ts"],"sourcesContent":["// Clamp a value between a minimum and maximum value\r\nexport function clamp(min, input, max) {\r\n return Math.max(min, Math.min(input, max))\r\n}\r\n\r\n// Truncate a floating-point number to a specified number of decimal places\r\nexport function truncate(value, decimals = 0) {\r\n return parseFloat(value.toFixed(decimals))\r\n}\r\n\r\n// Linearly interpolate between two values using an amount (0 <= t <= 1)\r\nexport function lerp(x, y, t) {\r\n return (1 - t) * x + t * y\r\n}\r\n\r\n// http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/\r\nexport function damp(x, y, lambda, dt) {\r\n return lerp(x, y, 1 - Math.exp(-lambda * dt))\r\n}\r\n\r\n// Calculate the modulo of the dividend and divisor while keeping the result within the same sign as the divisor\r\n// https://anguscroll.com/just/just-modulo\r\nexport function modulo(n, d) {\r\n return ((n % d) + d) % d\r\n}\r\n","import { clamp, damp } from './maths'\r\n\r\n// Animate class to handle value animations with lerping or easing\r\nexport class Animate {\r\n // Advance the animation by the given delta time\r\n advance(deltaTime) {\r\n if (!this.isRunning) return\r\n\r\n let completed = false\r\n\r\n if (this.lerp) {\r\n this.value = damp(this.value, this.to, this.lerp * 60, deltaTime)\r\n if (Math.round(this.value) === this.to) {\r\n this.value = this.to\r\n completed = true\r\n }\r\n } else {\r\n this.currentTime += deltaTime\r\n const linearProgress = clamp(0, this.currentTime / this.duration, 1)\r\n\r\n completed = linearProgress >= 1\r\n const easedProgress = completed ? 1 : this.easing(linearProgress)\r\n this.value = this.from + (this.to - this.from) * easedProgress\r\n }\r\n\r\n if (completed) {\r\n this.stop()\r\n }\r\n\r\n // Call the onUpdate callback with the current value and completed status\r\n this.onUpdate?.(this.value, completed)\r\n }\r\n\r\n // Stop the animation\r\n stop() {\r\n this.isRunning = false\r\n }\r\n\r\n // Set up the animation from a starting value to an ending value\r\n // with optional parameters for lerping, duration, easing, and onUpdate callback\r\n fromTo(\r\n from,\r\n to,\r\n { lerp = 0.1, duration = 1, easing = (t) => t, onStart, onUpdate }\r\n ) {\r\n this.from = this.value = from\r\n this.to = to\r\n this.lerp = lerp\r\n this.duration = duration\r\n this.easing = easing\r\n this.currentTime = 0\r\n this.isRunning = true\r\n\r\n onStart?.()\r\n this.onUpdate = onUpdate\r\n }\r\n}\r\n","export function debounce(callback, delay) {\r\n let timer\r\n return function () {\r\n let args = arguments\r\n let context = this\r\n clearTimeout(timer)\r\n timer = setTimeout(function () {\r\n callback.apply(context, args)\r\n }, delay)\r\n }\r\n}\r\n","import { debounce } from './debounce'\r\n\r\nexport class Dimensions {\r\n constructor({\r\n wrapper,\r\n content,\r\n autoResize = true,\r\n debounce: debounceValue = 250,\r\n } = {}) {\r\n this.wrapper = wrapper\r\n this.content = content\r\n\r\n if (autoResize) {\r\n this.debouncedResize = debounce(this.resize, debounceValue)\r\n\r\n if (this.wrapper === window) {\r\n window.addEventListener('resize', this.debouncedResize, false)\r\n } else {\r\n this.wrapperResizeObserver = new ResizeObserver(this.debouncedResize)\r\n this.wrapperResizeObserver.observe(this.wrapper)\r\n }\r\n\r\n this.contentResizeObserver = new ResizeObserver(this.debouncedResize)\r\n this.contentResizeObserver.observe(this.content)\r\n }\r\n\r\n this.resize()\r\n }\r\n\r\n destroy() {\r\n this.wrapperResizeObserver?.disconnect()\r\n this.contentResizeObserver?.disconnect()\r\n window.removeEventListener('resize', this.debouncedResize, false)\r\n }\r\n\r\n resize = () => {\r\n this.onWrapperResize()\r\n this.onContentResize()\r\n }\r\n\r\n onWrapperResize = () => {\r\n if (this.wrapper === window) {\r\n this.width = window.innerWidth\r\n this.height = window.innerHeight\r\n } else {\r\n this.width = this.wrapper.clientWidth\r\n this.height = this.wrapper.clientHeight\r\n }\r\n }\r\n\r\n onContentResize = () => {\r\n if (this.wrapper === window) {\r\n this.scrollHeight = this.content.scrollHeight\r\n this.scrollWidth = this.content.scrollWidth\r\n } else {\r\n this.scrollHeight = this.wrapper.scrollHeight\r\n this.scrollWidth = this.wrapper.scrollWidth\r\n }\r\n }\r\n\r\n get limit() {\r\n return {\r\n x: this.scrollWidth - this.width,\r\n y: this.scrollHeight - this.height,\r\n }\r\n }\r\n}\r\n","export class Emitter {\r\n constructor() {\r\n this.events = {}\r\n }\r\n\r\n emit(event, ...args) {\r\n let callbacks = this.events[event] || []\r\n for (let i = 0, length = callbacks.length; i < length; i++) {\r\n callbacks[i](...args)\r\n }\r\n }\r\n\r\n on(event, cb) {\r\n // Add the callback to the event's callback list, or create a new list with the callback\r\n this.events[event]?.push(cb) || (this.events[event] = [cb])\r\n\r\n // Return an unsubscribe function\r\n return () => {\r\n this.events[event] = this.events[event]?.filter((i) => cb !== i)\r\n }\r\n }\r\n\r\n off(event, callback) {\r\n this.events[event] = this.events[event]?.filter((i) => callback !== i)\r\n }\r\n\r\n destroy() {\r\n this.events = {}\r\n }\r\n}\r\n","import { Emitter } from './emitter'\r\n\r\nconst LINE_HEIGHT = 100 / 6\r\n\r\nexport class VirtualScroll {\r\n constructor(element, { wheelMultiplier = 1, touchMultiplier = 1 }) {\r\n this.element = element\r\n this.wheelMultiplier = wheelMultiplier\r\n this.touchMultiplier = touchMultiplier\r\n\r\n this.touchStart = {\r\n x: null,\r\n y: null,\r\n }\r\n\r\n this.emitter = new Emitter()\r\n window.addEventListener('resize', this.onWindowResize, false)\r\n this.onWindowResize()\r\n\r\n this.element.addEventListener('wheel', this.onWheel, { passive: false })\r\n this.element.addEventListener('touchstart', this.onTouchStart, {\r\n passive: false,\r\n })\r\n this.element.addEventListener('touchmove', this.onTouchMove, {\r\n passive: false,\r\n })\r\n this.element.addEventListener('touchend', this.onTouchEnd, {\r\n passive: false,\r\n })\r\n }\r\n\r\n // Add an event listener for the given event and callback\r\n on(event, callback) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n // Remove all event listeners and clean up\r\n destroy() {\r\n this.emitter.destroy()\r\n\r\n window.removeEventListener('resize', this.onWindowResize, false)\r\n\r\n this.element.removeEventListener('wheel', this.onWheel, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchstart', this.onTouchStart, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchmove', this.onTouchMove, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchend', this.onTouchEnd, {\r\n passive: false,\r\n })\r\n }\r\n\r\n // Event handler for 'touchstart' event\r\n onTouchStart = (event) => {\r\n const { clientX, clientY } = event.targetTouches\r\n ? event.targetTouches[0]\r\n : event\r\n\r\n this.touchStart.x = clientX\r\n this.touchStart.y = clientY\r\n\r\n this.lastDelta = {\r\n x: 0,\r\n y: 0,\r\n }\r\n\r\n this.emitter.emit('scroll', {\r\n deltaX: 0,\r\n deltaY: 0,\r\n event,\r\n })\r\n }\r\n\r\n // Event handler for 'touchmove' event\r\n onTouchMove = (event) => {\r\n const { clientX, clientY } = event.targetTouches\r\n ? event.targetTouches[0]\r\n : event\r\n\r\n const deltaX = -(clientX - this.touchStart.x) * this.touchMultiplier\r\n const deltaY = -(clientY - this.touchStart.y) * this.touchMultiplier\r\n\r\n this.touchStart.x = clientX\r\n this.touchStart.y = clientY\r\n\r\n this.lastDelta = {\r\n x: deltaX,\r\n y: deltaY,\r\n }\r\n\r\n this.emitter.emit('scroll', {\r\n deltaX,\r\n deltaY,\r\n event,\r\n })\r\n }\r\n\r\n onTouchEnd = (event) => {\r\n this.emitter.emit('scroll', {\r\n deltaX: this.lastDelta.x,\r\n deltaY: this.lastDelta.y,\r\n event,\r\n })\r\n }\r\n\r\n // Event handler for 'wheel' event\r\n onWheel = (event) => {\r\n let { deltaX, deltaY, deltaMode } = event\r\n\r\n const multiplierX =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.windowWidth : 1\r\n const multiplierY =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.windowHeight : 1\r\n\r\n deltaX *= multiplierX\r\n deltaY *= multiplierY\r\n\r\n deltaX *= this.wheelMultiplier\r\n deltaY *= this.wheelMultiplier\r\n\r\n this.emitter.emit('scroll', { deltaX, deltaY, event })\r\n }\r\n\r\n onWindowResize = () => {\r\n this.windowWidth = window.innerWidth\r\n this.windowHeight = window.innerHeight\r\n }\r\n}\r\n","import { version } from '../../../package.json'\r\nimport { Animate } from './animate'\r\nimport { Dimensions } from './dimensions'\r\nimport { Emitter } from './emitter'\r\nimport { clamp, modulo } from './maths'\r\nimport { VirtualScroll } from './virtual-scroll'\r\n\r\n// Technical explanation\r\n// - listen to 'wheel' events\r\n// - prevent 'wheel' event to prevent scroll\r\n// - normalize wheel delta\r\n// - add delta to targetScroll\r\n// - animate scroll to targetScroll (smooth context)\r\n// - if animation is not running, listen to 'scroll' events (native context)\r\n\r\ntype EasingFunction = (t: number) => number\r\ntype Orientation = 'vertical' | 'horizontal'\r\ntype GestureOrientation = 'vertical' | 'horizontal' | 'both'\r\n\r\nexport type LenisOptions = {\r\n wrapper?: Window | HTMLElement\r\n content?: HTMLElement\r\n wheelEventsTarget?: Window | HTMLElement\r\n eventsTarget?: Window | HTMLElement\r\n smoothWheel?: boolean\r\n syncTouch?: boolean\r\n syncTouchLerp?: number\r\n touchInertiaMultiplier?: number\r\n duration?: number\r\n easing?: EasingFunction\r\n lerp?: number\r\n infinite?: boolean\r\n orientation?: Orientation\r\n gestureOrientation?: GestureOrientation\r\n touchMultiplier?: number\r\n wheelMultiplier?: number\r\n autoResize?: boolean\r\n prevent?: boolean | ((node: Element) => boolean)\r\n __experimental__naiveDimensions?: boolean\r\n}\r\n\r\nexport default class Lenis {\r\n // __isSmooth: boolean = false // true if scroll should be animated\r\n __isScrolling: boolean | 'native' | 'smooth' = false // true when scroll is animating\r\n __isStopped: boolean = false // true if user should not be able to scroll - enable/disable programmatically\r\n __isLocked: boolean = false // same as isStopped but enabled/disabled when scroll reaches target\r\n\r\n time: number\r\n userData: object\r\n lastVelocity: number\r\n velocity: number\r\n direction: 1 | -1 | undefined\r\n options: LenisOptions\r\n targetScroll: number\r\n animatedScroll: number\r\n // animate: Animate\r\n // emitter: Emitter\r\n // dimensions: Dimensions\r\n // virtualScroll: VirtualScroll\r\n\r\n constructor({\r\n wrapper = window,\r\n content = document.documentElement,\r\n wheelEventsTarget = wrapper, // deprecated\r\n eventsTarget = wheelEventsTarget,\r\n smoothWheel = true,\r\n syncTouch = false,\r\n syncTouchLerp = 0.075,\r\n touchInertiaMultiplier = 35,\r\n duration, // in seconds\r\n easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),\r\n lerp = !duration && 0.1,\r\n infinite = false,\r\n orientation = 'vertical', // vertical, horizontal\r\n gestureOrientation = 'vertical', // vertical, horizontal, both\r\n touchMultiplier = 1,\r\n wheelMultiplier = 1,\r\n autoResize = true,\r\n prevent = false,\r\n __experimental__naiveDimensions = false,\r\n }: LenisOptions = {}) {\r\n window.lenisVersion = version\r\n\r\n // if wrapper is html or body, fallback to window\r\n if (wrapper === document.documentElement || wrapper === document.body) {\r\n wrapper = window\r\n }\r\n\r\n this.options = {\r\n wrapper,\r\n content,\r\n wheelEventsTarget,\r\n eventsTarget,\r\n smoothWheel,\r\n syncTouch,\r\n syncTouchLerp,\r\n touchInertiaMultiplier,\r\n duration,\r\n easing,\r\n lerp,\r\n infinite,\r\n gestureOrientation,\r\n orientation,\r\n touchMultiplier,\r\n wheelMultiplier,\r\n autoResize,\r\n prevent,\r\n __experimental__naiveDimensions,\r\n }\r\n\r\n this.animate = new Animate()\r\n this.emitter = new Emitter()\r\n this.dimensions = new Dimensions({ wrapper, content, autoResize })\r\n // this.toggleClassName('lenis', true)\r\n this.updateClassName()\r\n\r\n this.userData = {}\r\n this.time = 0\r\n this.velocity = this.lastVelocity = 0\r\n this.isLocked = false\r\n this.isStopped = false\r\n // this.hasScrolled = false\r\n // this.isSmooth = syncTouch || smoothWheel\r\n // this.isSmooth = false\r\n this.isScrolling = false\r\n this.targetScroll = this.animatedScroll = this.actualScroll\r\n\r\n this.options.wrapper.addEventListener('scroll', this.onNativeScroll, false)\r\n\r\n this.virtualScroll = new VirtualScroll(eventsTarget, {\r\n touchMultiplier,\r\n wheelMultiplier,\r\n })\r\n this.virtualScroll.on('scroll', this.onVirtualScroll)\r\n }\r\n\r\n destroy() {\r\n this.emitter.destroy()\r\n\r\n this.options.wrapper.removeEventListener(\r\n 'scroll',\r\n this.onNativeScroll,\r\n false\r\n )\r\n\r\n this.virtualScroll.destroy()\r\n this.dimensions.destroy()\r\n\r\n this.cleanUpClassName()\r\n\r\n // this.rootElement.className = ''\r\n\r\n // this.toggleClassName('lenis', false)\r\n // this.toggleClassName('lenis-smooth', false)\r\n // this.toggleClassName('lenis-scrolling', false)\r\n // this.toggleClassName('lenis-stopped', false)\r\n // this.toggleClassName('lenis-locked', false)\r\n }\r\n\r\n on(event: string, callback: Function) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n off(event: string, callback: Function) {\r\n return this.emitter.off(event, callback)\r\n }\r\n\r\n private setScroll(scroll) {\r\n // apply scroll value immediately\r\n if (this.isHorizontal) {\r\n this.rootElement.scrollLeft = scroll\r\n } else {\r\n this.rootElement.scrollTop = scroll\r\n }\r\n }\r\n\r\n private onVirtualScroll = ({ deltaX, deltaY, event }) => {\r\n // keep zoom feature\r\n if (event.ctrlKey) return\r\n\r\n const isTouch = event.type.includes('touch')\r\n const isWheel = event.type.includes('wheel')\r\n\r\n this.isTouching = event.type === 'touchstart' || event.type === 'touchmove'\r\n // if (event.type === 'touchend') {\r\n // console.log('touchend', this.scroll)\r\n // // this.lastVelocity = this.velocity\r\n // // this.velocity = 0\r\n // // this.isScrolling = false\r\n // this.emit({ type: 'touchend' })\r\n // // alert('touchend')\r\n // return\r\n // }\r\n\r\n const isTapToStop =\r\n this.options.syncTouch &&\r\n isTouch &&\r\n event.type === 'touchstart' &&\r\n !this.isStopped &&\r\n !this.isLocked\r\n\r\n if (isTapToStop) {\r\n this.reset()\r\n return\r\n }\r\n\r\n const isClick = deltaX === 0 && deltaY === 0 // click event\r\n\r\n // const isPullToRefresh =\r\n // this.options.gestureOrientation === 'vertical' &&\r\n // this.scroll === 0 &&\r\n // !this.options.infinite &&\r\n // deltaY <= 5 // touch pull to refresh, not reliable yet\r\n\r\n const isUnknownGesture =\r\n (this.options.gestureOrientation === 'vertical' && deltaY === 0) ||\r\n (this.options.gestureOrientation === 'horizontal' && deltaX === 0)\r\n\r\n if (isClick || isUnknownGesture) {\r\n // console.log('prevent')\r\n return\r\n }\r\n\r\n // catch if scrolling on nested scroll elements\r\n let composedPath = event.composedPath()\r\n composedPath = composedPath.slice(0, composedPath.indexOf(this.rootElement)) // remove parents elements\r\n\r\n if (\r\n !!composedPath.find(\r\n (node) =>\r\n this.options.prevent(node) ||\r\n node.hasAttribute?.('data-lenis-prevent') ||\r\n (isTouch && node.hasAttribute?.('data-lenis-prevent-touch')) ||\r\n (isWheel && node.hasAttribute?.('data-lenis-prevent-wheel')) ||\r\n (node.classList?.contains('lenis') &&\r\n !node.classList?.contains('lenis-stopped')) // nested lenis instance\r\n )\r\n )\r\n return\r\n\r\n if (this.isStopped || this.isLocked) {\r\n event.preventDefault() // this will stop forwarding the event to the parent, this is problematic\r\n return\r\n }\r\n\r\n const isSmooth =\r\n (this.options.syncTouch && isTouch) ||\r\n (this.options.smoothWheel && isWheel)\r\n\r\n if (!isSmooth) {\r\n this.isScrolling = 'native'\r\n this.animate.stop()\r\n return\r\n }\r\n\r\n event.preventDefault()\r\n\r\n let delta = deltaY\r\n if (this.options.gestureOrientation === 'both') {\r\n delta = Math.abs(deltaY) > Math.abs(deltaX) ? deltaY : deltaX\r\n } else if (this.options.gestureOrientation === 'horizontal') {\r\n delta = deltaX\r\n }\r\n\r\n const syncTouch = isTouch && this.options.syncTouch\r\n const isTouchEnd = isTouch && event.type === 'touchend'\r\n\r\n const hasTouchInertia = isTouchEnd && Math.abs(delta) > 5\r\n\r\n if (hasTouchInertia) {\r\n delta = this.velocity * this.options.touchInertiaMultiplier\r\n }\r\n\r\n this.scrollTo(this.targetScroll + delta, {\r\n programmatic: false,\r\n ...(syncTouch\r\n ? {\r\n lerp: hasTouchInertia ? this.options.syncTouchLerp : 1,\r\n }\r\n : {\r\n lerp: this.options.lerp,\r\n duration: this.options.duration,\r\n easing: this.options.easing,\r\n }),\r\n })\r\n }\r\n\r\n resize() {\r\n this.dimensions.resize()\r\n }\r\n\r\n private emit({ userData = {} } = {}) {\r\n this.userData = userData\r\n this.emitter.emit('scroll', this)\r\n this.userData = {}\r\n }\r\n\r\n private onNativeScroll = () => {\r\n clearTimeout(this.__resetVelocityTimeout)\r\n delete this.__resetVelocityTimeout\r\n\r\n if (this.__preventNextNativeScrollEvent) {\r\n delete this.__preventNextNativeScrollEvent\r\n return\r\n }\r\n\r\n if (this.isScrolling === false || this.isScrolling === 'native') {\r\n const lastScroll = this.animatedScroll\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.lastVelocity = this.velocity\r\n this.velocity = this.animatedScroll - lastScroll\r\n this.direction = Math.sign(this.animatedScroll - lastScroll)\r\n // this.isSmooth = false\r\n this.isScrolling = this.hasScrolled ? 'native' : false\r\n this.emit()\r\n\r\n if (this.velocity !== 0) {\r\n this.__resetVelocityTimeout = setTimeout(() => {\r\n this.lastVelocity = this.velocity\r\n this.velocity = 0\r\n this.isScrolling = false\r\n this.emit()\r\n }, 400)\r\n }\r\n\r\n // this.hasScrolled = true\r\n // }, 50)\r\n }\r\n }\r\n\r\n private reset() {\r\n this.isLocked = false\r\n this.isScrolling = false\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.lastVelocity = this.velocity = 0\r\n this.animate.stop()\r\n }\r\n\r\n start() {\r\n if (!this.isStopped) return\r\n this.isStopped = false\r\n\r\n this.reset()\r\n }\r\n\r\n stop() {\r\n if (this.isStopped) return\r\n this.isStopped = true\r\n this.animate.stop()\r\n\r\n this.reset()\r\n }\r\n\r\n raf(time: number) {\r\n const deltaTime = time - (this.time || time)\r\n this.time = time\r\n\r\n this.animate.advance(deltaTime * 0.001)\r\n }\r\n\r\n scrollTo(\r\n target: number | string | HTMLElement,\r\n {\r\n offset = 0,\r\n immediate = false,\r\n lock = false,\r\n duration = this.options.duration,\r\n easing = this.options.easing,\r\n lerp = !duration && this.options.lerp,\r\n onStart,\r\n onComplete,\r\n force = false, // scroll even if stopped\r\n programmatic = true, // called from outside of the class\r\n userData = {},\r\n }: {\r\n offset?: number\r\n immediate?: boolean\r\n lock?: boolean\r\n duration?: number\r\n easing?: EasingFunction\r\n lerp?: number\r\n onStart?: (lenis: Lenis) => void\r\n onComplete?: (lenis: Lenis) => void\r\n force?: boolean\r\n programmatic?: boolean\r\n userData?: object\r\n } = {}\r\n ) {\r\n if ((this.isStopped || this.isLocked) && !force) return\r\n\r\n // keywords\r\n if (['top', 'left', 'start'].includes(target)) {\r\n target = 0\r\n } else if (['bottom', 'right', 'end'].includes(target)) {\r\n target = 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 }\r\n\r\n if (node) {\r\n if (this.options.wrapper !== window) {\r\n // nested scroll offset correction\r\n const wrapperRect = this.options.wrapper.getBoundingClientRect()\r\n offset -= this.isHorizontal ? wrapperRect.left : wrapperRect.top\r\n }\r\n\r\n const rect = node.getBoundingClientRect()\r\n\r\n target =\r\n (this.isHorizontal ? rect.left : rect.top) + this.animatedScroll\r\n }\r\n }\r\n\r\n if (typeof target !== 'number') return\r\n\r\n target += offset\r\n target = Math.round(target)\r\n\r\n if (this.options.infinite) {\r\n if (programmatic) {\r\n this.targetScroll = this.animatedScroll = this.scroll\r\n }\r\n } else {\r\n target = clamp(0, target, this.limit)\r\n }\r\n\r\n if (immediate) {\r\n this.animatedScroll = this.targetScroll = target\r\n this.setScroll(this.scroll)\r\n this.reset()\r\n onComplete?.(this)\r\n return\r\n }\r\n\r\n if (target === this.targetScroll) return\r\n\r\n if (!programmatic) {\r\n this.targetScroll = target\r\n }\r\n\r\n this.animate.fromTo(this.animatedScroll, target, {\r\n duration,\r\n easing,\r\n lerp,\r\n onStart: () => {\r\n // started\r\n if (lock) this.isLocked = true\r\n this.isScrolling = 'smooth'\r\n onStart?.(this)\r\n },\r\n onUpdate: (value: number, completed: boolean) => {\r\n this.isScrolling = 'smooth'\r\n\r\n // updated\r\n this.lastVelocity = this.velocity\r\n this.velocity = value - this.animatedScroll\r\n this.direction = Math.sign(this.velocity)\r\n\r\n this.animatedScroll = value\r\n this.setScroll(this.scroll)\r\n\r\n if (programmatic) {\r\n // wheel during programmatic should stop it\r\n this.targetScroll = value\r\n }\r\n\r\n if (!completed) this.emit({ userData })\r\n\r\n if (completed) {\r\n this.reset()\r\n this.emit({ userData })\r\n onComplete?.(this)\r\n\r\n // avoid emitting event twice\r\n this.__preventNextNativeScrollEvent = true\r\n // requestAnimationFrame(() => {\r\n // delete this.__preventNextNativeScrollEvent\r\n // })\r\n }\r\n },\r\n })\r\n }\r\n\r\n get rootElement() {\r\n return this.options.wrapper === window\r\n ? document.documentElement\r\n : this.options.wrapper\r\n }\r\n\r\n get limit() {\r\n if (this.options.__experimental__naiveDimensions) {\r\n if (this.isHorizontal) {\r\n return this.rootElement.scrollWidth - this.rootElement.clientWidth\r\n } else {\r\n return this.rootElement.scrollHeight - this.rootElement.clientHeight\r\n }\r\n } else {\r\n return this.dimensions.limit[this.isHorizontal ? 'x' : 'y']\r\n }\r\n }\r\n\r\n get isHorizontal() {\r\n return this.options.orientation === 'horizontal'\r\n }\r\n\r\n get actualScroll(): number {\r\n // value browser takes into account\r\n return this.isHorizontal\r\n ? this.rootElement.scrollLeft\r\n : this.rootElement.scrollTop\r\n }\r\n\r\n get scroll(): number {\r\n return this.options.infinite\r\n ? modulo(this.animatedScroll, this.limit)\r\n : this.animatedScroll\r\n }\r\n\r\n get progress(): number {\r\n // avoid progress to be NaN\r\n return this.limit === 0 ? 1 : this.scroll / this.limit\r\n }\r\n\r\n // get isSmooth() {\r\n // return this.__isSmooth\r\n // }\r\n\r\n // private set isSmooth(value: boolean) {\r\n // if (this.__isSmooth !== value) {\r\n // this.__isSmooth = value\r\n // this.updateClassName()\r\n // }\r\n // }\r\n\r\n get isScrolling() {\r\n return this.__isScrolling\r\n }\r\n\r\n private set isScrolling(value: boolean) {\r\n if (this.__isScrolling !== value) {\r\n this.__isScrolling = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isStopped() {\r\n return this.__isStopped\r\n }\r\n\r\n private set isStopped(value: boolean) {\r\n if (this.__isStopped !== value) {\r\n this.__isStopped = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isLocked() {\r\n return this.__isLocked\r\n }\r\n\r\n private set isLocked(value: boolean) {\r\n if (this.__isLocked !== value) {\r\n this.__isLocked = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isSmooth() {\r\n return this.isScrolling === 'smooth'\r\n }\r\n\r\n get className() {\r\n let className = 'lenis'\r\n if (this.isStopped) className += ' lenis-stopped'\r\n if (this.isLocked) className += ' lenis-locked'\r\n if (this.isScrolling) className += ' lenis-scrolling'\r\n if (this.isScrolling === 'smooth') className += ' lenis-smooth'\r\n // if (this.isScrolling === 'native') className += ' lenis-native'\r\n // if (this.isSmooth) className += ' lenis-smooth'\r\n return className\r\n }\r\n\r\n private updateClassName() {\r\n this.cleanUpClassName()\r\n\r\n this.rootElement.className =\r\n `${this.rootElement.className} ${this.className}`.trim()\r\n // this.emitter.emit('className change', this)\r\n }\r\n\r\n private cleanUpClassName() {\r\n this.rootElement.className = this.rootElement.className\r\n .replace(/lenis(-\\w+)?/g, '')\r\n .trim()\r\n }\r\n\r\n // private toggleClassName(name: string, value: boolean) {\r\n // // this.rootElement.classList.toggle(name, value)\r\n // this.rootElement.className = this.className\r\n // this.emitter.emit('className change', this)\r\n // }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;EAAA;EACO,SAAS,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE;EACvC,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;EAC5C,CAAC;AAMD;EACA;EACO,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;EAC9B,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;EAC5B,CAAC;AACD;EACA;EACO,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAA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AS,IAAI,eAAe,CAAA;UAC/C,IAAI,IAAI,CAAC,WAAW;cAAE,SAAS,IAAI,kBAAkB,CAAA;EACrD,QAAA,IAAI,IAAI,CAAC,WAAW,KAAK,QAAQ;cAAE,SAAS,IAAI,eAAe,CAAA;;;EAG/D,QAAA,OAAO,SAAS,CAAA;OACjB;MAEO,eAAe,GAAA;UACrB,IAAI,CAAC,gBAAgB,EAAE,CAAA;UAEvB,IAAI,CAAC,WAAW,CAAC,SAAS;EACxB,YAAA,CAAA,EAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAA,CAAA,EAAI,IAAI,CAAC,SAAS,CAAA,CAAE,CAAC,IAAI,EAAE,CAAA;;OAE3D;MAEO,gBAAgB,GAAA;UACtB,IAAI,CAAC,WAAW,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS;EACpD,aAAA,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;EAC5B,aAAA,IAAI,EAAE,CAAA;OACV;EAOF;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"lenis.js","sources":["../src/maths.js","../src/animate.js","../src/debounce.js","../src/dimensions.js","../src/emitter.js","../src/virtual-scroll.js","../src/index.ts"],"sourcesContent":["// Clamp a value between a minimum and maximum value\r\nexport function clamp(min, input, max) {\r\n return Math.max(min, Math.min(input, max))\r\n}\r\n\r\n// Truncate a floating-point number to a specified number of decimal places\r\nexport function truncate(value, decimals = 0) {\r\n return parseFloat(value.toFixed(decimals))\r\n}\r\n\r\n// Linearly interpolate between two values using an amount (0 <= t <= 1)\r\nexport function lerp(x, y, t) {\r\n return (1 - t) * x + t * y\r\n}\r\n\r\n// http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/\r\nexport function damp(x, y, lambda, dt) {\r\n return lerp(x, y, 1 - Math.exp(-lambda * dt))\r\n}\r\n\r\n// Calculate the modulo of the dividend and divisor while keeping the result within the same sign as the divisor\r\n// https://anguscroll.com/just/just-modulo\r\nexport function modulo(n, d) {\r\n return ((n % d) + d) % d\r\n}\r\n","import { clamp, damp } from './maths'\r\n\r\n// Animate class to handle value animations with lerping or easing\r\nexport class Animate {\r\n // Advance the animation by the given delta time\r\n advance(deltaTime) {\r\n if (!this.isRunning) return\r\n\r\n let completed = false\r\n\r\n if (this.lerp) {\r\n this.value = damp(this.value, this.to, this.lerp * 60, deltaTime)\r\n if (Math.round(this.value) === this.to) {\r\n this.value = this.to\r\n completed = true\r\n }\r\n } else {\r\n this.currentTime += deltaTime\r\n const linearProgress = clamp(0, this.currentTime / this.duration, 1)\r\n\r\n completed = linearProgress >= 1\r\n const easedProgress = completed ? 1 : this.easing(linearProgress)\r\n this.value = this.from + (this.to - this.from) * easedProgress\r\n }\r\n\r\n if (completed) {\r\n this.stop()\r\n }\r\n\r\n // Call the onUpdate callback with the current value and completed status\r\n this.onUpdate?.(this.value, completed)\r\n }\r\n\r\n // Stop the animation\r\n stop() {\r\n this.isRunning = false\r\n }\r\n\r\n // Set up the animation from a starting value to an ending value\r\n // with optional parameters for lerping, duration, easing, and onUpdate callback\r\n fromTo(\r\n from,\r\n to,\r\n { lerp = 0.1, duration = 1, easing = (t) => t, onStart, onUpdate }\r\n ) {\r\n this.from = this.value = from\r\n this.to = to\r\n this.lerp = lerp\r\n this.duration = duration\r\n this.easing = easing\r\n this.currentTime = 0\r\n this.isRunning = true\r\n\r\n onStart?.()\r\n this.onUpdate = onUpdate\r\n }\r\n}\r\n","export function debounce(callback, delay) {\r\n let timer\r\n return function () {\r\n let args = arguments\r\n let context = this\r\n clearTimeout(timer)\r\n timer = setTimeout(function () {\r\n callback.apply(context, args)\r\n }, delay)\r\n }\r\n}\r\n","import { debounce } from './debounce'\r\n\r\nexport class Dimensions {\r\n constructor({\r\n wrapper,\r\n content,\r\n autoResize = true,\r\n debounce: debounceValue = 250,\r\n } = {}) {\r\n this.wrapper = wrapper\r\n this.content = content\r\n\r\n if (autoResize) {\r\n this.debouncedResize = debounce(this.resize, debounceValue)\r\n\r\n if (this.wrapper === window) {\r\n window.addEventListener('resize', this.debouncedResize, false)\r\n } else {\r\n this.wrapperResizeObserver = new ResizeObserver(this.debouncedResize)\r\n this.wrapperResizeObserver.observe(this.wrapper)\r\n }\r\n\r\n this.contentResizeObserver = new ResizeObserver(this.debouncedResize)\r\n this.contentResizeObserver.observe(this.content)\r\n }\r\n\r\n this.resize()\r\n }\r\n\r\n destroy() {\r\n this.wrapperResizeObserver?.disconnect()\r\n this.contentResizeObserver?.disconnect()\r\n window.removeEventListener('resize', this.debouncedResize, false)\r\n }\r\n\r\n resize = () => {\r\n this.onWrapperResize()\r\n this.onContentResize()\r\n }\r\n\r\n onWrapperResize = () => {\r\n if (this.wrapper === window) {\r\n this.width = window.innerWidth\r\n this.height = window.innerHeight\r\n } else {\r\n this.width = this.wrapper.clientWidth\r\n this.height = this.wrapper.clientHeight\r\n }\r\n }\r\n\r\n onContentResize = () => {\r\n if (this.wrapper === window) {\r\n this.scrollHeight = this.content.scrollHeight\r\n this.scrollWidth = this.content.scrollWidth\r\n } else {\r\n this.scrollHeight = this.wrapper.scrollHeight\r\n this.scrollWidth = this.wrapper.scrollWidth\r\n }\r\n }\r\n\r\n get limit() {\r\n return {\r\n x: this.scrollWidth - this.width,\r\n y: this.scrollHeight - this.height,\r\n }\r\n }\r\n}\r\n","export class Emitter {\r\n constructor() {\r\n this.events = {}\r\n }\r\n\r\n emit(event, ...args) {\r\n let callbacks = this.events[event] || []\r\n for (let i = 0, length = callbacks.length; i < length; i++) {\r\n callbacks[i](...args)\r\n }\r\n }\r\n\r\n on(event, cb) {\r\n // Add the callback to the event's callback list, or create a new list with the callback\r\n this.events[event]?.push(cb) || (this.events[event] = [cb])\r\n\r\n // Return an unsubscribe function\r\n return () => {\r\n this.events[event] = this.events[event]?.filter((i) => cb !== i)\r\n }\r\n }\r\n\r\n off(event, callback) {\r\n this.events[event] = this.events[event]?.filter((i) => callback !== i)\r\n }\r\n\r\n destroy() {\r\n this.events = {}\r\n }\r\n}\r\n","import { Emitter } from './emitter'\r\n\r\nconst LINE_HEIGHT = 100 / 6\r\n\r\nexport class VirtualScroll {\r\n constructor(element, { wheelMultiplier = 1, touchMultiplier = 1 }) {\r\n this.element = element\r\n this.wheelMultiplier = wheelMultiplier\r\n this.touchMultiplier = touchMultiplier\r\n\r\n this.touchStart = {\r\n x: null,\r\n y: null,\r\n }\r\n\r\n this.emitter = new Emitter()\r\n window.addEventListener('resize', this.onWindowResize, false)\r\n this.onWindowResize()\r\n\r\n this.element.addEventListener('wheel', this.onWheel, { passive: false })\r\n this.element.addEventListener('touchstart', this.onTouchStart, {\r\n passive: false,\r\n })\r\n this.element.addEventListener('touchmove', this.onTouchMove, {\r\n passive: false,\r\n })\r\n this.element.addEventListener('touchend', this.onTouchEnd, {\r\n passive: false,\r\n })\r\n }\r\n\r\n // Add an event listener for the given event and callback\r\n on(event, callback) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n // Remove all event listeners and clean up\r\n destroy() {\r\n this.emitter.destroy()\r\n\r\n window.removeEventListener('resize', this.onWindowResize, false)\r\n\r\n this.element.removeEventListener('wheel', this.onWheel, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchstart', this.onTouchStart, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchmove', this.onTouchMove, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchend', this.onTouchEnd, {\r\n passive: false,\r\n })\r\n }\r\n\r\n // Event handler for 'touchstart' event\r\n onTouchStart = (event) => {\r\n const { clientX, clientY } = event.targetTouches\r\n ? event.targetTouches[0]\r\n : event\r\n\r\n this.touchStart.x = clientX\r\n this.touchStart.y = clientY\r\n\r\n this.lastDelta = {\r\n x: 0,\r\n y: 0,\r\n }\r\n\r\n this.emitter.emit('scroll', {\r\n deltaX: 0,\r\n deltaY: 0,\r\n event,\r\n })\r\n }\r\n\r\n // Event handler for 'touchmove' event\r\n onTouchMove = (event) => {\r\n const { clientX, clientY } = event.targetTouches\r\n ? event.targetTouches[0]\r\n : event\r\n\r\n const deltaX = -(clientX - this.touchStart.x) * this.touchMultiplier\r\n const deltaY = -(clientY - this.touchStart.y) * this.touchMultiplier\r\n\r\n this.touchStart.x = clientX\r\n this.touchStart.y = clientY\r\n\r\n this.lastDelta = {\r\n x: deltaX,\r\n y: deltaY,\r\n }\r\n\r\n this.emitter.emit('scroll', {\r\n deltaX,\r\n deltaY,\r\n event,\r\n })\r\n }\r\n\r\n onTouchEnd = (event) => {\r\n this.emitter.emit('scroll', {\r\n deltaX: this.lastDelta.x,\r\n deltaY: this.lastDelta.y,\r\n event,\r\n })\r\n }\r\n\r\n // Event handler for 'wheel' event\r\n onWheel = (event) => {\r\n let { deltaX, deltaY, deltaMode } = event\r\n\r\n const multiplierX =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.windowWidth : 1\r\n const multiplierY =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.windowHeight : 1\r\n\r\n deltaX *= multiplierX\r\n deltaY *= multiplierY\r\n\r\n deltaX *= this.wheelMultiplier\r\n deltaY *= this.wheelMultiplier\r\n\r\n this.emitter.emit('scroll', { deltaX, deltaY, event })\r\n }\r\n\r\n onWindowResize = () => {\r\n this.windowWidth = window.innerWidth\r\n this.windowHeight = window.innerHeight\r\n }\r\n}\r\n","import { version } from '../../../package.json'\r\nimport { Animate } from './animate'\r\nimport { Dimensions } from './dimensions'\r\nimport { Emitter } from './emitter'\r\nimport { clamp, modulo } from './maths'\r\nimport { VirtualScroll } from './virtual-scroll'\r\n\r\n// Technical explanation\r\n// - listen to 'wheel' events\r\n// - prevent 'wheel' event to prevent scroll\r\n// - normalize wheel delta\r\n// - add delta to targetScroll\r\n// - animate scroll to targetScroll (smooth context)\r\n// - if animation is not running, listen to 'scroll' events (native context)\r\n\r\ntype EasingFunction = (t: number) => number\r\ntype Orientation = 'vertical' | 'horizontal'\r\ntype GestureOrientation = 'vertical' | 'horizontal' | 'both'\r\n\r\nexport type LenisOptions = {\r\n wrapper?: Window | HTMLElement\r\n content?: HTMLElement\r\n wheelEventsTarget?: Window | HTMLElement\r\n eventsTarget?: Window | HTMLElement\r\n smoothWheel?: boolean\r\n syncTouch?: boolean\r\n syncTouchLerp?: number\r\n touchInertiaMultiplier?: number\r\n duration?: number\r\n easing?: EasingFunction\r\n lerp?: number\r\n infinite?: boolean\r\n orientation?: Orientation\r\n gestureOrientation?: GestureOrientation\r\n touchMultiplier?: number\r\n wheelMultiplier?: number\r\n autoResize?: boolean\r\n prevent?: boolean | ((node: Element) => boolean)\r\n __experimental__naiveDimensions?: boolean\r\n}\r\n\r\nexport default class Lenis {\r\n // __isSmooth: boolean = false // true if scroll should be animated\r\n __isScrolling: boolean | 'native' | 'smooth' = false // true when scroll is animating\r\n __isStopped: boolean = false // true if user should not be able to scroll - enable/disable programmatically\r\n __isLocked: boolean = false // same as isStopped but enabled/disabled when scroll reaches target\r\n\r\n time: number\r\n userData: object\r\n lastVelocity: number\r\n velocity: number\r\n direction: 1 | -1 | undefined\r\n options: LenisOptions\r\n targetScroll: number\r\n animatedScroll: number\r\n // animate: Animate\r\n // emitter: Emitter\r\n // dimensions: Dimensions\r\n // virtualScroll: VirtualScroll\r\n\r\n constructor({\r\n wrapper = window,\r\n content = document.documentElement,\r\n wheelEventsTarget = wrapper, // deprecated\r\n eventsTarget = wheelEventsTarget,\r\n smoothWheel = true,\r\n syncTouch = false,\r\n syncTouchLerp = 0.075,\r\n touchInertiaMultiplier = 35,\r\n duration, // in seconds\r\n easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),\r\n lerp = !duration && 0.1,\r\n infinite = false,\r\n orientation = 'vertical', // vertical, horizontal\r\n gestureOrientation = 'vertical', // vertical, horizontal, both\r\n touchMultiplier = 1,\r\n wheelMultiplier = 1,\r\n autoResize = true,\r\n prevent = false,\r\n __experimental__naiveDimensions = false,\r\n }: LenisOptions = {}) {\r\n window.lenisVersion = version\r\n\r\n // if wrapper is html or body, fallback to window\r\n if (wrapper === document.documentElement || wrapper === document.body) {\r\n wrapper = window\r\n }\r\n\r\n this.options = {\r\n wrapper,\r\n content,\r\n wheelEventsTarget,\r\n eventsTarget,\r\n smoothWheel,\r\n syncTouch,\r\n syncTouchLerp,\r\n touchInertiaMultiplier,\r\n duration,\r\n easing,\r\n lerp,\r\n infinite,\r\n gestureOrientation,\r\n orientation,\r\n touchMultiplier,\r\n wheelMultiplier,\r\n autoResize,\r\n prevent,\r\n __experimental__naiveDimensions,\r\n }\r\n\r\n this.animate = new Animate()\r\n this.emitter = new Emitter()\r\n this.dimensions = new Dimensions({ wrapper, content, autoResize })\r\n // this.toggleClassName('lenis', true)\r\n this.updateClassName()\r\n\r\n this.userData = {}\r\n this.time = 0\r\n this.velocity = this.lastVelocity = 0\r\n this.isLocked = false\r\n this.isStopped = false\r\n // this.hasScrolled = false\r\n // this.isSmooth = syncTouch || smoothWheel\r\n // this.isSmooth = false\r\n this.isScrolling = false\r\n this.targetScroll = this.animatedScroll = this.actualScroll\r\n\r\n this.options.wrapper.addEventListener('scroll', this.onNativeScroll, false)\r\n\r\n this.virtualScroll = new VirtualScroll(eventsTarget, {\r\n touchMultiplier,\r\n wheelMultiplier,\r\n })\r\n this.virtualScroll.on('scroll', this.onVirtualScroll)\r\n }\r\n\r\n destroy() {\r\n this.emitter.destroy()\r\n\r\n this.options.wrapper.removeEventListener(\r\n 'scroll',\r\n this.onNativeScroll,\r\n false\r\n )\r\n\r\n this.virtualScroll.destroy()\r\n this.dimensions.destroy()\r\n\r\n this.cleanUpClassName()\r\n\r\n // this.rootElement.className = ''\r\n\r\n // this.toggleClassName('lenis', false)\r\n // this.toggleClassName('lenis-smooth', false)\r\n // this.toggleClassName('lenis-scrolling', false)\r\n // this.toggleClassName('lenis-stopped', false)\r\n // this.toggleClassName('lenis-locked', false)\r\n }\r\n\r\n on(event: string, callback: Function) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n off(event: string, callback: Function) {\r\n return this.emitter.off(event, callback)\r\n }\r\n\r\n private setScroll(scroll) {\r\n // apply scroll value immediately\r\n if (this.isHorizontal) {\r\n this.rootElement.scrollLeft = scroll\r\n } else {\r\n this.rootElement.scrollTop = scroll\r\n }\r\n }\r\n\r\n private onVirtualScroll = ({ deltaX, deltaY, event }) => {\r\n // keep zoom feature\r\n if (event.ctrlKey) return\r\n\r\n const isTouch = event.type.includes('touch')\r\n const isWheel = event.type.includes('wheel')\r\n\r\n this.isTouching = event.type === 'touchstart' || event.type === 'touchmove'\r\n // if (event.type === 'touchend') {\r\n // console.log('touchend', this.scroll)\r\n // // this.lastVelocity = this.velocity\r\n // // this.velocity = 0\r\n // // this.isScrolling = false\r\n // this.emit({ type: 'touchend' })\r\n // // alert('touchend')\r\n // return\r\n // }\r\n\r\n const isTapToStop =\r\n this.options.syncTouch &&\r\n isTouch &&\r\n event.type === 'touchstart' &&\r\n !this.isStopped &&\r\n !this.isLocked\r\n\r\n if (isTapToStop) {\r\n this.reset()\r\n return\r\n }\r\n\r\n const isClick = deltaX === 0 && deltaY === 0 // click event\r\n\r\n // const isPullToRefresh =\r\n // this.options.gestureOrientation === 'vertical' &&\r\n // this.scroll === 0 &&\r\n // !this.options.infinite &&\r\n // deltaY <= 5 // touch pull to refresh, not reliable yet\r\n\r\n const isUnknownGesture =\r\n (this.options.gestureOrientation === 'vertical' && deltaY === 0) ||\r\n (this.options.gestureOrientation === 'horizontal' && deltaX === 0)\r\n\r\n if (isClick || isUnknownGesture) {\r\n // console.log('prevent')\r\n return\r\n }\r\n\r\n // catch if scrolling on nested scroll elements\r\n let composedPath = event.composedPath()\r\n composedPath = composedPath.slice(0, composedPath.indexOf(this.rootElement)) // remove parents elements\r\n\r\n const prevent = this.options.prevent\r\n\r\n if (\r\n !!composedPath.find(\r\n (node) =>\r\n (typeof prevent === 'function' ? prevent?.(node) : prevent) ||\r\n node.hasAttribute?.('data-lenis-prevent') ||\r\n (isTouch && node.hasAttribute?.('data-lenis-prevent-touch')) ||\r\n (isWheel && node.hasAttribute?.('data-lenis-prevent-wheel')) ||\r\n (node.classList?.contains('lenis') &&\r\n !node.classList?.contains('lenis-stopped')) // nested lenis instance\r\n )\r\n )\r\n return\r\n\r\n if (this.isStopped || this.isLocked) {\r\n event.preventDefault() // this will stop forwarding the event to the parent, this is problematic\r\n return\r\n }\r\n\r\n const isSmooth =\r\n (this.options.syncTouch && isTouch) ||\r\n (this.options.smoothWheel && isWheel)\r\n\r\n if (!isSmooth) {\r\n this.isScrolling = 'native'\r\n this.animate.stop()\r\n return\r\n }\r\n\r\n event.preventDefault()\r\n\r\n let delta = deltaY\r\n if (this.options.gestureOrientation === 'both') {\r\n delta = Math.abs(deltaY) > Math.abs(deltaX) ? deltaY : deltaX\r\n } else if (this.options.gestureOrientation === 'horizontal') {\r\n delta = deltaX\r\n }\r\n\r\n const syncTouch = isTouch && this.options.syncTouch\r\n const isTouchEnd = isTouch && event.type === 'touchend'\r\n\r\n const hasTouchInertia = isTouchEnd && Math.abs(delta) > 5\r\n\r\n if (hasTouchInertia) {\r\n delta = this.velocity * this.options.touchInertiaMultiplier\r\n }\r\n\r\n this.scrollTo(this.targetScroll + delta, {\r\n programmatic: false,\r\n ...(syncTouch\r\n ? {\r\n lerp: hasTouchInertia ? this.options.syncTouchLerp : 1,\r\n }\r\n : {\r\n lerp: this.options.lerp,\r\n duration: this.options.duration,\r\n easing: this.options.easing,\r\n }),\r\n })\r\n }\r\n\r\n resize() {\r\n this.dimensions.resize()\r\n }\r\n\r\n private emit({ userData = {} } = {}) {\r\n this.userData = userData\r\n this.emitter.emit('scroll', this)\r\n this.userData = {}\r\n }\r\n\r\n private onNativeScroll = () => {\r\n clearTimeout(this.__resetVelocityTimeout)\r\n delete this.__resetVelocityTimeout\r\n\r\n if (this.__preventNextNativeScrollEvent) {\r\n delete this.__preventNextNativeScrollEvent\r\n return\r\n }\r\n\r\n if (this.isScrolling === false || this.isScrolling === 'native') {\r\n const lastScroll = this.animatedScroll\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.lastVelocity = this.velocity\r\n this.velocity = this.animatedScroll - lastScroll\r\n this.direction = Math.sign(this.animatedScroll - lastScroll)\r\n // this.isSmooth = false\r\n this.isScrolling = this.hasScrolled ? 'native' : false\r\n this.emit()\r\n\r\n if (this.velocity !== 0) {\r\n this.__resetVelocityTimeout = setTimeout(() => {\r\n this.lastVelocity = this.velocity\r\n this.velocity = 0\r\n this.isScrolling = false\r\n this.emit()\r\n }, 400)\r\n }\r\n\r\n // this.hasScrolled = true\r\n // }, 50)\r\n }\r\n }\r\n\r\n private reset() {\r\n this.isLocked = false\r\n this.isScrolling = false\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.lastVelocity = this.velocity = 0\r\n this.animate.stop()\r\n }\r\n\r\n start() {\r\n if (!this.isStopped) return\r\n this.isStopped = false\r\n\r\n this.reset()\r\n }\r\n\r\n stop() {\r\n if (this.isStopped) return\r\n this.isStopped = true\r\n this.animate.stop()\r\n\r\n this.reset()\r\n }\r\n\r\n raf(time: number) {\r\n const deltaTime = time - (this.time || time)\r\n this.time = time\r\n\r\n this.animate.advance(deltaTime * 0.001)\r\n }\r\n\r\n scrollTo(\r\n target: number | string | HTMLElement,\r\n {\r\n offset = 0,\r\n immediate = false,\r\n lock = false,\r\n duration = this.options.duration,\r\n easing = this.options.easing,\r\n lerp = !duration && this.options.lerp,\r\n onStart,\r\n onComplete,\r\n force = false, // scroll even if stopped\r\n programmatic = true, // called from outside of the class\r\n userData = {},\r\n }: {\r\n offset?: number\r\n immediate?: boolean\r\n lock?: boolean\r\n duration?: number\r\n easing?: EasingFunction\r\n lerp?: number\r\n onStart?: (lenis: Lenis) => void\r\n onComplete?: (lenis: Lenis) => void\r\n force?: boolean\r\n programmatic?: boolean\r\n userData?: object\r\n } = {}\r\n ) {\r\n if ((this.isStopped || this.isLocked) && !force) return\r\n\r\n // keywords\r\n if (['top', 'left', 'start'].includes(target)) {\r\n target = 0\r\n } else if (['bottom', 'right', 'end'].includes(target)) {\r\n target = 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 }\r\n\r\n if (node) {\r\n if (this.options.wrapper !== window) {\r\n // nested scroll offset correction\r\n const wrapperRect = this.options.wrapper.getBoundingClientRect()\r\n offset -= this.isHorizontal ? wrapperRect.left : wrapperRect.top\r\n }\r\n\r\n const rect = node.getBoundingClientRect()\r\n\r\n target =\r\n (this.isHorizontal ? rect.left : rect.top) + this.animatedScroll\r\n }\r\n }\r\n\r\n if (typeof target !== 'number') return\r\n\r\n target += offset\r\n target = Math.round(target)\r\n\r\n if (this.options.infinite) {\r\n if (programmatic) {\r\n this.targetScroll = this.animatedScroll = this.scroll\r\n }\r\n } else {\r\n target = clamp(0, target, this.limit)\r\n }\r\n\r\n if (immediate) {\r\n this.animatedScroll = this.targetScroll = target\r\n this.setScroll(this.scroll)\r\n this.reset()\r\n onComplete?.(this)\r\n return\r\n }\r\n\r\n if (target === this.targetScroll) return\r\n\r\n if (!programmatic) {\r\n this.targetScroll = target\r\n }\r\n\r\n this.animate.fromTo(this.animatedScroll, target, {\r\n duration,\r\n easing,\r\n lerp,\r\n onStart: () => {\r\n // started\r\n if (lock) this.isLocked = true\r\n this.isScrolling = 'smooth'\r\n onStart?.(this)\r\n },\r\n onUpdate: (value: number, completed: boolean) => {\r\n this.isScrolling = 'smooth'\r\n\r\n // updated\r\n this.lastVelocity = this.velocity\r\n this.velocity = value - this.animatedScroll\r\n this.direction = Math.sign(this.velocity)\r\n\r\n this.animatedScroll = value\r\n this.setScroll(this.scroll)\r\n\r\n if (programmatic) {\r\n // wheel during programmatic should stop it\r\n this.targetScroll = value\r\n }\r\n\r\n if (!completed) this.emit({ userData })\r\n\r\n if (completed) {\r\n this.reset()\r\n this.emit({ userData })\r\n onComplete?.(this)\r\n\r\n // avoid emitting event twice\r\n this.__preventNextNativeScrollEvent = true\r\n // requestAnimationFrame(() => {\r\n // delete this.__preventNextNativeScrollEvent\r\n // })\r\n }\r\n },\r\n })\r\n }\r\n\r\n get rootElement() {\r\n return this.options.wrapper === window\r\n ? document.documentElement\r\n : this.options.wrapper\r\n }\r\n\r\n get limit() {\r\n if (this.options.__experimental__naiveDimensions) {\r\n if (this.isHorizontal) {\r\n return this.rootElement.scrollWidth - this.rootElement.clientWidth\r\n } else {\r\n return this.rootElement.scrollHeight - this.rootElement.clientHeight\r\n }\r\n } else {\r\n return this.dimensions.limit[this.isHorizontal ? 'x' : 'y']\r\n }\r\n }\r\n\r\n get isHorizontal() {\r\n return this.options.orientation === 'horizontal'\r\n }\r\n\r\n get actualScroll(): number {\r\n // value browser takes into account\r\n return this.isHorizontal\r\n ? this.rootElement.scrollLeft\r\n : this.rootElement.scrollTop\r\n }\r\n\r\n get scroll(): number {\r\n return this.options.infinite\r\n ? modulo(this.animatedScroll, this.limit)\r\n : this.animatedScroll\r\n }\r\n\r\n get progress(): number {\r\n // avoid progress to be NaN\r\n return this.limit === 0 ? 1 : this.scroll / this.limit\r\n }\r\n\r\n // get isSmooth() {\r\n // return this.__isSmooth\r\n // }\r\n\r\n // private set isSmooth(value: boolean) {\r\n // if (this.__isSmooth !== value) {\r\n // this.__isSmooth = value\r\n // this.updateClassName()\r\n // }\r\n // }\r\n\r\n get isScrolling() {\r\n return this.__isScrolling\r\n }\r\n\r\n private set isScrolling(value: boolean) {\r\n if (this.__isScrolling !== value) {\r\n this.__isScrolling = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isStopped() {\r\n return this.__isStopped\r\n }\r\n\r\n private set isStopped(value: boolean) {\r\n if (this.__isStopped !== value) {\r\n this.__isStopped = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isLocked() {\r\n return this.__isLocked\r\n }\r\n\r\n private set isLocked(value: boolean) {\r\n if (this.__isLocked !== value) {\r\n this.__isLocked = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isSmooth() {\r\n return this.isScrolling === 'smooth'\r\n }\r\n\r\n get className() {\r\n let className = 'lenis'\r\n if (this.isStopped) className += ' lenis-stopped'\r\n if (this.isLocked) className += ' lenis-locked'\r\n if (this.isScrolling) className += ' lenis-scrolling'\r\n if (this.isScrolling === 'smooth') className += ' lenis-smooth'\r\n // if (this.isScrolling === 'native') className += ' lenis-native'\r\n // if (this.isSmooth) className += ' lenis-smooth'\r\n return className\r\n }\r\n\r\n private updateClassName() {\r\n this.cleanUpClassName()\r\n\r\n this.rootElement.className =\r\n `${this.rootElement.className} ${this.className}`.trim()\r\n // this.emitter.emit('className change', this)\r\n }\r\n\r\n private cleanUpClassName() {\r\n this.rootElement.className = this.rootElement.className\r\n .replace(/lenis(-\\w+)?/g, '')\r\n .trim()\r\n }\r\n\r\n // private toggleClassName(name: string, value: boolean) {\r\n // // this.rootElement.classList.toggle(name, value)\r\n // this.rootElement.className = this.className\r\n // this.emitter.emit('className change', this)\r\n // }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;EAAA;EACO,SAAS,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE;EACvC,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;EAC5C,CAAC;AAMD;EACA;EACO,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;EAC9B,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;EAC5B,CAAC;AACD;EACA;EACO,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;EACvC,EAAE,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;EAC/C,CAAC;AACD;EACA;EACA;EACO,SAAS,MAAM,CAAC,CAAC,EAAE,C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WAAW;cAAE,SAAS,IAAI,kBAAkB,CAAA;EACrD,QAAA,IAAI,IAAI,CAAC,WAAW,KAAK,QAAQ;cAAE,SAAS,IAAI,eAAe,CAAA;;;EAG/D,QAAA,OAAO,SAAS,CAAA;OACjB;MAEO,eAAe,GAAA;UACrB,IAAI,CAAC,gBAAgB,EAAE,CAAA;UAEvB,IAAI,CAAC,WAAW,CAAC,SAAS;EACxB,YAAA,CAAA,EAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAA,CAAA,EAAI,IAAI,CAAC,SAAS,CAAA,CAAE,CAAC,IAAI,EAAE,CAAA;;OAE3D;MAEO,gBAAgB,GAAA;UACtB,IAAI,CAAC,WAAW,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS;EACpD,aAAA,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;EAC5B,aAAA,IAAI,EAAE,CAAA;OACV;EAOF;;;;;;;;"} \ No newline at end of file diff --git a/dist/lenis.min.js b/dist/lenis.min.js index cf7a7fd8..d6bfb23b 100644 --- a/dist/lenis.min.js +++ b/dist/lenis.min.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="undefined"!=typeof globalThis?globalThis:t||self).Lenis=e()}(this,(function(){"use strict";function clamp(t,e,i){return Math.max(t,Math.min(e,i))}class Animate{advance(t){if(!this.isRunning)return;let e=!1;if(this.lerp)this.value=function damp(t,e,i,s){return function lerp(t,e,i){return(1-i)*t+i*e}(t,e,1-Math.exp(-i*s))}(this.value,this.to,60*this.lerp,t),Math.round(this.value)===this.to&&(this.value=this.to,e=!0);else{this.currentTime+=t;const i=clamp(0,this.currentTime/this.duration,1);e=i>=1;const s=e?1:this.easing(i);this.value=this.from+(this.to-this.from)*s}e&&this.stop(),this.onUpdate?.(this.value,e)}stop(){this.isRunning=!1}fromTo(t,e,{lerp:i=.1,duration:s=1,easing:o=(t=>t),onStart:n,onUpdate:r}){this.from=this.value=t,this.to=e,this.lerp=i,this.duration=s,this.easing=o,this.currentTime=0,this.isRunning=!0,n?.(),this.onUpdate=r}}class Dimensions{constructor({wrapper:t,content:e,autoResize:i=!0,debounce:s=250}={}){this.wrapper=t,this.content=e,i&&(this.debouncedResize=function debounce(t,e){let i;return function(){let s=arguments,o=this;clearTimeout(i),i=setTimeout((function(){t.apply(o,s)}),e)}}(this.resize,s),this.wrapper===window?window.addEventListener("resize",this.debouncedResize,!1):(this.wrapperResizeObserver=new ResizeObserver(this.debouncedResize),this.wrapperResizeObserver.observe(this.wrapper)),this.contentResizeObserver=new ResizeObserver(this.debouncedResize),this.contentResizeObserver.observe(this.content)),this.resize()}destroy(){this.wrapperResizeObserver?.disconnect(),this.contentResizeObserver?.disconnect(),window.removeEventListener("resize",this.debouncedResize,!1)}resize=()=>{this.onWrapperResize(),this.onContentResize()};onWrapperResize=()=>{this.wrapper===window?(this.width=window.innerWidth,this.height=window.innerHeight):(this.width=this.wrapper.clientWidth,this.height=this.wrapper.clientHeight)};onContentResize=()=>{this.wrapper===window?(this.scrollHeight=this.content.scrollHeight,this.scrollWidth=this.content.scrollWidth):(this.scrollHeight=this.wrapper.scrollHeight,this.scrollWidth=this.wrapper.scrollWidth)};get limit(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}}class Emitter{constructor(){this.events={}}emit(t,...e){let i=this.events[t]||[];for(let t=0,s=i.length;t{this.events[t]=this.events[t]?.filter((t=>e!==t))}}off(t,e){this.events[t]=this.events[t]?.filter((t=>e!==t))}destroy(){this.events={}}}const t=100/6;class VirtualScroll{constructor(t,{wheelMultiplier:e=1,touchMultiplier:i=1}){this.element=t,this.wheelMultiplier=e,this.touchMultiplier=i,this.touchStart={x:null,y:null},this.emitter=new Emitter,window.addEventListener("resize",this.onWindowResize,!1),this.onWindowResize(),this.element.addEventListener("wheel",this.onWheel,{passive:!1}),this.element.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.element.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.element.addEventListener("touchend",this.onTouchEnd,{passive:!1})}on(t,e){return this.emitter.on(t,e)}destroy(){this.emitter.destroy(),window.removeEventListener("resize",this.onWindowResize,!1),this.element.removeEventListener("wheel",this.onWheel,{passive:!1}),this.element.removeEventListener("touchstart",this.onTouchStart,{passive:!1}),this.element.removeEventListener("touchmove",this.onTouchMove,{passive:!1}),this.element.removeEventListener("touchend",this.onTouchEnd,{passive:!1})}onTouchStart=t=>{const{clientX:e,clientY:i}=t.targetTouches?t.targetTouches[0]:t;this.touchStart.x=e,this.touchStart.y=i,this.lastDelta={x:0,y:0},this.emitter.emit("scroll",{deltaX:0,deltaY:0,event:t})};onTouchMove=t=>{const{clientX:e,clientY:i}=t.targetTouches?t.targetTouches[0]:t,s=-(e-this.touchStart.x)*this.touchMultiplier,o=-(i-this.touchStart.y)*this.touchMultiplier;this.touchStart.x=e,this.touchStart.y=i,this.lastDelta={x:s,y:o},this.emitter.emit("scroll",{deltaX:s,deltaY:o,event:t})};onTouchEnd=t=>{this.emitter.emit("scroll",{deltaX:this.lastDelta.x,deltaY:this.lastDelta.y,event:t})};onWheel=e=>{let{deltaX:i,deltaY:s,deltaMode:o}=e;i*=1===o?t:2===o?this.windowWidth:1,s*=1===o?t:2===o?this.windowHeight:1,i*=this.wheelMultiplier,s*=this.wheelMultiplier,this.emitter.emit("scroll",{deltaX:i,deltaY:s,event:e})};onWindowResize=()=>{this.windowWidth=window.innerWidth,this.windowHeight=window.innerHeight}}return class Lenis{constructor({wrapper:t=window,content:e=document.documentElement,wheelEventsTarget:i=t,eventsTarget:s=i,smoothWheel:o=!0,syncTouch:n=!1,syncTouchLerp:r=.075,touchInertiaMultiplier:l=35,duration:h,easing:a=(t=>Math.min(1,1.001-Math.pow(2,-10*t))),lerp:c=!h&&.1,infinite:u=!1,orientation:d="vertical",gestureOrientation:p="vertical",touchMultiplier:m=1,wheelMultiplier:v=1,autoResize:g=!0,prevent:S=!1,__experimental__naiveDimensions:w=!1}={}){this.__isScrolling=!1,this.__isStopped=!1,this.__isLocked=!1,this.onVirtualScroll=({deltaX:t,deltaY:e,event:i})=>{if(i.ctrlKey)return;const s=i.type.includes("touch"),o=i.type.includes("wheel");this.isTouching="touchstart"===i.type||"touchmove"===i.type;if(this.options.syncTouch&&s&&"touchstart"===i.type&&!this.isStopped&&!this.isLocked)return void this.reset();const n=0===t&&0===e,r="vertical"===this.options.gestureOrientation&&0===e||"horizontal"===this.options.gestureOrientation&&0===t;if(n||r)return;let l=i.composedPath();if(l=l.slice(0,l.indexOf(this.rootElement)),l.find((t=>{var e,i,n,r,l;return this.options.prevent(t)||(null===(e=t.hasAttribute)||void 0===e?void 0:e.call(t,"data-lenis-prevent"))||s&&(null===(i=t.hasAttribute)||void 0===i?void 0:i.call(t,"data-lenis-prevent-touch"))||o&&(null===(n=t.hasAttribute)||void 0===n?void 0:n.call(t,"data-lenis-prevent-wheel"))||(null===(r=t.classList)||void 0===r?void 0:r.contains("lenis"))&&!(null===(l=t.classList)||void 0===l?void 0:l.contains("lenis-stopped"))})))return;if(this.isStopped||this.isLocked)return void i.preventDefault();if(!(this.options.syncTouch&&s||this.options.smoothWheel&&o))return this.isScrolling="native",void this.animate.stop();i.preventDefault();let h=e;"both"===this.options.gestureOrientation?h=Math.abs(e)>Math.abs(t)?e:t:"horizontal"===this.options.gestureOrientation&&(h=t);const a=s&&this.options.syncTouch,c=s&&"touchend"===i.type&&Math.abs(h)>5;c&&(h=this.velocity*this.options.touchInertiaMultiplier),this.scrollTo(this.targetScroll+h,Object.assign({programmatic:!1},a?{lerp:c?this.options.syncTouchLerp:1}:{lerp:this.options.lerp,duration:this.options.duration,easing:this.options.easing}))},this.onNativeScroll=()=>{if(clearTimeout(this.__resetVelocityTimeout),delete this.__resetVelocityTimeout,this.__preventNextNativeScrollEvent)delete this.__preventNextNativeScrollEvent;else if(!1===this.isScrolling||"native"===this.isScrolling){const t=this.animatedScroll;this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity,this.velocity=this.animatedScroll-t,this.direction=Math.sign(this.animatedScroll-t),this.isScrolling=!!this.hasScrolled&&"native",this.emit(),0!==this.velocity&&(this.__resetVelocityTimeout=setTimeout((()=>{this.lastVelocity=this.velocity,this.velocity=0,this.isScrolling=!1,this.emit()}),400))}},window.lenisVersion="1.1.0",t!==document.documentElement&&t!==document.body||(t=window),this.options={wrapper:t,content:e,wheelEventsTarget:i,eventsTarget:s,smoothWheel:o,syncTouch:n,syncTouchLerp:r,touchInertiaMultiplier:l,duration:h,easing:a,lerp:c,infinite:u,gestureOrientation:p,orientation:d,touchMultiplier:m,wheelMultiplier:v,autoResize:g,prevent:S,__experimental__naiveDimensions:w},this.animate=new Animate,this.emitter=new Emitter,this.dimensions=new Dimensions({wrapper:t,content:e,autoResize:g}),this.updateClassName(),this.userData={},this.time=0,this.velocity=this.lastVelocity=0,this.isLocked=!1,this.isStopped=!1,this.isScrolling=!1,this.targetScroll=this.animatedScroll=this.actualScroll,this.options.wrapper.addEventListener("scroll",this.onNativeScroll,!1),this.virtualScroll=new VirtualScroll(s,{touchMultiplier:m,wheelMultiplier:v}),this.virtualScroll.on("scroll",this.onVirtualScroll)}destroy(){this.emitter.destroy(),this.options.wrapper.removeEventListener("scroll",this.onNativeScroll,!1),this.virtualScroll.destroy(),this.dimensions.destroy(),this.cleanUpClassName()}on(t,e){return this.emitter.on(t,e)}off(t,e){return this.emitter.off(t,e)}setScroll(t){this.isHorizontal?this.rootElement.scrollLeft=t:this.rootElement.scrollTop=t}resize(){this.dimensions.resize()}emit({userData:t={}}={}){this.userData=t,this.emitter.emit("scroll",this),this.userData={}}reset(){this.isLocked=!1,this.isScrolling=!1,this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity=0,this.animate.stop()}start(){this.isStopped&&(this.isStopped=!1,this.reset())}stop(){this.isStopped||(this.isStopped=!0,this.animate.stop(),this.reset())}raf(t){const e=t-(this.time||t);this.time=t,this.animate.advance(.001*e)}scrollTo(t,{offset:e=0,immediate:i=!1,lock:s=!1,duration:o=this.options.duration,easing:n=this.options.easing,lerp:r=!o&&this.options.lerp,onStart:l,onComplete:h,force:a=!1,programmatic:c=!0,userData:u={}}={}){if(!this.isStopped&&!this.isLocked||a){if(["top","left","start"].includes(t))t=0;else if(["bottom","right","end"].includes(t))t=this.limit;else{let i;if("string"==typeof t?i=document.querySelector(t):(null==t?void 0:t.nodeType)&&(i=t),i){if(this.options.wrapper!==window){const t=this.options.wrapper.getBoundingClientRect();e-=this.isHorizontal?t.left:t.top}const s=i.getBoundingClientRect();t=(this.isHorizontal?s.left:s.top)+this.animatedScroll}}if("number"==typeof t){if(t+=e,t=Math.round(t),this.options.infinite?c&&(this.targetScroll=this.animatedScroll=this.scroll):t=clamp(0,t,this.limit),i)return this.animatedScroll=this.targetScroll=t,this.setScroll(this.scroll),this.reset(),void(null==h||h(this));t!==this.targetScroll&&(c||(this.targetScroll=t),this.animate.fromTo(this.animatedScroll,t,{duration:o,easing:n,lerp:r,onStart:()=>{s&&(this.isLocked=!0),this.isScrolling="smooth",null==l||l(this)},onUpdate:(t,e)=>{this.isScrolling="smooth",this.lastVelocity=this.velocity,this.velocity=t-this.animatedScroll,this.direction=Math.sign(this.velocity),this.animatedScroll=t,this.setScroll(this.scroll),c&&(this.targetScroll=t),e||this.emit({userData:u}),e&&(this.reset(),this.emit({userData:u}),null==h||h(this),this.__preventNextNativeScrollEvent=!0)}}))}}}get rootElement(){return this.options.wrapper===window?document.documentElement:this.options.wrapper}get limit(){return this.options.__experimental__naiveDimensions?this.isHorizontal?this.rootElement.scrollWidth-this.rootElement.clientWidth:this.rootElement.scrollHeight-this.rootElement.clientHeight:this.dimensions.limit[this.isHorizontal?"x":"y"]}get isHorizontal(){return"horizontal"===this.options.orientation}get actualScroll(){return this.isHorizontal?this.rootElement.scrollLeft:this.rootElement.scrollTop}get scroll(){return this.options.infinite?function modulo(t,e){return(t%e+e)%e}(this.animatedScroll,this.limit):this.animatedScroll}get progress(){return 0===this.limit?1:this.scroll/this.limit}get isScrolling(){return this.__isScrolling}set isScrolling(t){this.__isScrolling!==t&&(this.__isScrolling=t,this.updateClassName())}get isStopped(){return this.__isStopped}set isStopped(t){this.__isStopped!==t&&(this.__isStopped=t,this.updateClassName())}get isLocked(){return this.__isLocked}set isLocked(t){this.__isLocked!==t&&(this.__isLocked=t,this.updateClassName())}get isSmooth(){return"smooth"===this.isScrolling}get className(){let t="lenis";return this.isStopped&&(t+=" lenis-stopped"),this.isLocked&&(t+=" lenis-locked"),this.isScrolling&&(t+=" lenis-scrolling"),"smooth"===this.isScrolling&&(t+=" lenis-smooth"),t}updateClassName(){this.cleanUpClassName(),this.rootElement.className=`${this.rootElement.className} ${this.className}`.trim()}cleanUpClassName(){this.rootElement.className=this.rootElement.className.replace(/lenis(-\w+)?/g,"").trim()}}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Lenis=e()}(this,(function(){"use strict";function clamp(t,e,i){return Math.max(t,Math.min(e,i))}class Animate{advance(t){if(!this.isRunning)return;let e=!1;if(this.lerp)this.value=function damp(t,e,i,s){return function lerp(t,e,i){return(1-i)*t+i*e}(t,e,1-Math.exp(-i*s))}(this.value,this.to,60*this.lerp,t),Math.round(this.value)===this.to&&(this.value=this.to,e=!0);else{this.currentTime+=t;const i=clamp(0,this.currentTime/this.duration,1);e=i>=1;const s=e?1:this.easing(i);this.value=this.from+(this.to-this.from)*s}e&&this.stop(),this.onUpdate?.(this.value,e)}stop(){this.isRunning=!1}fromTo(t,e,{lerp:i=.1,duration:s=1,easing:o=(t=>t),onStart:n,onUpdate:r}){this.from=this.value=t,this.to=e,this.lerp=i,this.duration=s,this.easing=o,this.currentTime=0,this.isRunning=!0,n?.(),this.onUpdate=r}}class Dimensions{constructor({wrapper:t,content:e,autoResize:i=!0,debounce:s=250}={}){this.wrapper=t,this.content=e,i&&(this.debouncedResize=function debounce(t,e){let i;return function(){let s=arguments,o=this;clearTimeout(i),i=setTimeout((function(){t.apply(o,s)}),e)}}(this.resize,s),this.wrapper===window?window.addEventListener("resize",this.debouncedResize,!1):(this.wrapperResizeObserver=new ResizeObserver(this.debouncedResize),this.wrapperResizeObserver.observe(this.wrapper)),this.contentResizeObserver=new ResizeObserver(this.debouncedResize),this.contentResizeObserver.observe(this.content)),this.resize()}destroy(){this.wrapperResizeObserver?.disconnect(),this.contentResizeObserver?.disconnect(),window.removeEventListener("resize",this.debouncedResize,!1)}resize=()=>{this.onWrapperResize(),this.onContentResize()};onWrapperResize=()=>{this.wrapper===window?(this.width=window.innerWidth,this.height=window.innerHeight):(this.width=this.wrapper.clientWidth,this.height=this.wrapper.clientHeight)};onContentResize=()=>{this.wrapper===window?(this.scrollHeight=this.content.scrollHeight,this.scrollWidth=this.content.scrollWidth):(this.scrollHeight=this.wrapper.scrollHeight,this.scrollWidth=this.wrapper.scrollWidth)};get limit(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}}class Emitter{constructor(){this.events={}}emit(t,...e){let i=this.events[t]||[];for(let t=0,s=i.length;t{this.events[t]=this.events[t]?.filter((t=>e!==t))}}off(t,e){this.events[t]=this.events[t]?.filter((t=>e!==t))}destroy(){this.events={}}}const t=100/6;class VirtualScroll{constructor(t,{wheelMultiplier:e=1,touchMultiplier:i=1}){this.element=t,this.wheelMultiplier=e,this.touchMultiplier=i,this.touchStart={x:null,y:null},this.emitter=new Emitter,window.addEventListener("resize",this.onWindowResize,!1),this.onWindowResize(),this.element.addEventListener("wheel",this.onWheel,{passive:!1}),this.element.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.element.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.element.addEventListener("touchend",this.onTouchEnd,{passive:!1})}on(t,e){return this.emitter.on(t,e)}destroy(){this.emitter.destroy(),window.removeEventListener("resize",this.onWindowResize,!1),this.element.removeEventListener("wheel",this.onWheel,{passive:!1}),this.element.removeEventListener("touchstart",this.onTouchStart,{passive:!1}),this.element.removeEventListener("touchmove",this.onTouchMove,{passive:!1}),this.element.removeEventListener("touchend",this.onTouchEnd,{passive:!1})}onTouchStart=t=>{const{clientX:e,clientY:i}=t.targetTouches?t.targetTouches[0]:t;this.touchStart.x=e,this.touchStart.y=i,this.lastDelta={x:0,y:0},this.emitter.emit("scroll",{deltaX:0,deltaY:0,event:t})};onTouchMove=t=>{const{clientX:e,clientY:i}=t.targetTouches?t.targetTouches[0]:t,s=-(e-this.touchStart.x)*this.touchMultiplier,o=-(i-this.touchStart.y)*this.touchMultiplier;this.touchStart.x=e,this.touchStart.y=i,this.lastDelta={x:s,y:o},this.emitter.emit("scroll",{deltaX:s,deltaY:o,event:t})};onTouchEnd=t=>{this.emitter.emit("scroll",{deltaX:this.lastDelta.x,deltaY:this.lastDelta.y,event:t})};onWheel=e=>{let{deltaX:i,deltaY:s,deltaMode:o}=e;i*=1===o?t:2===o?this.windowWidth:1,s*=1===o?t:2===o?this.windowHeight:1,i*=this.wheelMultiplier,s*=this.wheelMultiplier,this.emitter.emit("scroll",{deltaX:i,deltaY:s,event:e})};onWindowResize=()=>{this.windowWidth=window.innerWidth,this.windowHeight=window.innerHeight}}return class Lenis{constructor({wrapper:t=window,content:e=document.documentElement,wheelEventsTarget:i=t,eventsTarget:s=i,smoothWheel:o=!0,syncTouch:n=!1,syncTouchLerp:r=.075,touchInertiaMultiplier:l=35,duration:h,easing:a=(t=>Math.min(1,1.001-Math.pow(2,-10*t))),lerp:c=!h&&.1,infinite:u=!1,orientation:d="vertical",gestureOrientation:p="vertical",touchMultiplier:m=1,wheelMultiplier:v=1,autoResize:g=!0,prevent:S=!1,__experimental__naiveDimensions:w=!1}={}){this.__isScrolling=!1,this.__isStopped=!1,this.__isLocked=!1,this.onVirtualScroll=({deltaX:t,deltaY:e,event:i})=>{if(i.ctrlKey)return;const s=i.type.includes("touch"),o=i.type.includes("wheel");this.isTouching="touchstart"===i.type||"touchmove"===i.type;if(this.options.syncTouch&&s&&"touchstart"===i.type&&!this.isStopped&&!this.isLocked)return void this.reset();const n=0===t&&0===e,r="vertical"===this.options.gestureOrientation&&0===e||"horizontal"===this.options.gestureOrientation&&0===t;if(n||r)return;let l=i.composedPath();l=l.slice(0,l.indexOf(this.rootElement));const h=this.options.prevent;if(l.find((t=>{var e,i,n,r,l;return("function"==typeof h?null==h?void 0:h(t):h)||(null===(e=t.hasAttribute)||void 0===e?void 0:e.call(t,"data-lenis-prevent"))||s&&(null===(i=t.hasAttribute)||void 0===i?void 0:i.call(t,"data-lenis-prevent-touch"))||o&&(null===(n=t.hasAttribute)||void 0===n?void 0:n.call(t,"data-lenis-prevent-wheel"))||(null===(r=t.classList)||void 0===r?void 0:r.contains("lenis"))&&!(null===(l=t.classList)||void 0===l?void 0:l.contains("lenis-stopped"))})))return;if(this.isStopped||this.isLocked)return void i.preventDefault();if(!(this.options.syncTouch&&s||this.options.smoothWheel&&o))return this.isScrolling="native",void this.animate.stop();i.preventDefault();let a=e;"both"===this.options.gestureOrientation?a=Math.abs(e)>Math.abs(t)?e:t:"horizontal"===this.options.gestureOrientation&&(a=t);const c=s&&this.options.syncTouch,u=s&&"touchend"===i.type&&Math.abs(a)>5;u&&(a=this.velocity*this.options.touchInertiaMultiplier),this.scrollTo(this.targetScroll+a,Object.assign({programmatic:!1},c?{lerp:u?this.options.syncTouchLerp:1}:{lerp:this.options.lerp,duration:this.options.duration,easing:this.options.easing}))},this.onNativeScroll=()=>{if(clearTimeout(this.__resetVelocityTimeout),delete this.__resetVelocityTimeout,this.__preventNextNativeScrollEvent)delete this.__preventNextNativeScrollEvent;else if(!1===this.isScrolling||"native"===this.isScrolling){const t=this.animatedScroll;this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity,this.velocity=this.animatedScroll-t,this.direction=Math.sign(this.animatedScroll-t),this.isScrolling=!!this.hasScrolled&&"native",this.emit(),0!==this.velocity&&(this.__resetVelocityTimeout=setTimeout((()=>{this.lastVelocity=this.velocity,this.velocity=0,this.isScrolling=!1,this.emit()}),400))}},window.lenisVersion="1.1.1",t!==document.documentElement&&t!==document.body||(t=window),this.options={wrapper:t,content:e,wheelEventsTarget:i,eventsTarget:s,smoothWheel:o,syncTouch:n,syncTouchLerp:r,touchInertiaMultiplier:l,duration:h,easing:a,lerp:c,infinite:u,gestureOrientation:p,orientation:d,touchMultiplier:m,wheelMultiplier:v,autoResize:g,prevent:S,__experimental__naiveDimensions:w},this.animate=new Animate,this.emitter=new Emitter,this.dimensions=new Dimensions({wrapper:t,content:e,autoResize:g}),this.updateClassName(),this.userData={},this.time=0,this.velocity=this.lastVelocity=0,this.isLocked=!1,this.isStopped=!1,this.isScrolling=!1,this.targetScroll=this.animatedScroll=this.actualScroll,this.options.wrapper.addEventListener("scroll",this.onNativeScroll,!1),this.virtualScroll=new VirtualScroll(s,{touchMultiplier:m,wheelMultiplier:v}),this.virtualScroll.on("scroll",this.onVirtualScroll)}destroy(){this.emitter.destroy(),this.options.wrapper.removeEventListener("scroll",this.onNativeScroll,!1),this.virtualScroll.destroy(),this.dimensions.destroy(),this.cleanUpClassName()}on(t,e){return this.emitter.on(t,e)}off(t,e){return this.emitter.off(t,e)}setScroll(t){this.isHorizontal?this.rootElement.scrollLeft=t:this.rootElement.scrollTop=t}resize(){this.dimensions.resize()}emit({userData:t={}}={}){this.userData=t,this.emitter.emit("scroll",this),this.userData={}}reset(){this.isLocked=!1,this.isScrolling=!1,this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity=0,this.animate.stop()}start(){this.isStopped&&(this.isStopped=!1,this.reset())}stop(){this.isStopped||(this.isStopped=!0,this.animate.stop(),this.reset())}raf(t){const e=t-(this.time||t);this.time=t,this.animate.advance(.001*e)}scrollTo(t,{offset:e=0,immediate:i=!1,lock:s=!1,duration:o=this.options.duration,easing:n=this.options.easing,lerp:r=!o&&this.options.lerp,onStart:l,onComplete:h,force:a=!1,programmatic:c=!0,userData:u={}}={}){if(!this.isStopped&&!this.isLocked||a){if(["top","left","start"].includes(t))t=0;else if(["bottom","right","end"].includes(t))t=this.limit;else{let i;if("string"==typeof t?i=document.querySelector(t):(null==t?void 0:t.nodeType)&&(i=t),i){if(this.options.wrapper!==window){const t=this.options.wrapper.getBoundingClientRect();e-=this.isHorizontal?t.left:t.top}const s=i.getBoundingClientRect();t=(this.isHorizontal?s.left:s.top)+this.animatedScroll}}if("number"==typeof t){if(t+=e,t=Math.round(t),this.options.infinite?c&&(this.targetScroll=this.animatedScroll=this.scroll):t=clamp(0,t,this.limit),i)return this.animatedScroll=this.targetScroll=t,this.setScroll(this.scroll),this.reset(),void(null==h||h(this));t!==this.targetScroll&&(c||(this.targetScroll=t),this.animate.fromTo(this.animatedScroll,t,{duration:o,easing:n,lerp:r,onStart:()=>{s&&(this.isLocked=!0),this.isScrolling="smooth",null==l||l(this)},onUpdate:(t,e)=>{this.isScrolling="smooth",this.lastVelocity=this.velocity,this.velocity=t-this.animatedScroll,this.direction=Math.sign(this.velocity),this.animatedScroll=t,this.setScroll(this.scroll),c&&(this.targetScroll=t),e||this.emit({userData:u}),e&&(this.reset(),this.emit({userData:u}),null==h||h(this),this.__preventNextNativeScrollEvent=!0)}}))}}}get rootElement(){return this.options.wrapper===window?document.documentElement:this.options.wrapper}get limit(){return this.options.__experimental__naiveDimensions?this.isHorizontal?this.rootElement.scrollWidth-this.rootElement.clientWidth:this.rootElement.scrollHeight-this.rootElement.clientHeight:this.dimensions.limit[this.isHorizontal?"x":"y"]}get isHorizontal(){return"horizontal"===this.options.orientation}get actualScroll(){return this.isHorizontal?this.rootElement.scrollLeft:this.rootElement.scrollTop}get scroll(){return this.options.infinite?function modulo(t,e){return(t%e+e)%e}(this.animatedScroll,this.limit):this.animatedScroll}get progress(){return 0===this.limit?1:this.scroll/this.limit}get isScrolling(){return this.__isScrolling}set isScrolling(t){this.__isScrolling!==t&&(this.__isScrolling=t,this.updateClassName())}get isStopped(){return this.__isStopped}set isStopped(t){this.__isStopped!==t&&(this.__isStopped=t,this.updateClassName())}get isLocked(){return this.__isLocked}set isLocked(t){this.__isLocked!==t&&(this.__isLocked=t,this.updateClassName())}get isSmooth(){return"smooth"===this.isScrolling}get className(){let t="lenis";return this.isStopped&&(t+=" lenis-stopped"),this.isLocked&&(t+=" lenis-locked"),this.isScrolling&&(t+=" lenis-scrolling"),"smooth"===this.isScrolling&&(t+=" lenis-smooth"),t}updateClassName(){this.cleanUpClassName(),this.rootElement.className=`${this.rootElement.className} ${this.className}`.trim()}cleanUpClassName(){this.rootElement.className=this.rootElement.className.replace(/lenis(-\w+)?/g,"").trim()}}})); //# sourceMappingURL=lenis.min.js.map diff --git a/dist/lenis.min.js.map b/dist/lenis.min.js.map index 294b6235..f56cf0aa 100644 --- a/dist/lenis.min.js.map +++ b/dist/lenis.min.js.map @@ -1 +1 @@ -{"version":3,"file":"lenis.min.js","sources":["../src/maths.js","../src/animate.js","../src/dimensions.js","../src/debounce.js","../src/emitter.js","../src/virtual-scroll.js","../src/index.ts"],"sourcesContent":["// Clamp a value between a minimum and maximum value\r\nexport function clamp(min, input, max) {\r\n return Math.max(min, Math.min(input, max))\r\n}\r\n\r\n// Truncate a floating-point number to a specified number of decimal places\r\nexport function truncate(value, decimals = 0) {\r\n return parseFloat(value.toFixed(decimals))\r\n}\r\n\r\n// Linearly interpolate between two values using an amount (0 <= t <= 1)\r\nexport function lerp(x, y, t) {\r\n return (1 - t) * x + t * y\r\n}\r\n\r\n// http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/\r\nexport function damp(x, y, lambda, dt) {\r\n return lerp(x, y, 1 - Math.exp(-lambda * dt))\r\n}\r\n\r\n// Calculate the modulo of the dividend and divisor while keeping the result within the same sign as the divisor\r\n// https://anguscroll.com/just/just-modulo\r\nexport function modulo(n, d) {\r\n return ((n % d) + d) % d\r\n}\r\n","import { clamp, damp } from './maths'\r\n\r\n// Animate class to handle value animations with lerping or easing\r\nexport class Animate {\r\n // Advance the animation by the given delta time\r\n advance(deltaTime) {\r\n if (!this.isRunning) return\r\n\r\n let completed = false\r\n\r\n if (this.lerp) {\r\n this.value = damp(this.value, this.to, this.lerp * 60, deltaTime)\r\n if (Math.round(this.value) === this.to) {\r\n this.value = this.to\r\n completed = true\r\n }\r\n } else {\r\n this.currentTime += deltaTime\r\n const linearProgress = clamp(0, this.currentTime / this.duration, 1)\r\n\r\n completed = linearProgress >= 1\r\n const easedProgress = completed ? 1 : this.easing(linearProgress)\r\n this.value = this.from + (this.to - this.from) * easedProgress\r\n }\r\n\r\n if (completed) {\r\n this.stop()\r\n }\r\n\r\n // Call the onUpdate callback with the current value and completed status\r\n this.onUpdate?.(this.value, completed)\r\n }\r\n\r\n // Stop the animation\r\n stop() {\r\n this.isRunning = false\r\n }\r\n\r\n // Set up the animation from a starting value to an ending value\r\n // with optional parameters for lerping, duration, easing, and onUpdate callback\r\n fromTo(\r\n from,\r\n to,\r\n { lerp = 0.1, duration = 1, easing = (t) => t, onStart, onUpdate }\r\n ) {\r\n this.from = this.value = from\r\n this.to = to\r\n this.lerp = lerp\r\n this.duration = duration\r\n this.easing = easing\r\n this.currentTime = 0\r\n this.isRunning = true\r\n\r\n onStart?.()\r\n this.onUpdate = onUpdate\r\n }\r\n}\r\n","import { debounce } from './debounce'\r\n\r\nexport class Dimensions {\r\n constructor({\r\n wrapper,\r\n content,\r\n autoResize = true,\r\n debounce: debounceValue = 250,\r\n } = {}) {\r\n this.wrapper = wrapper\r\n this.content = content\r\n\r\n if (autoResize) {\r\n this.debouncedResize = debounce(this.resize, debounceValue)\r\n\r\n if (this.wrapper === window) {\r\n window.addEventListener('resize', this.debouncedResize, false)\r\n } else {\r\n this.wrapperResizeObserver = new ResizeObserver(this.debouncedResize)\r\n this.wrapperResizeObserver.observe(this.wrapper)\r\n }\r\n\r\n this.contentResizeObserver = new ResizeObserver(this.debouncedResize)\r\n this.contentResizeObserver.observe(this.content)\r\n }\r\n\r\n this.resize()\r\n }\r\n\r\n destroy() {\r\n this.wrapperResizeObserver?.disconnect()\r\n this.contentResizeObserver?.disconnect()\r\n window.removeEventListener('resize', this.debouncedResize, false)\r\n }\r\n\r\n resize = () => {\r\n this.onWrapperResize()\r\n this.onContentResize()\r\n }\r\n\r\n onWrapperResize = () => {\r\n if (this.wrapper === window) {\r\n this.width = window.innerWidth\r\n this.height = window.innerHeight\r\n } else {\r\n this.width = this.wrapper.clientWidth\r\n this.height = this.wrapper.clientHeight\r\n }\r\n }\r\n\r\n onContentResize = () => {\r\n if (this.wrapper === window) {\r\n this.scrollHeight = this.content.scrollHeight\r\n this.scrollWidth = this.content.scrollWidth\r\n } else {\r\n this.scrollHeight = this.wrapper.scrollHeight\r\n this.scrollWidth = this.wrapper.scrollWidth\r\n }\r\n }\r\n\r\n get limit() {\r\n return {\r\n x: this.scrollWidth - this.width,\r\n y: this.scrollHeight - this.height,\r\n }\r\n }\r\n}\r\n","export function debounce(callback, delay) {\r\n let timer\r\n return function () {\r\n let args = arguments\r\n let context = this\r\n clearTimeout(timer)\r\n timer = setTimeout(function () {\r\n callback.apply(context, args)\r\n }, delay)\r\n }\r\n}\r\n","export class Emitter {\r\n constructor() {\r\n this.events = {}\r\n }\r\n\r\n emit(event, ...args) {\r\n let callbacks = this.events[event] || []\r\n for (let i = 0, length = callbacks.length; i < length; i++) {\r\n callbacks[i](...args)\r\n }\r\n }\r\n\r\n on(event, cb) {\r\n // Add the callback to the event's callback list, or create a new list with the callback\r\n this.events[event]?.push(cb) || (this.events[event] = [cb])\r\n\r\n // Return an unsubscribe function\r\n return () => {\r\n this.events[event] = this.events[event]?.filter((i) => cb !== i)\r\n }\r\n }\r\n\r\n off(event, callback) {\r\n this.events[event] = this.events[event]?.filter((i) => callback !== i)\r\n }\r\n\r\n destroy() {\r\n this.events = {}\r\n }\r\n}\r\n","import { Emitter } from './emitter'\r\n\r\nconst LINE_HEIGHT = 100 / 6\r\n\r\nexport class VirtualScroll {\r\n constructor(element, { wheelMultiplier = 1, touchMultiplier = 1 }) {\r\n this.element = element\r\n this.wheelMultiplier = wheelMultiplier\r\n this.touchMultiplier = touchMultiplier\r\n\r\n this.touchStart = {\r\n x: null,\r\n y: null,\r\n }\r\n\r\n this.emitter = new Emitter()\r\n window.addEventListener('resize', this.onWindowResize, false)\r\n this.onWindowResize()\r\n\r\n this.element.addEventListener('wheel', this.onWheel, { passive: false })\r\n this.element.addEventListener('touchstart', this.onTouchStart, {\r\n passive: false,\r\n })\r\n this.element.addEventListener('touchmove', this.onTouchMove, {\r\n passive: false,\r\n })\r\n this.element.addEventListener('touchend', this.onTouchEnd, {\r\n passive: false,\r\n })\r\n }\r\n\r\n // Add an event listener for the given event and callback\r\n on(event, callback) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n // Remove all event listeners and clean up\r\n destroy() {\r\n this.emitter.destroy()\r\n\r\n window.removeEventListener('resize', this.onWindowResize, false)\r\n\r\n this.element.removeEventListener('wheel', this.onWheel, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchstart', this.onTouchStart, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchmove', this.onTouchMove, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchend', this.onTouchEnd, {\r\n passive: false,\r\n })\r\n }\r\n\r\n // Event handler for 'touchstart' event\r\n onTouchStart = (event) => {\r\n const { clientX, clientY } = event.targetTouches\r\n ? event.targetTouches[0]\r\n : event\r\n\r\n this.touchStart.x = clientX\r\n this.touchStart.y = clientY\r\n\r\n this.lastDelta = {\r\n x: 0,\r\n y: 0,\r\n }\r\n\r\n this.emitter.emit('scroll', {\r\n deltaX: 0,\r\n deltaY: 0,\r\n event,\r\n })\r\n }\r\n\r\n // Event handler for 'touchmove' event\r\n onTouchMove = (event) => {\r\n const { clientX, clientY } = event.targetTouches\r\n ? event.targetTouches[0]\r\n : event\r\n\r\n const deltaX = -(clientX - this.touchStart.x) * this.touchMultiplier\r\n const deltaY = -(clientY - this.touchStart.y) * this.touchMultiplier\r\n\r\n this.touchStart.x = clientX\r\n this.touchStart.y = clientY\r\n\r\n this.lastDelta = {\r\n x: deltaX,\r\n y: deltaY,\r\n }\r\n\r\n this.emitter.emit('scroll', {\r\n deltaX,\r\n deltaY,\r\n event,\r\n })\r\n }\r\n\r\n onTouchEnd = (event) => {\r\n this.emitter.emit('scroll', {\r\n deltaX: this.lastDelta.x,\r\n deltaY: this.lastDelta.y,\r\n event,\r\n })\r\n }\r\n\r\n // Event handler for 'wheel' event\r\n onWheel = (event) => {\r\n let { deltaX, deltaY, deltaMode } = event\r\n\r\n const multiplierX =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.windowWidth : 1\r\n const multiplierY =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.windowHeight : 1\r\n\r\n deltaX *= multiplierX\r\n deltaY *= multiplierY\r\n\r\n deltaX *= this.wheelMultiplier\r\n deltaY *= this.wheelMultiplier\r\n\r\n this.emitter.emit('scroll', { deltaX, deltaY, event })\r\n }\r\n\r\n onWindowResize = () => {\r\n this.windowWidth = window.innerWidth\r\n this.windowHeight = window.innerHeight\r\n }\r\n}\r\n","import { version } from '../../../package.json'\r\nimport { Animate } from './animate'\r\nimport { Dimensions } from './dimensions'\r\nimport { Emitter } from './emitter'\r\nimport { clamp, modulo } from './maths'\r\nimport { VirtualScroll } from './virtual-scroll'\r\n\r\n// Technical explanation\r\n// - listen to 'wheel' events\r\n// - prevent 'wheel' event to prevent scroll\r\n// - normalize wheel delta\r\n// - add delta to targetScroll\r\n// - animate scroll to targetScroll (smooth context)\r\n// - if animation is not running, listen to 'scroll' events (native context)\r\n\r\ntype EasingFunction = (t: number) => number\r\ntype Orientation = 'vertical' | 'horizontal'\r\ntype GestureOrientation = 'vertical' | 'horizontal' | 'both'\r\n\r\nexport type LenisOptions = {\r\n wrapper?: Window | HTMLElement\r\n content?: HTMLElement\r\n wheelEventsTarget?: Window | HTMLElement\r\n eventsTarget?: Window | HTMLElement\r\n smoothWheel?: boolean\r\n syncTouch?: boolean\r\n syncTouchLerp?: number\r\n touchInertiaMultiplier?: number\r\n duration?: number\r\n easing?: EasingFunction\r\n lerp?: number\r\n infinite?: boolean\r\n orientation?: Orientation\r\n gestureOrientation?: GestureOrientation\r\n touchMultiplier?: number\r\n wheelMultiplier?: number\r\n autoResize?: boolean\r\n prevent?: boolean | ((node: Element) => boolean)\r\n __experimental__naiveDimensions?: boolean\r\n}\r\n\r\nexport default class Lenis {\r\n // __isSmooth: boolean = false // true if scroll should be animated\r\n __isScrolling: boolean | 'native' | 'smooth' = false // true when scroll is animating\r\n __isStopped: boolean = false // true if user should not be able to scroll - enable/disable programmatically\r\n __isLocked: boolean = false // same as isStopped but enabled/disabled when scroll reaches target\r\n\r\n time: number\r\n userData: object\r\n lastVelocity: number\r\n velocity: number\r\n direction: 1 | -1 | undefined\r\n options: LenisOptions\r\n targetScroll: number\r\n animatedScroll: number\r\n // animate: Animate\r\n // emitter: Emitter\r\n // dimensions: Dimensions\r\n // virtualScroll: VirtualScroll\r\n\r\n constructor({\r\n wrapper = window,\r\n content = document.documentElement,\r\n wheelEventsTarget = wrapper, // deprecated\r\n eventsTarget = wheelEventsTarget,\r\n smoothWheel = true,\r\n syncTouch = false,\r\n syncTouchLerp = 0.075,\r\n touchInertiaMultiplier = 35,\r\n duration, // in seconds\r\n easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),\r\n lerp = !duration && 0.1,\r\n infinite = false,\r\n orientation = 'vertical', // vertical, horizontal\r\n gestureOrientation = 'vertical', // vertical, horizontal, both\r\n touchMultiplier = 1,\r\n wheelMultiplier = 1,\r\n autoResize = true,\r\n prevent = false,\r\n __experimental__naiveDimensions = false,\r\n }: LenisOptions = {}) {\r\n window.lenisVersion = version\r\n\r\n // if wrapper is html or body, fallback to window\r\n if (wrapper === document.documentElement || wrapper === document.body) {\r\n wrapper = window\r\n }\r\n\r\n this.options = {\r\n wrapper,\r\n content,\r\n wheelEventsTarget,\r\n eventsTarget,\r\n smoothWheel,\r\n syncTouch,\r\n syncTouchLerp,\r\n touchInertiaMultiplier,\r\n duration,\r\n easing,\r\n lerp,\r\n infinite,\r\n gestureOrientation,\r\n orientation,\r\n touchMultiplier,\r\n wheelMultiplier,\r\n autoResize,\r\n prevent,\r\n __experimental__naiveDimensions,\r\n }\r\n\r\n this.animate = new Animate()\r\n this.emitter = new Emitter()\r\n this.dimensions = new Dimensions({ wrapper, content, autoResize })\r\n // this.toggleClassName('lenis', true)\r\n this.updateClassName()\r\n\r\n this.userData = {}\r\n this.time = 0\r\n this.velocity = this.lastVelocity = 0\r\n this.isLocked = false\r\n this.isStopped = false\r\n // this.hasScrolled = false\r\n // this.isSmooth = syncTouch || smoothWheel\r\n // this.isSmooth = false\r\n this.isScrolling = false\r\n this.targetScroll = this.animatedScroll = this.actualScroll\r\n\r\n this.options.wrapper.addEventListener('scroll', this.onNativeScroll, false)\r\n\r\n this.virtualScroll = new VirtualScroll(eventsTarget, {\r\n touchMultiplier,\r\n wheelMultiplier,\r\n })\r\n this.virtualScroll.on('scroll', this.onVirtualScroll)\r\n }\r\n\r\n destroy() {\r\n this.emitter.destroy()\r\n\r\n this.options.wrapper.removeEventListener(\r\n 'scroll',\r\n this.onNativeScroll,\r\n false\r\n )\r\n\r\n this.virtualScroll.destroy()\r\n this.dimensions.destroy()\r\n\r\n this.cleanUpClassName()\r\n\r\n // this.rootElement.className = ''\r\n\r\n // this.toggleClassName('lenis', false)\r\n // this.toggleClassName('lenis-smooth', false)\r\n // this.toggleClassName('lenis-scrolling', false)\r\n // this.toggleClassName('lenis-stopped', false)\r\n // this.toggleClassName('lenis-locked', false)\r\n }\r\n\r\n on(event: string, callback: Function) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n off(event: string, callback: Function) {\r\n return this.emitter.off(event, callback)\r\n }\r\n\r\n private setScroll(scroll) {\r\n // apply scroll value immediately\r\n if (this.isHorizontal) {\r\n this.rootElement.scrollLeft = scroll\r\n } else {\r\n this.rootElement.scrollTop = scroll\r\n }\r\n }\r\n\r\n private onVirtualScroll = ({ deltaX, deltaY, event }) => {\r\n // keep zoom feature\r\n if (event.ctrlKey) return\r\n\r\n const isTouch = event.type.includes('touch')\r\n const isWheel = event.type.includes('wheel')\r\n\r\n this.isTouching = event.type === 'touchstart' || event.type === 'touchmove'\r\n // if (event.type === 'touchend') {\r\n // console.log('touchend', this.scroll)\r\n // // this.lastVelocity = this.velocity\r\n // // this.velocity = 0\r\n // // this.isScrolling = false\r\n // this.emit({ type: 'touchend' })\r\n // // alert('touchend')\r\n // return\r\n // }\r\n\r\n const isTapToStop =\r\n this.options.syncTouch &&\r\n isTouch &&\r\n event.type === 'touchstart' &&\r\n !this.isStopped &&\r\n !this.isLocked\r\n\r\n if (isTapToStop) {\r\n this.reset()\r\n return\r\n }\r\n\r\n const isClick = deltaX === 0 && deltaY === 0 // click event\r\n\r\n // const isPullToRefresh =\r\n // this.options.gestureOrientation === 'vertical' &&\r\n // this.scroll === 0 &&\r\n // !this.options.infinite &&\r\n // deltaY <= 5 // touch pull to refresh, not reliable yet\r\n\r\n const isUnknownGesture =\r\n (this.options.gestureOrientation === 'vertical' && deltaY === 0) ||\r\n (this.options.gestureOrientation === 'horizontal' && deltaX === 0)\r\n\r\n if (isClick || isUnknownGesture) {\r\n // console.log('prevent')\r\n return\r\n }\r\n\r\n // catch if scrolling on nested scroll elements\r\n let composedPath = event.composedPath()\r\n composedPath = composedPath.slice(0, composedPath.indexOf(this.rootElement)) // remove parents elements\r\n\r\n if (\r\n !!composedPath.find(\r\n (node) =>\r\n this.options.prevent(node) ||\r\n node.hasAttribute?.('data-lenis-prevent') ||\r\n (isTouch && node.hasAttribute?.('data-lenis-prevent-touch')) ||\r\n (isWheel && node.hasAttribute?.('data-lenis-prevent-wheel')) ||\r\n (node.classList?.contains('lenis') &&\r\n !node.classList?.contains('lenis-stopped')) // nested lenis instance\r\n )\r\n )\r\n return\r\n\r\n if (this.isStopped || this.isLocked) {\r\n event.preventDefault() // this will stop forwarding the event to the parent, this is problematic\r\n return\r\n }\r\n\r\n const isSmooth =\r\n (this.options.syncTouch && isTouch) ||\r\n (this.options.smoothWheel && isWheel)\r\n\r\n if (!isSmooth) {\r\n this.isScrolling = 'native'\r\n this.animate.stop()\r\n return\r\n }\r\n\r\n event.preventDefault()\r\n\r\n let delta = deltaY\r\n if (this.options.gestureOrientation === 'both') {\r\n delta = Math.abs(deltaY) > Math.abs(deltaX) ? deltaY : deltaX\r\n } else if (this.options.gestureOrientation === 'horizontal') {\r\n delta = deltaX\r\n }\r\n\r\n const syncTouch = isTouch && this.options.syncTouch\r\n const isTouchEnd = isTouch && event.type === 'touchend'\r\n\r\n const hasTouchInertia = isTouchEnd && Math.abs(delta) > 5\r\n\r\n if (hasTouchInertia) {\r\n delta = this.velocity * this.options.touchInertiaMultiplier\r\n }\r\n\r\n this.scrollTo(this.targetScroll + delta, {\r\n programmatic: false,\r\n ...(syncTouch\r\n ? {\r\n lerp: hasTouchInertia ? this.options.syncTouchLerp : 1,\r\n }\r\n : {\r\n lerp: this.options.lerp,\r\n duration: this.options.duration,\r\n easing: this.options.easing,\r\n }),\r\n })\r\n }\r\n\r\n resize() {\r\n this.dimensions.resize()\r\n }\r\n\r\n private emit({ userData = {} } = {}) {\r\n this.userData = userData\r\n this.emitter.emit('scroll', this)\r\n this.userData = {}\r\n }\r\n\r\n private onNativeScroll = () => {\r\n clearTimeout(this.__resetVelocityTimeout)\r\n delete this.__resetVelocityTimeout\r\n\r\n if (this.__preventNextNativeScrollEvent) {\r\n delete this.__preventNextNativeScrollEvent\r\n return\r\n }\r\n\r\n if (this.isScrolling === false || this.isScrolling === 'native') {\r\n const lastScroll = this.animatedScroll\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.lastVelocity = this.velocity\r\n this.velocity = this.animatedScroll - lastScroll\r\n this.direction = Math.sign(this.animatedScroll - lastScroll)\r\n // this.isSmooth = false\r\n this.isScrolling = this.hasScrolled ? 'native' : false\r\n this.emit()\r\n\r\n if (this.velocity !== 0) {\r\n this.__resetVelocityTimeout = setTimeout(() => {\r\n this.lastVelocity = this.velocity\r\n this.velocity = 0\r\n this.isScrolling = false\r\n this.emit()\r\n }, 400)\r\n }\r\n\r\n // this.hasScrolled = true\r\n // }, 50)\r\n }\r\n }\r\n\r\n private reset() {\r\n this.isLocked = false\r\n this.isScrolling = false\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.lastVelocity = this.velocity = 0\r\n this.animate.stop()\r\n }\r\n\r\n start() {\r\n if (!this.isStopped) return\r\n this.isStopped = false\r\n\r\n this.reset()\r\n }\r\n\r\n stop() {\r\n if (this.isStopped) return\r\n this.isStopped = true\r\n this.animate.stop()\r\n\r\n this.reset()\r\n }\r\n\r\n raf(time: number) {\r\n const deltaTime = time - (this.time || time)\r\n this.time = time\r\n\r\n this.animate.advance(deltaTime * 0.001)\r\n }\r\n\r\n scrollTo(\r\n target: number | string | HTMLElement,\r\n {\r\n offset = 0,\r\n immediate = false,\r\n lock = false,\r\n duration = this.options.duration,\r\n easing = this.options.easing,\r\n lerp = !duration && this.options.lerp,\r\n onStart,\r\n onComplete,\r\n force = false, // scroll even if stopped\r\n programmatic = true, // called from outside of the class\r\n userData = {},\r\n }: {\r\n offset?: number\r\n immediate?: boolean\r\n lock?: boolean\r\n duration?: number\r\n easing?: EasingFunction\r\n lerp?: number\r\n onStart?: (lenis: Lenis) => void\r\n onComplete?: (lenis: Lenis) => void\r\n force?: boolean\r\n programmatic?: boolean\r\n userData?: object\r\n } = {}\r\n ) {\r\n if ((this.isStopped || this.isLocked) && !force) return\r\n\r\n // keywords\r\n if (['top', 'left', 'start'].includes(target)) {\r\n target = 0\r\n } else if (['bottom', 'right', 'end'].includes(target)) {\r\n target = 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 }\r\n\r\n if (node) {\r\n if (this.options.wrapper !== window) {\r\n // nested scroll offset correction\r\n const wrapperRect = this.options.wrapper.getBoundingClientRect()\r\n offset -= this.isHorizontal ? wrapperRect.left : wrapperRect.top\r\n }\r\n\r\n const rect = node.getBoundingClientRect()\r\n\r\n target =\r\n (this.isHorizontal ? rect.left : rect.top) + this.animatedScroll\r\n }\r\n }\r\n\r\n if (typeof target !== 'number') return\r\n\r\n target += offset\r\n target = Math.round(target)\r\n\r\n if (this.options.infinite) {\r\n if (programmatic) {\r\n this.targetScroll = this.animatedScroll = this.scroll\r\n }\r\n } else {\r\n target = clamp(0, target, this.limit)\r\n }\r\n\r\n if (immediate) {\r\n this.animatedScroll = this.targetScroll = target\r\n this.setScroll(this.scroll)\r\n this.reset()\r\n onComplete?.(this)\r\n return\r\n }\r\n\r\n if (target === this.targetScroll) return\r\n\r\n if (!programmatic) {\r\n this.targetScroll = target\r\n }\r\n\r\n this.animate.fromTo(this.animatedScroll, target, {\r\n duration,\r\n easing,\r\n lerp,\r\n onStart: () => {\r\n // started\r\n if (lock) this.isLocked = true\r\n this.isScrolling = 'smooth'\r\n onStart?.(this)\r\n },\r\n onUpdate: (value: number, completed: boolean) => {\r\n this.isScrolling = 'smooth'\r\n\r\n // updated\r\n this.lastVelocity = this.velocity\r\n this.velocity = value - this.animatedScroll\r\n this.direction = Math.sign(this.velocity)\r\n\r\n this.animatedScroll = value\r\n this.setScroll(this.scroll)\r\n\r\n if (programmatic) {\r\n // wheel during programmatic should stop it\r\n this.targetScroll = value\r\n }\r\n\r\n if (!completed) this.emit({ userData })\r\n\r\n if (completed) {\r\n this.reset()\r\n this.emit({ userData })\r\n onComplete?.(this)\r\n\r\n // avoid emitting event twice\r\n this.__preventNextNativeScrollEvent = true\r\n // requestAnimationFrame(() => {\r\n // delete this.__preventNextNativeScrollEvent\r\n // })\r\n }\r\n },\r\n })\r\n }\r\n\r\n get rootElement() {\r\n return this.options.wrapper === window\r\n ? document.documentElement\r\n : this.options.wrapper\r\n }\r\n\r\n get limit() {\r\n if (this.options.__experimental__naiveDimensions) {\r\n if (this.isHorizontal) {\r\n return this.rootElement.scrollWidth - this.rootElement.clientWidth\r\n } else {\r\n return this.rootElement.scrollHeight - this.rootElement.clientHeight\r\n }\r\n } else {\r\n return this.dimensions.limit[this.isHorizontal ? 'x' : 'y']\r\n }\r\n }\r\n\r\n get isHorizontal() {\r\n return this.options.orientation === 'horizontal'\r\n }\r\n\r\n get actualScroll(): number {\r\n // value browser takes into account\r\n return this.isHorizontal\r\n ? this.rootElement.scrollLeft\r\n : this.rootElement.scrollTop\r\n }\r\n\r\n get scroll(): number {\r\n return this.options.infinite\r\n ? modulo(this.animatedScroll, this.limit)\r\n : this.animatedScroll\r\n }\r\n\r\n get progress(): number {\r\n // avoid progress to be NaN\r\n return this.limit === 0 ? 1 : this.scroll / this.limit\r\n }\r\n\r\n // get isSmooth() {\r\n // return this.__isSmooth\r\n // }\r\n\r\n // private set isSmooth(value: boolean) {\r\n // if (this.__isSmooth !== value) {\r\n // this.__isSmooth = value\r\n // this.updateClassName()\r\n // }\r\n // }\r\n\r\n get isScrolling() {\r\n return this.__isScrolling\r\n }\r\n\r\n private set isScrolling(value: boolean) {\r\n if (this.__isScrolling !== value) {\r\n this.__isScrolling = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isStopped() {\r\n return this.__isStopped\r\n }\r\n\r\n private set isStopped(value: boolean) {\r\n if (this.__isStopped !== value) {\r\n this.__isStopped = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isLocked() {\r\n return this.__isLocked\r\n }\r\n\r\n private set isLocked(value: boolean) {\r\n if (this.__isLocked !== value) {\r\n this.__isLocked = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isSmooth() {\r\n return this.isScrolling === 'smooth'\r\n }\r\n\r\n get className() {\r\n let className = 'lenis'\r\n if (this.isStopped) className += ' lenis-stopped'\r\n if (this.isLocked) className += ' lenis-locked'\r\n if (this.isScrolling) className += ' lenis-scrolling'\r\n if (this.isScrolling === 'smooth') className += ' lenis-smooth'\r\n // if (this.isScrolling === 'native') className += ' lenis-native'\r\n // if (this.isSmooth) className += ' lenis-smooth'\r\n return className\r\n }\r\n\r\n private updateClassName() {\r\n this.cleanUpClassName()\r\n\r\n this.rootElement.className =\r\n `${this.rootElement.className} ${this.className}`.trim()\r\n // this.emitter.emit('className change', this)\r\n }\r\n\r\n private cleanUpClassName() {\r\n this.rootElement.className = this.rootElement.className\r\n .replace(/lenis(-\\w+)?/g, '')\r\n .trim()\r\n }\r\n\r\n // private toggleClassName(name: string, value: boolean) {\r\n // // this.rootElement.classList.toggle(name, value)\r\n // this.rootElement.className = this.className\r\n // this.emitter.emit('className change', this)\r\n // }\r\n}\r\n"],"names":["clamp","min","input","max","Math","Animate","advance","deltaTime","this","isRunning","completed","lerp","value","damp","x","y","lambda","dt","t","exp","to","round","currentTime","linearProgress","duration","easedProgress","easing","from","stop","onUpdate","fromTo","onStart","Dimensions","constructor","wrapper","content","autoResize","debounce","debounceValue","debouncedResize","callback","delay","timer","args","arguments","context","clearTimeout","setTimeout","apply","resize","window","addEventListener","wrapperResizeObserver","ResizeObserver","observe","contentResizeObserver","destroy","disconnect","removeEventListener","onWrapperResize","onContentResize","width","innerWidth","height","innerHeight","clientWidth","clientHeight","scrollHeight","scrollWidth","limit","Emitter","events","emit","event","callbacks","i","length","on","cb","push","filter","off","LINE_HEIGHT","VirtualScroll","element","wheelMultiplier","touchMultiplier","touchStart","emitter","onWindowResize","onWheel","passive","onTouchStart","onTouchMove","onTouchEnd","clientX","clientY","targetTouches","lastDelta","deltaX","deltaY","deltaMode","windowWidth","windowHeight","Lenis","document","documentElement","wheelEventsTarget","eventsTarget","smoothWheel","syncTouch","syncTouchLerp","touchInertiaMultiplier","pow","infinite","orientation","gestureOrientation","prevent","__experimental__naiveDimensions","__isScrolling","__isStopped","__isLocked","onVirtualScroll","ctrlKey","isTouch","type","includes","isWheel","isTouching","options","isStopped","isLocked","reset","isClick","isUnknownGesture","composedPath","slice","indexOf","rootElement","find","node","_a","hasAttribute","call","_b","_c","classList","_d","contains","_e","preventDefault","isScrolling","animate","delta","abs","hasTouchInertia","velocity","scrollTo","targetScroll","Object","assign","programmatic","onNativeScroll","__resetVelocityTimeout","__preventNextNativeScrollEvent","lastScroll","animatedScroll","actualScroll","lastVelocity","direction","sign","hasScrolled","lenisVersion","body","dimensions","updateClassName","userData","time","virtualScroll","cleanUpClassName","setScroll","scroll","isHorizontal","scrollLeft","scrollTop","start","raf","target","offset","immediate","lock","onComplete","force","querySelector","nodeType","wrapperRect","getBoundingClientRect","left","top","rect","modulo","n","d","progress","isSmooth","className","trim","replace"],"mappings":"sOACO,SAASA,MAAMC,EAAKC,EAAOC,GAChC,OAAOC,KAAKD,IAAIF,EAAKG,KAAKH,IAAIC,EAAOC,GACvC,CCAO,MAAME,QAEX,OAAAC,CAAQC,GACN,IAAKC,KAAKC,UAAW,OAErB,IAAIC,GAAY,EAEhB,GAAIF,KAAKG,KACPH,KAAKI,MDKJ,SAASC,KAAKC,EAAGC,EAAGC,EAAQC,GACjC,OANK,SAASN,KAAKG,EAAGC,EAAGG,GACzB,OAAQ,EAAIA,GAAKJ,EAAII,EAAIH,CAC3B,CAISJ,CAAKG,EAAGC,EAAG,EAAIX,KAAKe,KAAKH,EAASC,GAC3C,CCPmBJ,CAAKL,KAAKI,MAAOJ,KAAKY,GAAgB,GAAZZ,KAAKG,KAAWJ,GACnDH,KAAKiB,MAAMb,KAAKI,SAAWJ,KAAKY,KAClCZ,KAAKI,MAAQJ,KAAKY,GAClBV,GAAY,OAET,CACLF,KAAKc,aAAef,EACpB,MAAMgB,EAAiBvB,MAAM,EAAGQ,KAAKc,YAAcd,KAAKgB,SAAU,GAElEd,EAAYa,GAAkB,EAC9B,MAAME,EAAgBf,EAAY,EAAIF,KAAKkB,OAAOH,GAClDf,KAAKI,MAAQJ,KAAKmB,MAAQnB,KAAKY,GAAKZ,KAAKmB,MAAQF,CAClD,CAEGf,GACFF,KAAKoB,OAIPpB,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AAK8J,cACV,CAED,YAAIqC,GAEF,OAAsB,IAAfnM,KAAK6D,MAAc,EAAI7D,KAAK6K,OAAS7K,KAAK6D,KAClD,CAaD,eAAIkF,GACF,OAAO/I,KAAK+G,aACb,CAED,eAAYgC,CAAY3I,GAClBJ,KAAK+G,gBAAkB3G,IACzBJ,KAAK+G,cAAgB3G,EACrBJ,KAAKuK,kBAER,CAED,aAAI7C,GACF,OAAO1H,KAAKgH,WACb,CAED,aAAYU,CAAUtH,GAChBJ,KAAKgH,cAAgB5G,IACvBJ,KAAKgH,YAAc5G,EACnBJ,KAAKuK,kBAER,CAED,YAAI5C,GACF,OAAO3H,KAAKiH,UACb,CAED,YAAYU,CAASvH,GACfJ,KAAKiH,aAAe7G,IACtBJ,KAAKiH,WAAa7G,EAClBJ,KAAKuK,kBAER,CAED,YAAI6B,GACF,MAA4B,WAArBpM,KAAK+I,WACb,CAED,aAAIsD,GACF,IAAIA,EAAY,QAOhB,OANIrM,KAAK0H,YAAW2E,GAAa,kBAC7BrM,KAAK2H,WAAU0E,GAAa,iBAC5BrM,KAAK+I,cAAasD,GAAa,oBACV,WAArBrM,KAAK+I,cAA0BsD,GAAa,iBAGzCA,CACR,CAEO,eAAA9B,GACNvK,KAAK2K,mBAEL3K,KAAKkI,YAAYmE,UACf,GAAGrM,KAAKkI,YAAYmE,aAAarM,KAAKqM,YAAYC,MAErD,CAEO,gBAAA3B,GACN3K,KAAKkI,YAAYmE,UAAYrM,KAAKkI,YAAYmE,UAC3CE,QAAQ,gBAAiB,IACzBD,MACJ"} \ No newline at end of file +{"version":3,"file":"lenis.min.js","sources":["../src/maths.js","../src/animate.js","../src/dimensions.js","../src/debounce.js","../src/emitter.js","../src/virtual-scroll.js","../src/index.ts"],"sourcesContent":["// Clamp a value between a minimum and maximum value\r\nexport function clamp(min, input, max) {\r\n return Math.max(min, Math.min(input, max))\r\n}\r\n\r\n// Truncate a floating-point number to a specified number of decimal places\r\nexport function truncate(value, decimals = 0) {\r\n return parseFloat(value.toFixed(decimals))\r\n}\r\n\r\n// Linearly interpolate between two values using an amount (0 <= t <= 1)\r\nexport function lerp(x, y, t) {\r\n return (1 - t) * x + t * y\r\n}\r\n\r\n// http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/\r\nexport function damp(x, y, lambda, dt) {\r\n return lerp(x, y, 1 - Math.exp(-lambda * dt))\r\n}\r\n\r\n// Calculate the modulo of the dividend and divisor while keeping the result within the same sign as the divisor\r\n// https://anguscroll.com/just/just-modulo\r\nexport function modulo(n, d) {\r\n return ((n % d) + d) % d\r\n}\r\n","import { clamp, damp } from './maths'\r\n\r\n// Animate class to handle value animations with lerping or easing\r\nexport class Animate {\r\n // Advance the animation by the given delta time\r\n advance(deltaTime) {\r\n if (!this.isRunning) return\r\n\r\n let completed = false\r\n\r\n if (this.lerp) {\r\n this.value = damp(this.value, this.to, this.lerp * 60, deltaTime)\r\n if (Math.round(this.value) === this.to) {\r\n this.value = this.to\r\n completed = true\r\n }\r\n } else {\r\n this.currentTime += deltaTime\r\n const linearProgress = clamp(0, this.currentTime / this.duration, 1)\r\n\r\n completed = linearProgress >= 1\r\n const easedProgress = completed ? 1 : this.easing(linearProgress)\r\n this.value = this.from + (this.to - this.from) * easedProgress\r\n }\r\n\r\n if (completed) {\r\n this.stop()\r\n }\r\n\r\n // Call the onUpdate callback with the current value and completed status\r\n this.onUpdate?.(this.value, completed)\r\n }\r\n\r\n // Stop the animation\r\n stop() {\r\n this.isRunning = false\r\n }\r\n\r\n // Set up the animation from a starting value to an ending value\r\n // with optional parameters for lerping, duration, easing, and onUpdate callback\r\n fromTo(\r\n from,\r\n to,\r\n { lerp = 0.1, duration = 1, easing = (t) => t, onStart, onUpdate }\r\n ) {\r\n this.from = this.value = from\r\n this.to = to\r\n this.lerp = lerp\r\n this.duration = duration\r\n this.easing = easing\r\n this.currentTime = 0\r\n this.isRunning = true\r\n\r\n onStart?.()\r\n this.onUpdate = onUpdate\r\n }\r\n}\r\n","import { debounce } from './debounce'\r\n\r\nexport class Dimensions {\r\n constructor({\r\n wrapper,\r\n content,\r\n autoResize = true,\r\n debounce: debounceValue = 250,\r\n } = {}) {\r\n this.wrapper = wrapper\r\n this.content = content\r\n\r\n if (autoResize) {\r\n this.debouncedResize = debounce(this.resize, debounceValue)\r\n\r\n if (this.wrapper === window) {\r\n window.addEventListener('resize', this.debouncedResize, false)\r\n } else {\r\n this.wrapperResizeObserver = new ResizeObserver(this.debouncedResize)\r\n this.wrapperResizeObserver.observe(this.wrapper)\r\n }\r\n\r\n this.contentResizeObserver = new ResizeObserver(this.debouncedResize)\r\n this.contentResizeObserver.observe(this.content)\r\n }\r\n\r\n this.resize()\r\n }\r\n\r\n destroy() {\r\n this.wrapperResizeObserver?.disconnect()\r\n this.contentResizeObserver?.disconnect()\r\n window.removeEventListener('resize', this.debouncedResize, false)\r\n }\r\n\r\n resize = () => {\r\n this.onWrapperResize()\r\n this.onContentResize()\r\n }\r\n\r\n onWrapperResize = () => {\r\n if (this.wrapper === window) {\r\n this.width = window.innerWidth\r\n this.height = window.innerHeight\r\n } else {\r\n this.width = this.wrapper.clientWidth\r\n this.height = this.wrapper.clientHeight\r\n }\r\n }\r\n\r\n onContentResize = () => {\r\n if (this.wrapper === window) {\r\n this.scrollHeight = this.content.scrollHeight\r\n this.scrollWidth = this.content.scrollWidth\r\n } else {\r\n this.scrollHeight = this.wrapper.scrollHeight\r\n this.scrollWidth = this.wrapper.scrollWidth\r\n }\r\n }\r\n\r\n get limit() {\r\n return {\r\n x: this.scrollWidth - this.width,\r\n y: this.scrollHeight - this.height,\r\n }\r\n }\r\n}\r\n","export function debounce(callback, delay) {\r\n let timer\r\n return function () {\r\n let args = arguments\r\n let context = this\r\n clearTimeout(timer)\r\n timer = setTimeout(function () {\r\n callback.apply(context, args)\r\n }, delay)\r\n }\r\n}\r\n","export class Emitter {\r\n constructor() {\r\n this.events = {}\r\n }\r\n\r\n emit(event, ...args) {\r\n let callbacks = this.events[event] || []\r\n for (let i = 0, length = callbacks.length; i < length; i++) {\r\n callbacks[i](...args)\r\n }\r\n }\r\n\r\n on(event, cb) {\r\n // Add the callback to the event's callback list, or create a new list with the callback\r\n this.events[event]?.push(cb) || (this.events[event] = [cb])\r\n\r\n // Return an unsubscribe function\r\n return () => {\r\n this.events[event] = this.events[event]?.filter((i) => cb !== i)\r\n }\r\n }\r\n\r\n off(event, callback) {\r\n this.events[event] = this.events[event]?.filter((i) => callback !== i)\r\n }\r\n\r\n destroy() {\r\n this.events = {}\r\n }\r\n}\r\n","import { Emitter } from './emitter'\r\n\r\nconst LINE_HEIGHT = 100 / 6\r\n\r\nexport class VirtualScroll {\r\n constructor(element, { wheelMultiplier = 1, touchMultiplier = 1 }) {\r\n this.element = element\r\n this.wheelMultiplier = wheelMultiplier\r\n this.touchMultiplier = touchMultiplier\r\n\r\n this.touchStart = {\r\n x: null,\r\n y: null,\r\n }\r\n\r\n this.emitter = new Emitter()\r\n window.addEventListener('resize', this.onWindowResize, false)\r\n this.onWindowResize()\r\n\r\n this.element.addEventListener('wheel', this.onWheel, { passive: false })\r\n this.element.addEventListener('touchstart', this.onTouchStart, {\r\n passive: false,\r\n })\r\n this.element.addEventListener('touchmove', this.onTouchMove, {\r\n passive: false,\r\n })\r\n this.element.addEventListener('touchend', this.onTouchEnd, {\r\n passive: false,\r\n })\r\n }\r\n\r\n // Add an event listener for the given event and callback\r\n on(event, callback) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n // Remove all event listeners and clean up\r\n destroy() {\r\n this.emitter.destroy()\r\n\r\n window.removeEventListener('resize', this.onWindowResize, false)\r\n\r\n this.element.removeEventListener('wheel', this.onWheel, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchstart', this.onTouchStart, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchmove', this.onTouchMove, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchend', this.onTouchEnd, {\r\n passive: false,\r\n })\r\n }\r\n\r\n // Event handler for 'touchstart' event\r\n onTouchStart = (event) => {\r\n const { clientX, clientY } = event.targetTouches\r\n ? event.targetTouches[0]\r\n : event\r\n\r\n this.touchStart.x = clientX\r\n this.touchStart.y = clientY\r\n\r\n this.lastDelta = {\r\n x: 0,\r\n y: 0,\r\n }\r\n\r\n this.emitter.emit('scroll', {\r\n deltaX: 0,\r\n deltaY: 0,\r\n event,\r\n })\r\n }\r\n\r\n // Event handler for 'touchmove' event\r\n onTouchMove = (event) => {\r\n const { clientX, clientY } = event.targetTouches\r\n ? event.targetTouches[0]\r\n : event\r\n\r\n const deltaX = -(clientX - this.touchStart.x) * this.touchMultiplier\r\n const deltaY = -(clientY - this.touchStart.y) * this.touchMultiplier\r\n\r\n this.touchStart.x = clientX\r\n this.touchStart.y = clientY\r\n\r\n this.lastDelta = {\r\n x: deltaX,\r\n y: deltaY,\r\n }\r\n\r\n this.emitter.emit('scroll', {\r\n deltaX,\r\n deltaY,\r\n event,\r\n })\r\n }\r\n\r\n onTouchEnd = (event) => {\r\n this.emitter.emit('scroll', {\r\n deltaX: this.lastDelta.x,\r\n deltaY: this.lastDelta.y,\r\n event,\r\n })\r\n }\r\n\r\n // Event handler for 'wheel' event\r\n onWheel = (event) => {\r\n let { deltaX, deltaY, deltaMode } = event\r\n\r\n const multiplierX =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.windowWidth : 1\r\n const multiplierY =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.windowHeight : 1\r\n\r\n deltaX *= multiplierX\r\n deltaY *= multiplierY\r\n\r\n deltaX *= this.wheelMultiplier\r\n deltaY *= this.wheelMultiplier\r\n\r\n this.emitter.emit('scroll', { deltaX, deltaY, event })\r\n }\r\n\r\n onWindowResize = () => {\r\n this.windowWidth = window.innerWidth\r\n this.windowHeight = window.innerHeight\r\n }\r\n}\r\n","import { version } from '../../../package.json'\r\nimport { Animate } from './animate'\r\nimport { Dimensions } from './dimensions'\r\nimport { Emitter } from './emitter'\r\nimport { clamp, modulo } from './maths'\r\nimport { VirtualScroll } from './virtual-scroll'\r\n\r\n// Technical explanation\r\n// - listen to 'wheel' events\r\n// - prevent 'wheel' event to prevent scroll\r\n// - normalize wheel delta\r\n// - add delta to targetScroll\r\n// - animate scroll to targetScroll (smooth context)\r\n// - if animation is not running, listen to 'scroll' events (native context)\r\n\r\ntype EasingFunction = (t: number) => number\r\ntype Orientation = 'vertical' | 'horizontal'\r\ntype GestureOrientation = 'vertical' | 'horizontal' | 'both'\r\n\r\nexport type LenisOptions = {\r\n wrapper?: Window | HTMLElement\r\n content?: HTMLElement\r\n wheelEventsTarget?: Window | HTMLElement\r\n eventsTarget?: Window | HTMLElement\r\n smoothWheel?: boolean\r\n syncTouch?: boolean\r\n syncTouchLerp?: number\r\n touchInertiaMultiplier?: number\r\n duration?: number\r\n easing?: EasingFunction\r\n lerp?: number\r\n infinite?: boolean\r\n orientation?: Orientation\r\n gestureOrientation?: GestureOrientation\r\n touchMultiplier?: number\r\n wheelMultiplier?: number\r\n autoResize?: boolean\r\n prevent?: boolean | ((node: Element) => boolean)\r\n __experimental__naiveDimensions?: boolean\r\n}\r\n\r\nexport default class Lenis {\r\n // __isSmooth: boolean = false // true if scroll should be animated\r\n __isScrolling: boolean | 'native' | 'smooth' = false // true when scroll is animating\r\n __isStopped: boolean = false // true if user should not be able to scroll - enable/disable programmatically\r\n __isLocked: boolean = false // same as isStopped but enabled/disabled when scroll reaches target\r\n\r\n time: number\r\n userData: object\r\n lastVelocity: number\r\n velocity: number\r\n direction: 1 | -1 | undefined\r\n options: LenisOptions\r\n targetScroll: number\r\n animatedScroll: number\r\n // animate: Animate\r\n // emitter: Emitter\r\n // dimensions: Dimensions\r\n // virtualScroll: VirtualScroll\r\n\r\n constructor({\r\n wrapper = window,\r\n content = document.documentElement,\r\n wheelEventsTarget = wrapper, // deprecated\r\n eventsTarget = wheelEventsTarget,\r\n smoothWheel = true,\r\n syncTouch = false,\r\n syncTouchLerp = 0.075,\r\n touchInertiaMultiplier = 35,\r\n duration, // in seconds\r\n easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),\r\n lerp = !duration && 0.1,\r\n infinite = false,\r\n orientation = 'vertical', // vertical, horizontal\r\n gestureOrientation = 'vertical', // vertical, horizontal, both\r\n touchMultiplier = 1,\r\n wheelMultiplier = 1,\r\n autoResize = true,\r\n prevent = false,\r\n __experimental__naiveDimensions = false,\r\n }: LenisOptions = {}) {\r\n window.lenisVersion = version\r\n\r\n // if wrapper is html or body, fallback to window\r\n if (wrapper === document.documentElement || wrapper === document.body) {\r\n wrapper = window\r\n }\r\n\r\n this.options = {\r\n wrapper,\r\n content,\r\n wheelEventsTarget,\r\n eventsTarget,\r\n smoothWheel,\r\n syncTouch,\r\n syncTouchLerp,\r\n touchInertiaMultiplier,\r\n duration,\r\n easing,\r\n lerp,\r\n infinite,\r\n gestureOrientation,\r\n orientation,\r\n touchMultiplier,\r\n wheelMultiplier,\r\n autoResize,\r\n prevent,\r\n __experimental__naiveDimensions,\r\n }\r\n\r\n this.animate = new Animate()\r\n this.emitter = new Emitter()\r\n this.dimensions = new Dimensions({ wrapper, content, autoResize })\r\n // this.toggleClassName('lenis', true)\r\n this.updateClassName()\r\n\r\n this.userData = {}\r\n this.time = 0\r\n this.velocity = this.lastVelocity = 0\r\n this.isLocked = false\r\n this.isStopped = false\r\n // this.hasScrolled = false\r\n // this.isSmooth = syncTouch || smoothWheel\r\n // this.isSmooth = false\r\n this.isScrolling = false\r\n this.targetScroll = this.animatedScroll = this.actualScroll\r\n\r\n this.options.wrapper.addEventListener('scroll', this.onNativeScroll, false)\r\n\r\n this.virtualScroll = new VirtualScroll(eventsTarget, {\r\n touchMultiplier,\r\n wheelMultiplier,\r\n })\r\n this.virtualScroll.on('scroll', this.onVirtualScroll)\r\n }\r\n\r\n destroy() {\r\n this.emitter.destroy()\r\n\r\n this.options.wrapper.removeEventListener(\r\n 'scroll',\r\n this.onNativeScroll,\r\n false\r\n )\r\n\r\n this.virtualScroll.destroy()\r\n this.dimensions.destroy()\r\n\r\n this.cleanUpClassName()\r\n\r\n // this.rootElement.className = ''\r\n\r\n // this.toggleClassName('lenis', false)\r\n // this.toggleClassName('lenis-smooth', false)\r\n // this.toggleClassName('lenis-scrolling', false)\r\n // this.toggleClassName('lenis-stopped', false)\r\n // this.toggleClassName('lenis-locked', false)\r\n }\r\n\r\n on(event: string, callback: Function) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n off(event: string, callback: Function) {\r\n return this.emitter.off(event, callback)\r\n }\r\n\r\n private setScroll(scroll) {\r\n // apply scroll value immediately\r\n if (this.isHorizontal) {\r\n this.rootElement.scrollLeft = scroll\r\n } else {\r\n this.rootElement.scrollTop = scroll\r\n }\r\n }\r\n\r\n private onVirtualScroll = ({ deltaX, deltaY, event }) => {\r\n // keep zoom feature\r\n if (event.ctrlKey) return\r\n\r\n const isTouch = event.type.includes('touch')\r\n const isWheel = event.type.includes('wheel')\r\n\r\n this.isTouching = event.type === 'touchstart' || event.type === 'touchmove'\r\n // if (event.type === 'touchend') {\r\n // console.log('touchend', this.scroll)\r\n // // this.lastVelocity = this.velocity\r\n // // this.velocity = 0\r\n // // this.isScrolling = false\r\n // this.emit({ type: 'touchend' })\r\n // // alert('touchend')\r\n // return\r\n // }\r\n\r\n const isTapToStop =\r\n this.options.syncTouch &&\r\n isTouch &&\r\n event.type === 'touchstart' &&\r\n !this.isStopped &&\r\n !this.isLocked\r\n\r\n if (isTapToStop) {\r\n this.reset()\r\n return\r\n }\r\n\r\n const isClick = deltaX === 0 && deltaY === 0 // click event\r\n\r\n // const isPullToRefresh =\r\n // this.options.gestureOrientation === 'vertical' &&\r\n // this.scroll === 0 &&\r\n // !this.options.infinite &&\r\n // deltaY <= 5 // touch pull to refresh, not reliable yet\r\n\r\n const isUnknownGesture =\r\n (this.options.gestureOrientation === 'vertical' && deltaY === 0) ||\r\n (this.options.gestureOrientation === 'horizontal' && deltaX === 0)\r\n\r\n if (isClick || isUnknownGesture) {\r\n // console.log('prevent')\r\n return\r\n }\r\n\r\n // catch if scrolling on nested scroll elements\r\n let composedPath = event.composedPath()\r\n composedPath = composedPath.slice(0, composedPath.indexOf(this.rootElement)) // remove parents elements\r\n\r\n const prevent = this.options.prevent\r\n\r\n if (\r\n !!composedPath.find(\r\n (node) =>\r\n (typeof prevent === 'function' ? prevent?.(node) : prevent) ||\r\n node.hasAttribute?.('data-lenis-prevent') ||\r\n (isTouch && node.hasAttribute?.('data-lenis-prevent-touch')) ||\r\n (isWheel && node.hasAttribute?.('data-lenis-prevent-wheel')) ||\r\n (node.classList?.contains('lenis') &&\r\n !node.classList?.contains('lenis-stopped')) // nested lenis instance\r\n )\r\n )\r\n return\r\n\r\n if (this.isStopped || this.isLocked) {\r\n event.preventDefault() // this will stop forwarding the event to the parent, this is problematic\r\n return\r\n }\r\n\r\n const isSmooth =\r\n (this.options.syncTouch && isTouch) ||\r\n (this.options.smoothWheel && isWheel)\r\n\r\n if (!isSmooth) {\r\n this.isScrolling = 'native'\r\n this.animate.stop()\r\n return\r\n }\r\n\r\n event.preventDefault()\r\n\r\n let delta = deltaY\r\n if (this.options.gestureOrientation === 'both') {\r\n delta = Math.abs(deltaY) > Math.abs(deltaX) ? deltaY : deltaX\r\n } else if (this.options.gestureOrientation === 'horizontal') {\r\n delta = deltaX\r\n }\r\n\r\n const syncTouch = isTouch && this.options.syncTouch\r\n const isTouchEnd = isTouch && event.type === 'touchend'\r\n\r\n const hasTouchInertia = isTouchEnd && Math.abs(delta) > 5\r\n\r\n if (hasTouchInertia) {\r\n delta = this.velocity * this.options.touchInertiaMultiplier\r\n }\r\n\r\n this.scrollTo(this.targetScroll + delta, {\r\n programmatic: false,\r\n ...(syncTouch\r\n ? {\r\n lerp: hasTouchInertia ? this.options.syncTouchLerp : 1,\r\n }\r\n : {\r\n lerp: this.options.lerp,\r\n duration: this.options.duration,\r\n easing: this.options.easing,\r\n }),\r\n })\r\n }\r\n\r\n resize() {\r\n this.dimensions.resize()\r\n }\r\n\r\n private emit({ userData = {} } = {}) {\r\n this.userData = userData\r\n this.emitter.emit('scroll', this)\r\n this.userData = {}\r\n }\r\n\r\n private onNativeScroll = () => {\r\n clearTimeout(this.__resetVelocityTimeout)\r\n delete this.__resetVelocityTimeout\r\n\r\n if (this.__preventNextNativeScrollEvent) {\r\n delete this.__preventNextNativeScrollEvent\r\n return\r\n }\r\n\r\n if (this.isScrolling === false || this.isScrolling === 'native') {\r\n const lastScroll = this.animatedScroll\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.lastVelocity = this.velocity\r\n this.velocity = this.animatedScroll - lastScroll\r\n this.direction = Math.sign(this.animatedScroll - lastScroll)\r\n // this.isSmooth = false\r\n this.isScrolling = this.hasScrolled ? 'native' : false\r\n this.emit()\r\n\r\n if (this.velocity !== 0) {\r\n this.__resetVelocityTimeout = setTimeout(() => {\r\n this.lastVelocity = this.velocity\r\n this.velocity = 0\r\n this.isScrolling = false\r\n this.emit()\r\n }, 400)\r\n }\r\n\r\n // this.hasScrolled = true\r\n // }, 50)\r\n }\r\n }\r\n\r\n private reset() {\r\n this.isLocked = false\r\n this.isScrolling = false\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.lastVelocity = this.velocity = 0\r\n this.animate.stop()\r\n }\r\n\r\n start() {\r\n if (!this.isStopped) return\r\n this.isStopped = false\r\n\r\n this.reset()\r\n }\r\n\r\n stop() {\r\n if (this.isStopped) return\r\n this.isStopped = true\r\n this.animate.stop()\r\n\r\n this.reset()\r\n }\r\n\r\n raf(time: number) {\r\n const deltaTime = time - (this.time || time)\r\n this.time = time\r\n\r\n this.animate.advance(deltaTime * 0.001)\r\n }\r\n\r\n scrollTo(\r\n target: number | string | HTMLElement,\r\n {\r\n offset = 0,\r\n immediate = false,\r\n lock = false,\r\n duration = this.options.duration,\r\n easing = this.options.easing,\r\n lerp = !duration && this.options.lerp,\r\n onStart,\r\n onComplete,\r\n force = false, // scroll even if stopped\r\n programmatic = true, // called from outside of the class\r\n userData = {},\r\n }: {\r\n offset?: number\r\n immediate?: boolean\r\n lock?: boolean\r\n duration?: number\r\n easing?: EasingFunction\r\n lerp?: number\r\n onStart?: (lenis: Lenis) => void\r\n onComplete?: (lenis: Lenis) => void\r\n force?: boolean\r\n programmatic?: boolean\r\n userData?: object\r\n } = {}\r\n ) {\r\n if ((this.isStopped || this.isLocked) && !force) return\r\n\r\n // keywords\r\n if (['top', 'left', 'start'].includes(target)) {\r\n target = 0\r\n } else if (['bottom', 'right', 'end'].includes(target)) {\r\n target = 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 }\r\n\r\n if (node) {\r\n if (this.options.wrapper !== window) {\r\n // nested scroll offset correction\r\n const wrapperRect = this.options.wrapper.getBoundingClientRect()\r\n offset -= this.isHorizontal ? wrapperRect.left : wrapperRect.top\r\n }\r\n\r\n const rect = node.getBoundingClientRect()\r\n\r\n target =\r\n (this.isHorizontal ? rect.left : rect.top) + this.animatedScroll\r\n }\r\n }\r\n\r\n if (typeof target !== 'number') return\r\n\r\n target += offset\r\n target = Math.round(target)\r\n\r\n if (this.options.infinite) {\r\n if (programmatic) {\r\n this.targetScroll = this.animatedScroll = this.scroll\r\n }\r\n } else {\r\n target = clamp(0, target, this.limit)\r\n }\r\n\r\n if (immediate) {\r\n this.animatedScroll = this.targetScroll = target\r\n this.setScroll(this.scroll)\r\n this.reset()\r\n onComplete?.(this)\r\n return\r\n }\r\n\r\n if (target === this.targetScroll) return\r\n\r\n if (!programmatic) {\r\n this.targetScroll = target\r\n }\r\n\r\n this.animate.fromTo(this.animatedScroll, target, {\r\n duration,\r\n easing,\r\n lerp,\r\n onStart: () => {\r\n // started\r\n if (lock) this.isLocked = true\r\n this.isScrolling = 'smooth'\r\n onStart?.(this)\r\n },\r\n onUpdate: (value: number, completed: boolean) => {\r\n this.isScrolling = 'smooth'\r\n\r\n // updated\r\n this.lastVelocity = this.velocity\r\n this.velocity = value - this.animatedScroll\r\n this.direction = Math.sign(this.velocity)\r\n\r\n this.animatedScroll = value\r\n this.setScroll(this.scroll)\r\n\r\n if (programmatic) {\r\n // wheel during programmatic should stop it\r\n this.targetScroll = value\r\n }\r\n\r\n if (!completed) this.emit({ userData })\r\n\r\n if (completed) {\r\n this.reset()\r\n this.emit({ userData })\r\n onComplete?.(this)\r\n\r\n // avoid emitting event twice\r\n this.__preventNextNativeScrollEvent = true\r\n // requestAnimationFrame(() => {\r\n // delete this.__preventNextNativeScrollEvent\r\n // })\r\n }\r\n },\r\n })\r\n }\r\n\r\n get rootElement() {\r\n return this.options.wrapper === window\r\n ? document.documentElement\r\n : this.options.wrapper\r\n }\r\n\r\n get limit() {\r\n if (this.options.__experimental__naiveDimensions) {\r\n if (this.isHorizontal) {\r\n return this.rootElement.scrollWidth - this.rootElement.clientWidth\r\n } else {\r\n return this.rootElement.scrollHeight - this.rootElement.clientHeight\r\n }\r\n } else {\r\n return this.dimensions.limit[this.isHorizontal ? 'x' : 'y']\r\n }\r\n }\r\n\r\n get isHorizontal() {\r\n return this.options.orientation === 'horizontal'\r\n }\r\n\r\n get actualScroll(): number {\r\n // value browser takes into account\r\n return this.isHorizontal\r\n ? this.rootElement.scrollLeft\r\n : this.rootElement.scrollTop\r\n }\r\n\r\n get scroll(): number {\r\n return this.options.infinite\r\n ? modulo(this.animatedScroll, this.limit)\r\n : this.animatedScroll\r\n }\r\n\r\n get progress(): number {\r\n // avoid progress to be NaN\r\n return this.limit === 0 ? 1 : this.scroll / this.limit\r\n }\r\n\r\n // get isSmooth() {\r\n // return this.__isSmooth\r\n // }\r\n\r\n // private set isSmooth(value: boolean) {\r\n // if (this.__isSmooth !== value) {\r\n // this.__isSmooth = value\r\n // this.updateClassName()\r\n // }\r\n // }\r\n\r\n get isScrolling() {\r\n return this.__isScrolling\r\n }\r\n\r\n private set isScrolling(value: boolean) {\r\n if (this.__isScrolling !== value) {\r\n this.__isScrolling = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isStopped() {\r\n return this.__isStopped\r\n }\r\n\r\n private set isStopped(value: boolean) {\r\n if (this.__isStopped !== value) {\r\n this.__isStopped = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isLocked() {\r\n return this.__isLocked\r\n }\r\n\r\n private set isLocked(value: boolean) {\r\n if (this.__isLocked !== value) {\r\n this.__isLocked = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isSmooth() {\r\n return this.isScrolling === 'smooth'\r\n }\r\n\r\n get className() {\r\n let className = 'lenis'\r\n if (this.isStopped) className += ' lenis-stopped'\r\n if (this.isLocked) className += ' lenis-locked'\r\n if (this.isScrolling) className += ' lenis-scrolling'\r\n if (this.isScrolling === 'smooth') className += ' lenis-smooth'\r\n // if (this.isScrolling === 'native') className += ' lenis-native'\r\n // if (this.isSmooth) className += ' lenis-smooth'\r\n return className\r\n }\r\n\r\n private updateClassName() {\r\n this.cleanUpClassName()\r\n\r\n this.rootElement.className =\r\n `${this.rootElement.className} ${this.className}`.trim()\r\n // this.emitter.emit('className change', this)\r\n }\r\n\r\n private cleanUpClassName() {\r\n this.rootElement.className = this.rootElement.className\r\n .replace(/lenis(-\\w+)?/g, '')\r\n .trim()\r\n }\r\n\r\n // private toggleClassName(name: string, value: boolean) {\r\n // // this.rootElement.classList.toggle(name, value)\r\n // this.rootElement.className = this.className\r\n // this.emitter.emit('className change', this)\r\n // }\r\n}\r\n"],"names":["clamp","min","input","max","Math","Animate","advance","deltaTime","this","isRunning","completed","lerp","value","damp","x","y","lambda","dt","t","exp","to","round","currentTime","linearProgress","duration","easedProgress","easing","from","stop","onUpdate","fromTo","onStart","Dimensions","constructor","wrapper","content","autoResize","debounce","debounceValue","debouncedResize","callback","delay","timer","args","arguments","context","clearTimeout","setTimeout","apply","resize","window","addEventListener","wrapperResizeObserver","ResizeObserver","observe","contentResizeObserver","destroy","disconnect","removeEventListener","onWrapperResize","onContentResize","width","innerWidth","height","innerHeight","clientWidth","clientHeight","scrollHeight","scrollWidth","limit","Emitter","events","emit","event","callbacks","i","length","on","cb","push","filter","off","LINE_HEIGHT","VirtualScroll","element","wheelMultiplier","touchMultiplier","touchStart","emitter","onWindowResize","onWheel","passive","onTouchStart","onTouchMove","onTouchEnd","clientX","clientY","targetTouches","lastDelta","deltaX","deltaY","deltaMode","windowWidth","windowHeight","Lenis","document","documentElement","wheelEventsTarget","eventsTarget","smoothWheel","syncTouch","syncTouchLerp","touchInertiaMultiplier","pow","infinite","orientation","gestureOrientation","prevent","__experimental__naiveDimensions","__isScrolling","__isStopped","__isLocked","onVirtualScroll","ctrlKey","isTouch","type","includes","isWheel","isTouching","options","isStopped","isLocked","reset","isClick","isUnknownGesture","composedPath","slice","indexOf","rootElement","find","node","_a","hasAttribute","call","_b","_c","classList","_d","contains","_e","preventDefault","isScrolling","animate","delta","abs","hasTouchInertia","velocity","scrollTo","targetScroll","Object","assign","programmatic","onNativeScroll","__resetVelocityTimeout","__preventNextNativeScrollEvent","lastScroll","animatedScroll","actualScroll","lastVelocity","direction","sign","hasScrolled","lenisVersion","body","dimensions","updateClassName","userData","time","virtualScroll","cleanUpClassName","setScroll","scroll","isHorizontal","scrollLeft","scrollTop","start","raf","target","offset","immediate","lock","onComplete","force","querySelector","nodeType","wrapperRect","getBoundingClientRect","left","top","rect","modulo","n","d","progress","isSmooth","className","trim","replace"],"mappings":"sOACO,SAASA,MAAMC,EAAKC,EAAOC,GAChC,OAAOC,KAAKD,IAAIF,EAAKG,KAAKH,IAAIC,EAAOC,GACvC,CCAO,MAAME,QAEX,OAAAC,CAAQC,GACN,IAAKC,KAAKC,UAAW,OAErB,IAAIC,GAAY,EAEhB,GAAIF,KAAKG,KACPH,KAAKI,MDKJ,SAASC,KAAKC,EAAGC,EAAGC,EAAQC,GACjC,OANK,SAASN,KAAKG,EAAGC,EAAGG,GACzB,OAAQ,EAAIA,GAAKJ,EAAII,EAAIH,CAC3B,CAISJ,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AasD,GAAa,oBACV,WAArBrM,KAAK+I,cAA0BsD,GAAa,iBAGzCA,CACR,CAEO,eAAA9B,GACNvK,KAAK2K,mBAEL3K,KAAKkI,YAAYmE,UACf,GAAGrM,KAAKkI,YAAYmE,aAAarM,KAAKqM,YAAYC,MAErD,CAEO,gBAAA3B,GACN3K,KAAKkI,YAAYmE,UAAYrM,KAAKkI,YAAYmE,UAC3CE,QAAQ,gBAAiB,IACzBD,MACJ"} \ No newline at end of file diff --git a/dist/lenis.mjs b/dist/lenis.mjs index d6430de4..41abc793 100644 --- a/dist/lenis.mjs +++ b/dist/lenis.mjs @@ -1,2 +1,2 @@ -function clamp(t,e,i){return Math.max(t,Math.min(e,i))}class Animate{advance(t){if(!this.isRunning)return;let e=!1;if(this.lerp)this.value=function damp(t,e,i,s){return function lerp(t,e,i){return(1-i)*t+i*e}(t,e,1-Math.exp(-i*s))}(this.value,this.to,60*this.lerp,t),Math.round(this.value)===this.to&&(this.value=this.to,e=!0);else{this.currentTime+=t;const i=clamp(0,this.currentTime/this.duration,1);e=i>=1;const s=e?1:this.easing(i);this.value=this.from+(this.to-this.from)*s}e&&this.stop(),this.onUpdate?.(this.value,e)}stop(){this.isRunning=!1}fromTo(t,e,{lerp:i=.1,duration:s=1,easing:o=(t=>t),onStart:n,onUpdate:r}){this.from=this.value=t,this.to=e,this.lerp=i,this.duration=s,this.easing=o,this.currentTime=0,this.isRunning=!0,n?.(),this.onUpdate=r}}class Dimensions{constructor({wrapper:t,content:e,autoResize:i=!0,debounce:s=250}={}){this.wrapper=t,this.content=e,i&&(this.debouncedResize=function debounce(t,e){let i;return function(){let s=arguments,o=this;clearTimeout(i),i=setTimeout((function(){t.apply(o,s)}),e)}}(this.resize,s),this.wrapper===window?window.addEventListener("resize",this.debouncedResize,!1):(this.wrapperResizeObserver=new ResizeObserver(this.debouncedResize),this.wrapperResizeObserver.observe(this.wrapper)),this.contentResizeObserver=new ResizeObserver(this.debouncedResize),this.contentResizeObserver.observe(this.content)),this.resize()}destroy(){this.wrapperResizeObserver?.disconnect(),this.contentResizeObserver?.disconnect(),window.removeEventListener("resize",this.debouncedResize,!1)}resize=()=>{this.onWrapperResize(),this.onContentResize()};onWrapperResize=()=>{this.wrapper===window?(this.width=window.innerWidth,this.height=window.innerHeight):(this.width=this.wrapper.clientWidth,this.height=this.wrapper.clientHeight)};onContentResize=()=>{this.wrapper===window?(this.scrollHeight=this.content.scrollHeight,this.scrollWidth=this.content.scrollWidth):(this.scrollHeight=this.wrapper.scrollHeight,this.scrollWidth=this.wrapper.scrollWidth)};get limit(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}}class Emitter{constructor(){this.events={}}emit(t,...e){let i=this.events[t]||[];for(let t=0,s=i.length;t{this.events[t]=this.events[t]?.filter((t=>e!==t))}}off(t,e){this.events[t]=this.events[t]?.filter((t=>e!==t))}destroy(){this.events={}}}const t=100/6;class VirtualScroll{constructor(t,{wheelMultiplier:e=1,touchMultiplier:i=1}){this.element=t,this.wheelMultiplier=e,this.touchMultiplier=i,this.touchStart={x:null,y:null},this.emitter=new Emitter,window.addEventListener("resize",this.onWindowResize,!1),this.onWindowResize(),this.element.addEventListener("wheel",this.onWheel,{passive:!1}),this.element.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.element.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.element.addEventListener("touchend",this.onTouchEnd,{passive:!1})}on(t,e){return this.emitter.on(t,e)}destroy(){this.emitter.destroy(),window.removeEventListener("resize",this.onWindowResize,!1),this.element.removeEventListener("wheel",this.onWheel,{passive:!1}),this.element.removeEventListener("touchstart",this.onTouchStart,{passive:!1}),this.element.removeEventListener("touchmove",this.onTouchMove,{passive:!1}),this.element.removeEventListener("touchend",this.onTouchEnd,{passive:!1})}onTouchStart=t=>{const{clientX:e,clientY:i}=t.targetTouches?t.targetTouches[0]:t;this.touchStart.x=e,this.touchStart.y=i,this.lastDelta={x:0,y:0},this.emitter.emit("scroll",{deltaX:0,deltaY:0,event:t})};onTouchMove=t=>{const{clientX:e,clientY:i}=t.targetTouches?t.targetTouches[0]:t,s=-(e-this.touchStart.x)*this.touchMultiplier,o=-(i-this.touchStart.y)*this.touchMultiplier;this.touchStart.x=e,this.touchStart.y=i,this.lastDelta={x:s,y:o},this.emitter.emit("scroll",{deltaX:s,deltaY:o,event:t})};onTouchEnd=t=>{this.emitter.emit("scroll",{deltaX:this.lastDelta.x,deltaY:this.lastDelta.y,event:t})};onWheel=e=>{let{deltaX:i,deltaY:s,deltaMode:o}=e;i*=1===o?t:2===o?this.windowWidth:1,s*=1===o?t:2===o?this.windowHeight:1,i*=this.wheelMultiplier,s*=this.wheelMultiplier,this.emitter.emit("scroll",{deltaX:i,deltaY:s,event:e})};onWindowResize=()=>{this.windowWidth=window.innerWidth,this.windowHeight=window.innerHeight}}class Lenis{constructor({wrapper:t=window,content:e=document.documentElement,wheelEventsTarget:i=t,eventsTarget:s=i,smoothWheel:o=!0,syncTouch:n=!1,syncTouchLerp:r=.075,touchInertiaMultiplier:l=35,duration:h,easing:a=(t=>Math.min(1,1.001-Math.pow(2,-10*t))),lerp:c=!h&&.1,infinite:u=!1,orientation:d="vertical",gestureOrientation:p="vertical",touchMultiplier:m=1,wheelMultiplier:v=1,autoResize:g=!0,prevent:S=!1,__experimental__naiveDimensions:w=!1}={}){this.__isScrolling=!1,this.__isStopped=!1,this.__isLocked=!1,this.onVirtualScroll=({deltaX:t,deltaY:e,event:i})=>{if(i.ctrlKey)return;const s=i.type.includes("touch"),o=i.type.includes("wheel");this.isTouching="touchstart"===i.type||"touchmove"===i.type;if(this.options.syncTouch&&s&&"touchstart"===i.type&&!this.isStopped&&!this.isLocked)return void this.reset();const n=0===t&&0===e,r="vertical"===this.options.gestureOrientation&&0===e||"horizontal"===this.options.gestureOrientation&&0===t;if(n||r)return;let l=i.composedPath();if(l=l.slice(0,l.indexOf(this.rootElement)),l.find((t=>{var e,i,n,r,l;return this.options.prevent(t)||(null===(e=t.hasAttribute)||void 0===e?void 0:e.call(t,"data-lenis-prevent"))||s&&(null===(i=t.hasAttribute)||void 0===i?void 0:i.call(t,"data-lenis-prevent-touch"))||o&&(null===(n=t.hasAttribute)||void 0===n?void 0:n.call(t,"data-lenis-prevent-wheel"))||(null===(r=t.classList)||void 0===r?void 0:r.contains("lenis"))&&!(null===(l=t.classList)||void 0===l?void 0:l.contains("lenis-stopped"))})))return;if(this.isStopped||this.isLocked)return void i.preventDefault();if(!(this.options.syncTouch&&s||this.options.smoothWheel&&o))return this.isScrolling="native",void this.animate.stop();i.preventDefault();let h=e;"both"===this.options.gestureOrientation?h=Math.abs(e)>Math.abs(t)?e:t:"horizontal"===this.options.gestureOrientation&&(h=t);const a=s&&this.options.syncTouch,c=s&&"touchend"===i.type&&Math.abs(h)>5;c&&(h=this.velocity*this.options.touchInertiaMultiplier),this.scrollTo(this.targetScroll+h,Object.assign({programmatic:!1},a?{lerp:c?this.options.syncTouchLerp:1}:{lerp:this.options.lerp,duration:this.options.duration,easing:this.options.easing}))},this.onNativeScroll=()=>{if(clearTimeout(this.__resetVelocityTimeout),delete this.__resetVelocityTimeout,this.__preventNextNativeScrollEvent)delete this.__preventNextNativeScrollEvent;else if(!1===this.isScrolling||"native"===this.isScrolling){const t=this.animatedScroll;this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity,this.velocity=this.animatedScroll-t,this.direction=Math.sign(this.animatedScroll-t),this.isScrolling=!!this.hasScrolled&&"native",this.emit(),0!==this.velocity&&(this.__resetVelocityTimeout=setTimeout((()=>{this.lastVelocity=this.velocity,this.velocity=0,this.isScrolling=!1,this.emit()}),400))}},window.lenisVersion="1.1.0",t!==document.documentElement&&t!==document.body||(t=window),this.options={wrapper:t,content:e,wheelEventsTarget:i,eventsTarget:s,smoothWheel:o,syncTouch:n,syncTouchLerp:r,touchInertiaMultiplier:l,duration:h,easing:a,lerp:c,infinite:u,gestureOrientation:p,orientation:d,touchMultiplier:m,wheelMultiplier:v,autoResize:g,prevent:S,__experimental__naiveDimensions:w},this.animate=new Animate,this.emitter=new Emitter,this.dimensions=new Dimensions({wrapper:t,content:e,autoResize:g}),this.updateClassName(),this.userData={},this.time=0,this.velocity=this.lastVelocity=0,this.isLocked=!1,this.isStopped=!1,this.isScrolling=!1,this.targetScroll=this.animatedScroll=this.actualScroll,this.options.wrapper.addEventListener("scroll",this.onNativeScroll,!1),this.virtualScroll=new VirtualScroll(s,{touchMultiplier:m,wheelMultiplier:v}),this.virtualScroll.on("scroll",this.onVirtualScroll)}destroy(){this.emitter.destroy(),this.options.wrapper.removeEventListener("scroll",this.onNativeScroll,!1),this.virtualScroll.destroy(),this.dimensions.destroy(),this.cleanUpClassName()}on(t,e){return this.emitter.on(t,e)}off(t,e){return this.emitter.off(t,e)}setScroll(t){this.isHorizontal?this.rootElement.scrollLeft=t:this.rootElement.scrollTop=t}resize(){this.dimensions.resize()}emit({userData:t={}}={}){this.userData=t,this.emitter.emit("scroll",this),this.userData={}}reset(){this.isLocked=!1,this.isScrolling=!1,this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity=0,this.animate.stop()}start(){this.isStopped&&(this.isStopped=!1,this.reset())}stop(){this.isStopped||(this.isStopped=!0,this.animate.stop(),this.reset())}raf(t){const e=t-(this.time||t);this.time=t,this.animate.advance(.001*e)}scrollTo(t,{offset:e=0,immediate:i=!1,lock:s=!1,duration:o=this.options.duration,easing:n=this.options.easing,lerp:r=!o&&this.options.lerp,onStart:l,onComplete:h,force:a=!1,programmatic:c=!0,userData:u={}}={}){if(!this.isStopped&&!this.isLocked||a){if(["top","left","start"].includes(t))t=0;else if(["bottom","right","end"].includes(t))t=this.limit;else{let i;if("string"==typeof t?i=document.querySelector(t):(null==t?void 0:t.nodeType)&&(i=t),i){if(this.options.wrapper!==window){const t=this.options.wrapper.getBoundingClientRect();e-=this.isHorizontal?t.left:t.top}const s=i.getBoundingClientRect();t=(this.isHorizontal?s.left:s.top)+this.animatedScroll}}if("number"==typeof t){if(t+=e,t=Math.round(t),this.options.infinite?c&&(this.targetScroll=this.animatedScroll=this.scroll):t=clamp(0,t,this.limit),i)return this.animatedScroll=this.targetScroll=t,this.setScroll(this.scroll),this.reset(),void(null==h||h(this));t!==this.targetScroll&&(c||(this.targetScroll=t),this.animate.fromTo(this.animatedScroll,t,{duration:o,easing:n,lerp:r,onStart:()=>{s&&(this.isLocked=!0),this.isScrolling="smooth",null==l||l(this)},onUpdate:(t,e)=>{this.isScrolling="smooth",this.lastVelocity=this.velocity,this.velocity=t-this.animatedScroll,this.direction=Math.sign(this.velocity),this.animatedScroll=t,this.setScroll(this.scroll),c&&(this.targetScroll=t),e||this.emit({userData:u}),e&&(this.reset(),this.emit({userData:u}),null==h||h(this),this.__preventNextNativeScrollEvent=!0)}}))}}}get rootElement(){return this.options.wrapper===window?document.documentElement:this.options.wrapper}get limit(){return this.options.__experimental__naiveDimensions?this.isHorizontal?this.rootElement.scrollWidth-this.rootElement.clientWidth:this.rootElement.scrollHeight-this.rootElement.clientHeight:this.dimensions.limit[this.isHorizontal?"x":"y"]}get isHorizontal(){return"horizontal"===this.options.orientation}get actualScroll(){return this.isHorizontal?this.rootElement.scrollLeft:this.rootElement.scrollTop}get scroll(){return this.options.infinite?function modulo(t,e){return(t%e+e)%e}(this.animatedScroll,this.limit):this.animatedScroll}get progress(){return 0===this.limit?1:this.scroll/this.limit}get isScrolling(){return this.__isScrolling}set isScrolling(t){this.__isScrolling!==t&&(this.__isScrolling=t,this.updateClassName())}get isStopped(){return this.__isStopped}set isStopped(t){this.__isStopped!==t&&(this.__isStopped=t,this.updateClassName())}get isLocked(){return this.__isLocked}set isLocked(t){this.__isLocked!==t&&(this.__isLocked=t,this.updateClassName())}get isSmooth(){return"smooth"===this.isScrolling}get className(){let t="lenis";return this.isStopped&&(t+=" lenis-stopped"),this.isLocked&&(t+=" lenis-locked"),this.isScrolling&&(t+=" lenis-scrolling"),"smooth"===this.isScrolling&&(t+=" lenis-smooth"),t}updateClassName(){this.cleanUpClassName(),this.rootElement.className=`${this.rootElement.className} ${this.className}`.trim()}cleanUpClassName(){this.rootElement.className=this.rootElement.className.replace(/lenis(-\w+)?/g,"").trim()}}export{Lenis as default}; +function clamp(t,e,i){return Math.max(t,Math.min(e,i))}class Animate{advance(t){if(!this.isRunning)return;let e=!1;if(this.lerp)this.value=function damp(t,e,i,s){return function lerp(t,e,i){return(1-i)*t+i*e}(t,e,1-Math.exp(-i*s))}(this.value,this.to,60*this.lerp,t),Math.round(this.value)===this.to&&(this.value=this.to,e=!0);else{this.currentTime+=t;const i=clamp(0,this.currentTime/this.duration,1);e=i>=1;const s=e?1:this.easing(i);this.value=this.from+(this.to-this.from)*s}e&&this.stop(),this.onUpdate?.(this.value,e)}stop(){this.isRunning=!1}fromTo(t,e,{lerp:i=.1,duration:s=1,easing:o=(t=>t),onStart:n,onUpdate:r}){this.from=this.value=t,this.to=e,this.lerp=i,this.duration=s,this.easing=o,this.currentTime=0,this.isRunning=!0,n?.(),this.onUpdate=r}}class Dimensions{constructor({wrapper:t,content:e,autoResize:i=!0,debounce:s=250}={}){this.wrapper=t,this.content=e,i&&(this.debouncedResize=function debounce(t,e){let i;return function(){let s=arguments,o=this;clearTimeout(i),i=setTimeout((function(){t.apply(o,s)}),e)}}(this.resize,s),this.wrapper===window?window.addEventListener("resize",this.debouncedResize,!1):(this.wrapperResizeObserver=new ResizeObserver(this.debouncedResize),this.wrapperResizeObserver.observe(this.wrapper)),this.contentResizeObserver=new ResizeObserver(this.debouncedResize),this.contentResizeObserver.observe(this.content)),this.resize()}destroy(){this.wrapperResizeObserver?.disconnect(),this.contentResizeObserver?.disconnect(),window.removeEventListener("resize",this.debouncedResize,!1)}resize=()=>{this.onWrapperResize(),this.onContentResize()};onWrapperResize=()=>{this.wrapper===window?(this.width=window.innerWidth,this.height=window.innerHeight):(this.width=this.wrapper.clientWidth,this.height=this.wrapper.clientHeight)};onContentResize=()=>{this.wrapper===window?(this.scrollHeight=this.content.scrollHeight,this.scrollWidth=this.content.scrollWidth):(this.scrollHeight=this.wrapper.scrollHeight,this.scrollWidth=this.wrapper.scrollWidth)};get limit(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}}class Emitter{constructor(){this.events={}}emit(t,...e){let i=this.events[t]||[];for(let t=0,s=i.length;t{this.events[t]=this.events[t]?.filter((t=>e!==t))}}off(t,e){this.events[t]=this.events[t]?.filter((t=>e!==t))}destroy(){this.events={}}}const t=100/6;class VirtualScroll{constructor(t,{wheelMultiplier:e=1,touchMultiplier:i=1}){this.element=t,this.wheelMultiplier=e,this.touchMultiplier=i,this.touchStart={x:null,y:null},this.emitter=new Emitter,window.addEventListener("resize",this.onWindowResize,!1),this.onWindowResize(),this.element.addEventListener("wheel",this.onWheel,{passive:!1}),this.element.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.element.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.element.addEventListener("touchend",this.onTouchEnd,{passive:!1})}on(t,e){return this.emitter.on(t,e)}destroy(){this.emitter.destroy(),window.removeEventListener("resize",this.onWindowResize,!1),this.element.removeEventListener("wheel",this.onWheel,{passive:!1}),this.element.removeEventListener("touchstart",this.onTouchStart,{passive:!1}),this.element.removeEventListener("touchmove",this.onTouchMove,{passive:!1}),this.element.removeEventListener("touchend",this.onTouchEnd,{passive:!1})}onTouchStart=t=>{const{clientX:e,clientY:i}=t.targetTouches?t.targetTouches[0]:t;this.touchStart.x=e,this.touchStart.y=i,this.lastDelta={x:0,y:0},this.emitter.emit("scroll",{deltaX:0,deltaY:0,event:t})};onTouchMove=t=>{const{clientX:e,clientY:i}=t.targetTouches?t.targetTouches[0]:t,s=-(e-this.touchStart.x)*this.touchMultiplier,o=-(i-this.touchStart.y)*this.touchMultiplier;this.touchStart.x=e,this.touchStart.y=i,this.lastDelta={x:s,y:o},this.emitter.emit("scroll",{deltaX:s,deltaY:o,event:t})};onTouchEnd=t=>{this.emitter.emit("scroll",{deltaX:this.lastDelta.x,deltaY:this.lastDelta.y,event:t})};onWheel=e=>{let{deltaX:i,deltaY:s,deltaMode:o}=e;i*=1===o?t:2===o?this.windowWidth:1,s*=1===o?t:2===o?this.windowHeight:1,i*=this.wheelMultiplier,s*=this.wheelMultiplier,this.emitter.emit("scroll",{deltaX:i,deltaY:s,event:e})};onWindowResize=()=>{this.windowWidth=window.innerWidth,this.windowHeight=window.innerHeight}}class Lenis{constructor({wrapper:t=window,content:e=document.documentElement,wheelEventsTarget:i=t,eventsTarget:s=i,smoothWheel:o=!0,syncTouch:n=!1,syncTouchLerp:r=.075,touchInertiaMultiplier:l=35,duration:h,easing:a=(t=>Math.min(1,1.001-Math.pow(2,-10*t))),lerp:c=!h&&.1,infinite:u=!1,orientation:d="vertical",gestureOrientation:p="vertical",touchMultiplier:m=1,wheelMultiplier:v=1,autoResize:g=!0,prevent:S=!1,__experimental__naiveDimensions:w=!1}={}){this.__isScrolling=!1,this.__isStopped=!1,this.__isLocked=!1,this.onVirtualScroll=({deltaX:t,deltaY:e,event:i})=>{if(i.ctrlKey)return;const s=i.type.includes("touch"),o=i.type.includes("wheel");this.isTouching="touchstart"===i.type||"touchmove"===i.type;if(this.options.syncTouch&&s&&"touchstart"===i.type&&!this.isStopped&&!this.isLocked)return void this.reset();const n=0===t&&0===e,r="vertical"===this.options.gestureOrientation&&0===e||"horizontal"===this.options.gestureOrientation&&0===t;if(n||r)return;let l=i.composedPath();l=l.slice(0,l.indexOf(this.rootElement));const h=this.options.prevent;if(l.find((t=>{var e,i,n,r,l;return("function"==typeof h?null==h?void 0:h(t):h)||(null===(e=t.hasAttribute)||void 0===e?void 0:e.call(t,"data-lenis-prevent"))||s&&(null===(i=t.hasAttribute)||void 0===i?void 0:i.call(t,"data-lenis-prevent-touch"))||o&&(null===(n=t.hasAttribute)||void 0===n?void 0:n.call(t,"data-lenis-prevent-wheel"))||(null===(r=t.classList)||void 0===r?void 0:r.contains("lenis"))&&!(null===(l=t.classList)||void 0===l?void 0:l.contains("lenis-stopped"))})))return;if(this.isStopped||this.isLocked)return void i.preventDefault();if(!(this.options.syncTouch&&s||this.options.smoothWheel&&o))return this.isScrolling="native",void this.animate.stop();i.preventDefault();let a=e;"both"===this.options.gestureOrientation?a=Math.abs(e)>Math.abs(t)?e:t:"horizontal"===this.options.gestureOrientation&&(a=t);const c=s&&this.options.syncTouch,u=s&&"touchend"===i.type&&Math.abs(a)>5;u&&(a=this.velocity*this.options.touchInertiaMultiplier),this.scrollTo(this.targetScroll+a,Object.assign({programmatic:!1},c?{lerp:u?this.options.syncTouchLerp:1}:{lerp:this.options.lerp,duration:this.options.duration,easing:this.options.easing}))},this.onNativeScroll=()=>{if(clearTimeout(this.__resetVelocityTimeout),delete this.__resetVelocityTimeout,this.__preventNextNativeScrollEvent)delete this.__preventNextNativeScrollEvent;else if(!1===this.isScrolling||"native"===this.isScrolling){const t=this.animatedScroll;this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity,this.velocity=this.animatedScroll-t,this.direction=Math.sign(this.animatedScroll-t),this.isScrolling=!!this.hasScrolled&&"native",this.emit(),0!==this.velocity&&(this.__resetVelocityTimeout=setTimeout((()=>{this.lastVelocity=this.velocity,this.velocity=0,this.isScrolling=!1,this.emit()}),400))}},window.lenisVersion="1.1.1",t!==document.documentElement&&t!==document.body||(t=window),this.options={wrapper:t,content:e,wheelEventsTarget:i,eventsTarget:s,smoothWheel:o,syncTouch:n,syncTouchLerp:r,touchInertiaMultiplier:l,duration:h,easing:a,lerp:c,infinite:u,gestureOrientation:p,orientation:d,touchMultiplier:m,wheelMultiplier:v,autoResize:g,prevent:S,__experimental__naiveDimensions:w},this.animate=new Animate,this.emitter=new Emitter,this.dimensions=new Dimensions({wrapper:t,content:e,autoResize:g}),this.updateClassName(),this.userData={},this.time=0,this.velocity=this.lastVelocity=0,this.isLocked=!1,this.isStopped=!1,this.isScrolling=!1,this.targetScroll=this.animatedScroll=this.actualScroll,this.options.wrapper.addEventListener("scroll",this.onNativeScroll,!1),this.virtualScroll=new VirtualScroll(s,{touchMultiplier:m,wheelMultiplier:v}),this.virtualScroll.on("scroll",this.onVirtualScroll)}destroy(){this.emitter.destroy(),this.options.wrapper.removeEventListener("scroll",this.onNativeScroll,!1),this.virtualScroll.destroy(),this.dimensions.destroy(),this.cleanUpClassName()}on(t,e){return this.emitter.on(t,e)}off(t,e){return this.emitter.off(t,e)}setScroll(t){this.isHorizontal?this.rootElement.scrollLeft=t:this.rootElement.scrollTop=t}resize(){this.dimensions.resize()}emit({userData:t={}}={}){this.userData=t,this.emitter.emit("scroll",this),this.userData={}}reset(){this.isLocked=!1,this.isScrolling=!1,this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity=0,this.animate.stop()}start(){this.isStopped&&(this.isStopped=!1,this.reset())}stop(){this.isStopped||(this.isStopped=!0,this.animate.stop(),this.reset())}raf(t){const e=t-(this.time||t);this.time=t,this.animate.advance(.001*e)}scrollTo(t,{offset:e=0,immediate:i=!1,lock:s=!1,duration:o=this.options.duration,easing:n=this.options.easing,lerp:r=!o&&this.options.lerp,onStart:l,onComplete:h,force:a=!1,programmatic:c=!0,userData:u={}}={}){if(!this.isStopped&&!this.isLocked||a){if(["top","left","start"].includes(t))t=0;else if(["bottom","right","end"].includes(t))t=this.limit;else{let i;if("string"==typeof t?i=document.querySelector(t):(null==t?void 0:t.nodeType)&&(i=t),i){if(this.options.wrapper!==window){const t=this.options.wrapper.getBoundingClientRect();e-=this.isHorizontal?t.left:t.top}const s=i.getBoundingClientRect();t=(this.isHorizontal?s.left:s.top)+this.animatedScroll}}if("number"==typeof t){if(t+=e,t=Math.round(t),this.options.infinite?c&&(this.targetScroll=this.animatedScroll=this.scroll):t=clamp(0,t,this.limit),i)return this.animatedScroll=this.targetScroll=t,this.setScroll(this.scroll),this.reset(),void(null==h||h(this));t!==this.targetScroll&&(c||(this.targetScroll=t),this.animate.fromTo(this.animatedScroll,t,{duration:o,easing:n,lerp:r,onStart:()=>{s&&(this.isLocked=!0),this.isScrolling="smooth",null==l||l(this)},onUpdate:(t,e)=>{this.isScrolling="smooth",this.lastVelocity=this.velocity,this.velocity=t-this.animatedScroll,this.direction=Math.sign(this.velocity),this.animatedScroll=t,this.setScroll(this.scroll),c&&(this.targetScroll=t),e||this.emit({userData:u}),e&&(this.reset(),this.emit({userData:u}),null==h||h(this),this.__preventNextNativeScrollEvent=!0)}}))}}}get rootElement(){return this.options.wrapper===window?document.documentElement:this.options.wrapper}get limit(){return this.options.__experimental__naiveDimensions?this.isHorizontal?this.rootElement.scrollWidth-this.rootElement.clientWidth:this.rootElement.scrollHeight-this.rootElement.clientHeight:this.dimensions.limit[this.isHorizontal?"x":"y"]}get isHorizontal(){return"horizontal"===this.options.orientation}get actualScroll(){return this.isHorizontal?this.rootElement.scrollLeft:this.rootElement.scrollTop}get scroll(){return this.options.infinite?function modulo(t,e){return(t%e+e)%e}(this.animatedScroll,this.limit):this.animatedScroll}get progress(){return 0===this.limit?1:this.scroll/this.limit}get isScrolling(){return this.__isScrolling}set isScrolling(t){this.__isScrolling!==t&&(this.__isScrolling=t,this.updateClassName())}get isStopped(){return this.__isStopped}set isStopped(t){this.__isStopped!==t&&(this.__isStopped=t,this.updateClassName())}get isLocked(){return this.__isLocked}set isLocked(t){this.__isLocked!==t&&(this.__isLocked=t,this.updateClassName())}get isSmooth(){return"smooth"===this.isScrolling}get className(){let t="lenis";return this.isStopped&&(t+=" lenis-stopped"),this.isLocked&&(t+=" lenis-locked"),this.isScrolling&&(t+=" lenis-scrolling"),"smooth"===this.isScrolling&&(t+=" lenis-smooth"),t}updateClassName(){this.cleanUpClassName(),this.rootElement.className=`${this.rootElement.className} ${this.className}`.trim()}cleanUpClassName(){this.rootElement.className=this.rootElement.className.replace(/lenis(-\w+)?/g,"").trim()}}export{Lenis as default}; //# sourceMappingURL=lenis.mjs.map diff --git a/dist/lenis.mjs.map b/dist/lenis.mjs.map index fedf6fd9..92e834cb 100644 --- a/dist/lenis.mjs.map +++ b/dist/lenis.mjs.map @@ -1 +1 @@ -{"version":3,"file":"lenis.mjs","sources":["../src/maths.js","../src/animate.js","../src/dimensions.js","../src/debounce.js","../src/emitter.js","../src/virtual-scroll.js","../src/index.ts"],"sourcesContent":["// Clamp a value between a minimum and maximum value\r\nexport function clamp(min, input, max) {\r\n return Math.max(min, Math.min(input, max))\r\n}\r\n\r\n// Truncate a floating-point number to a specified number of decimal places\r\nexport function truncate(value, decimals = 0) {\r\n return parseFloat(value.toFixed(decimals))\r\n}\r\n\r\n// Linearly interpolate between two values using an amount (0 <= t <= 1)\r\nexport function lerp(x, y, t) {\r\n return (1 - t) * x + t * y\r\n}\r\n\r\n// http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/\r\nexport function damp(x, y, lambda, dt) {\r\n return lerp(x, y, 1 - Math.exp(-lambda * dt))\r\n}\r\n\r\n// Calculate the modulo of the dividend and divisor while keeping the result within the same sign as the divisor\r\n// https://anguscroll.com/just/just-modulo\r\nexport function modulo(n, d) {\r\n return ((n % d) + d) % d\r\n}\r\n","import { clamp, damp } from './maths'\r\n\r\n// Animate class to handle value animations with lerping or easing\r\nexport class Animate {\r\n // Advance the animation by the given delta time\r\n advance(deltaTime) {\r\n if (!this.isRunning) return\r\n\r\n let completed = false\r\n\r\n if (this.lerp) {\r\n this.value = damp(this.value, this.to, this.lerp * 60, deltaTime)\r\n if (Math.round(this.value) === this.to) {\r\n this.value = this.to\r\n completed = true\r\n }\r\n } else {\r\n this.currentTime += deltaTime\r\n const linearProgress = clamp(0, this.currentTime / this.duration, 1)\r\n\r\n completed = linearProgress >= 1\r\n const easedProgress = completed ? 1 : this.easing(linearProgress)\r\n this.value = this.from + (this.to - this.from) * easedProgress\r\n }\r\n\r\n if (completed) {\r\n this.stop()\r\n }\r\n\r\n // Call the onUpdate callback with the current value and completed status\r\n this.onUpdate?.(this.value, completed)\r\n }\r\n\r\n // Stop the animation\r\n stop() {\r\n this.isRunning = false\r\n }\r\n\r\n // Set up the animation from a starting value to an ending value\r\n // with optional parameters for lerping, duration, easing, and onUpdate callback\r\n fromTo(\r\n from,\r\n to,\r\n { lerp = 0.1, duration = 1, easing = (t) => t, onStart, onUpdate }\r\n ) {\r\n this.from = this.value = from\r\n this.to = to\r\n this.lerp = lerp\r\n this.duration = duration\r\n this.easing = easing\r\n this.currentTime = 0\r\n this.isRunning = true\r\n\r\n onStart?.()\r\n this.onUpdate = onUpdate\r\n }\r\n}\r\n","import { debounce } from './debounce'\r\n\r\nexport class Dimensions {\r\n constructor({\r\n wrapper,\r\n content,\r\n autoResize = true,\r\n debounce: debounceValue = 250,\r\n } = {}) {\r\n this.wrapper = wrapper\r\n this.content = content\r\n\r\n if (autoResize) {\r\n this.debouncedResize = debounce(this.resize, debounceValue)\r\n\r\n if (this.wrapper === window) {\r\n window.addEventListener('resize', this.debouncedResize, false)\r\n } else {\r\n this.wrapperResizeObserver = new ResizeObserver(this.debouncedResize)\r\n this.wrapperResizeObserver.observe(this.wrapper)\r\n }\r\n\r\n this.contentResizeObserver = new ResizeObserver(this.debouncedResize)\r\n this.contentResizeObserver.observe(this.content)\r\n }\r\n\r\n this.resize()\r\n }\r\n\r\n destroy() {\r\n this.wrapperResizeObserver?.disconnect()\r\n this.contentResizeObserver?.disconnect()\r\n window.removeEventListener('resize', this.debouncedResize, false)\r\n }\r\n\r\n resize = () => {\r\n this.onWrapperResize()\r\n this.onContentResize()\r\n }\r\n\r\n onWrapperResize = () => {\r\n if (this.wrapper === window) {\r\n this.width = window.innerWidth\r\n this.height = window.innerHeight\r\n } else {\r\n this.width = this.wrapper.clientWidth\r\n this.height = this.wrapper.clientHeight\r\n }\r\n }\r\n\r\n onContentResize = () => {\r\n if (this.wrapper === window) {\r\n this.scrollHeight = this.content.scrollHeight\r\n this.scrollWidth = this.content.scrollWidth\r\n } else {\r\n this.scrollHeight = this.wrapper.scrollHeight\r\n this.scrollWidth = this.wrapper.scrollWidth\r\n }\r\n }\r\n\r\n get limit() {\r\n return {\r\n x: this.scrollWidth - this.width,\r\n y: this.scrollHeight - this.height,\r\n }\r\n }\r\n}\r\n","export function debounce(callback, delay) {\r\n let timer\r\n return function () {\r\n let args = arguments\r\n let context = this\r\n clearTimeout(timer)\r\n timer = setTimeout(function () {\r\n callback.apply(context, args)\r\n }, delay)\r\n }\r\n}\r\n","export class Emitter {\r\n constructor() {\r\n this.events = {}\r\n }\r\n\r\n emit(event, ...args) {\r\n let callbacks = this.events[event] || []\r\n for (let i = 0, length = callbacks.length; i < length; i++) {\r\n callbacks[i](...args)\r\n }\r\n }\r\n\r\n on(event, cb) {\r\n // Add the callback to the event's callback list, or create a new list with the callback\r\n this.events[event]?.push(cb) || (this.events[event] = [cb])\r\n\r\n // Return an unsubscribe function\r\n return () => {\r\n this.events[event] = this.events[event]?.filter((i) => cb !== i)\r\n }\r\n }\r\n\r\n off(event, callback) {\r\n this.events[event] = this.events[event]?.filter((i) => callback !== i)\r\n }\r\n\r\n destroy() {\r\n this.events = {}\r\n }\r\n}\r\n","import { Emitter } from './emitter'\r\n\r\nconst LINE_HEIGHT = 100 / 6\r\n\r\nexport class VirtualScroll {\r\n constructor(element, { wheelMultiplier = 1, touchMultiplier = 1 }) {\r\n this.element = element\r\n this.wheelMultiplier = wheelMultiplier\r\n this.touchMultiplier = touchMultiplier\r\n\r\n this.touchStart = {\r\n x: null,\r\n y: null,\r\n }\r\n\r\n this.emitter = new Emitter()\r\n window.addEventListener('resize', this.onWindowResize, false)\r\n this.onWindowResize()\r\n\r\n this.element.addEventListener('wheel', this.onWheel, { passive: false })\r\n this.element.addEventListener('touchstart', this.onTouchStart, {\r\n passive: false,\r\n })\r\n this.element.addEventListener('touchmove', this.onTouchMove, {\r\n passive: false,\r\n })\r\n this.element.addEventListener('touchend', this.onTouchEnd, {\r\n passive: false,\r\n })\r\n }\r\n\r\n // Add an event listener for the given event and callback\r\n on(event, callback) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n // Remove all event listeners and clean up\r\n destroy() {\r\n this.emitter.destroy()\r\n\r\n window.removeEventListener('resize', this.onWindowResize, false)\r\n\r\n this.element.removeEventListener('wheel', this.onWheel, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchstart', this.onTouchStart, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchmove', this.onTouchMove, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchend', this.onTouchEnd, {\r\n passive: false,\r\n })\r\n }\r\n\r\n // Event handler for 'touchstart' event\r\n onTouchStart = (event) => {\r\n const { clientX, clientY } = event.targetTouches\r\n ? event.targetTouches[0]\r\n : event\r\n\r\n this.touchStart.x = clientX\r\n this.touchStart.y = clientY\r\n\r\n this.lastDelta = {\r\n x: 0,\r\n y: 0,\r\n }\r\n\r\n this.emitter.emit('scroll', {\r\n deltaX: 0,\r\n deltaY: 0,\r\n event,\r\n })\r\n }\r\n\r\n // Event handler for 'touchmove' event\r\n onTouchMove = (event) => {\r\n const { clientX, clientY } = event.targetTouches\r\n ? event.targetTouches[0]\r\n : event\r\n\r\n const deltaX = -(clientX - this.touchStart.x) * this.touchMultiplier\r\n const deltaY = -(clientY - this.touchStart.y) * this.touchMultiplier\r\n\r\n this.touchStart.x = clientX\r\n this.touchStart.y = clientY\r\n\r\n this.lastDelta = {\r\n x: deltaX,\r\n y: deltaY,\r\n }\r\n\r\n this.emitter.emit('scroll', {\r\n deltaX,\r\n deltaY,\r\n event,\r\n })\r\n }\r\n\r\n onTouchEnd = (event) => {\r\n this.emitter.emit('scroll', {\r\n deltaX: this.lastDelta.x,\r\n deltaY: this.lastDelta.y,\r\n event,\r\n })\r\n }\r\n\r\n // Event handler for 'wheel' event\r\n onWheel = (event) => {\r\n let { deltaX, deltaY, deltaMode } = event\r\n\r\n const multiplierX =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.windowWidth : 1\r\n const multiplierY =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.windowHeight : 1\r\n\r\n deltaX *= multiplierX\r\n deltaY *= multiplierY\r\n\r\n deltaX *= this.wheelMultiplier\r\n deltaY *= this.wheelMultiplier\r\n\r\n this.emitter.emit('scroll', { deltaX, deltaY, event })\r\n }\r\n\r\n onWindowResize = () => {\r\n this.windowWidth = window.innerWidth\r\n this.windowHeight = window.innerHeight\r\n }\r\n}\r\n","import { version } from '../../../package.json'\r\nimport { Animate } from './animate'\r\nimport { Dimensions } from './dimensions'\r\nimport { Emitter } from './emitter'\r\nimport { clamp, modulo } from './maths'\r\nimport { VirtualScroll } from './virtual-scroll'\r\n\r\n// Technical explanation\r\n// - listen to 'wheel' events\r\n// - prevent 'wheel' event to prevent scroll\r\n// - normalize wheel delta\r\n// - add delta to targetScroll\r\n// - animate scroll to targetScroll (smooth context)\r\n// - if animation is not running, listen to 'scroll' events (native context)\r\n\r\ntype EasingFunction = (t: number) => number\r\ntype Orientation = 'vertical' | 'horizontal'\r\ntype GestureOrientation = 'vertical' | 'horizontal' | 'both'\r\n\r\nexport type LenisOptions = {\r\n wrapper?: Window | HTMLElement\r\n content?: HTMLElement\r\n wheelEventsTarget?: Window | HTMLElement\r\n eventsTarget?: Window | HTMLElement\r\n smoothWheel?: boolean\r\n syncTouch?: boolean\r\n syncTouchLerp?: number\r\n touchInertiaMultiplier?: number\r\n duration?: number\r\n easing?: EasingFunction\r\n lerp?: number\r\n infinite?: boolean\r\n orientation?: Orientation\r\n gestureOrientation?: GestureOrientation\r\n touchMultiplier?: number\r\n wheelMultiplier?: number\r\n autoResize?: boolean\r\n prevent?: boolean | ((node: Element) => boolean)\r\n __experimental__naiveDimensions?: boolean\r\n}\r\n\r\nexport default class Lenis {\r\n // __isSmooth: boolean = false // true if scroll should be animated\r\n __isScrolling: boolean | 'native' | 'smooth' = false // true when scroll is animating\r\n __isStopped: boolean = false // true if user should not be able to scroll - enable/disable programmatically\r\n __isLocked: boolean = false // same as isStopped but enabled/disabled when scroll reaches target\r\n\r\n time: number\r\n userData: object\r\n lastVelocity: number\r\n velocity: number\r\n direction: 1 | -1 | undefined\r\n options: LenisOptions\r\n targetScroll: number\r\n animatedScroll: number\r\n // animate: Animate\r\n // emitter: Emitter\r\n // dimensions: Dimensions\r\n // virtualScroll: VirtualScroll\r\n\r\n constructor({\r\n wrapper = window,\r\n content = document.documentElement,\r\n wheelEventsTarget = wrapper, // deprecated\r\n eventsTarget = wheelEventsTarget,\r\n smoothWheel = true,\r\n syncTouch = false,\r\n syncTouchLerp = 0.075,\r\n touchInertiaMultiplier = 35,\r\n duration, // in seconds\r\n easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),\r\n lerp = !duration && 0.1,\r\n infinite = false,\r\n orientation = 'vertical', // vertical, horizontal\r\n gestureOrientation = 'vertical', // vertical, horizontal, both\r\n touchMultiplier = 1,\r\n wheelMultiplier = 1,\r\n autoResize = true,\r\n prevent = false,\r\n __experimental__naiveDimensions = false,\r\n }: LenisOptions = {}) {\r\n window.lenisVersion = version\r\n\r\n // if wrapper is html or body, fallback to window\r\n if (wrapper === document.documentElement || wrapper === document.body) {\r\n wrapper = window\r\n }\r\n\r\n this.options = {\r\n wrapper,\r\n content,\r\n wheelEventsTarget,\r\n eventsTarget,\r\n smoothWheel,\r\n syncTouch,\r\n syncTouchLerp,\r\n touchInertiaMultiplier,\r\n duration,\r\n easing,\r\n lerp,\r\n infinite,\r\n gestureOrientation,\r\n orientation,\r\n touchMultiplier,\r\n wheelMultiplier,\r\n autoResize,\r\n prevent,\r\n __experimental__naiveDimensions,\r\n }\r\n\r\n this.animate = new Animate()\r\n this.emitter = new Emitter()\r\n this.dimensions = new Dimensions({ wrapper, content, autoResize })\r\n // this.toggleClassName('lenis', true)\r\n this.updateClassName()\r\n\r\n this.userData = {}\r\n this.time = 0\r\n this.velocity = this.lastVelocity = 0\r\n this.isLocked = false\r\n this.isStopped = false\r\n // this.hasScrolled = false\r\n // this.isSmooth = syncTouch || smoothWheel\r\n // this.isSmooth = false\r\n this.isScrolling = false\r\n this.targetScroll = this.animatedScroll = this.actualScroll\r\n\r\n this.options.wrapper.addEventListener('scroll', this.onNativeScroll, false)\r\n\r\n this.virtualScroll = new VirtualScroll(eventsTarget, {\r\n touchMultiplier,\r\n wheelMultiplier,\r\n })\r\n this.virtualScroll.on('scroll', this.onVirtualScroll)\r\n }\r\n\r\n destroy() {\r\n this.emitter.destroy()\r\n\r\n this.options.wrapper.removeEventListener(\r\n 'scroll',\r\n this.onNativeScroll,\r\n false\r\n )\r\n\r\n this.virtualScroll.destroy()\r\n this.dimensions.destroy()\r\n\r\n this.cleanUpClassName()\r\n\r\n // this.rootElement.className = ''\r\n\r\n // this.toggleClassName('lenis', false)\r\n // this.toggleClassName('lenis-smooth', false)\r\n // this.toggleClassName('lenis-scrolling', false)\r\n // this.toggleClassName('lenis-stopped', false)\r\n // this.toggleClassName('lenis-locked', false)\r\n }\r\n\r\n on(event: string, callback: Function) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n off(event: string, callback: Function) {\r\n return this.emitter.off(event, callback)\r\n }\r\n\r\n private setScroll(scroll) {\r\n // apply scroll value immediately\r\n if (this.isHorizontal) {\r\n this.rootElement.scrollLeft = scroll\r\n } else {\r\n this.rootElement.scrollTop = scroll\r\n }\r\n }\r\n\r\n private onVirtualScroll = ({ deltaX, deltaY, event }) => {\r\n // keep zoom feature\r\n if (event.ctrlKey) return\r\n\r\n const isTouch = event.type.includes('touch')\r\n const isWheel = event.type.includes('wheel')\r\n\r\n this.isTouching = event.type === 'touchstart' || event.type === 'touchmove'\r\n // if (event.type === 'touchend') {\r\n // console.log('touchend', this.scroll)\r\n // // this.lastVelocity = this.velocity\r\n // // this.velocity = 0\r\n // // this.isScrolling = false\r\n // this.emit({ type: 'touchend' })\r\n // // alert('touchend')\r\n // return\r\n // }\r\n\r\n const isTapToStop =\r\n this.options.syncTouch &&\r\n isTouch &&\r\n event.type === 'touchstart' &&\r\n !this.isStopped &&\r\n !this.isLocked\r\n\r\n if (isTapToStop) {\r\n this.reset()\r\n return\r\n }\r\n\r\n const isClick = deltaX === 0 && deltaY === 0 // click event\r\n\r\n // const isPullToRefresh =\r\n // this.options.gestureOrientation === 'vertical' &&\r\n // this.scroll === 0 &&\r\n // !this.options.infinite &&\r\n // deltaY <= 5 // touch pull to refresh, not reliable yet\r\n\r\n const isUnknownGesture =\r\n (this.options.gestureOrientation === 'vertical' && deltaY === 0) ||\r\n (this.options.gestureOrientation === 'horizontal' && deltaX === 0)\r\n\r\n if (isClick || isUnknownGesture) {\r\n // console.log('prevent')\r\n return\r\n }\r\n\r\n // catch if scrolling on nested scroll elements\r\n let composedPath = event.composedPath()\r\n composedPath = composedPath.slice(0, composedPath.indexOf(this.rootElement)) // remove parents elements\r\n\r\n if (\r\n !!composedPath.find(\r\n (node) =>\r\n this.options.prevent(node) ||\r\n node.hasAttribute?.('data-lenis-prevent') ||\r\n (isTouch && node.hasAttribute?.('data-lenis-prevent-touch')) ||\r\n (isWheel && node.hasAttribute?.('data-lenis-prevent-wheel')) ||\r\n (node.classList?.contains('lenis') &&\r\n !node.classList?.contains('lenis-stopped')) // nested lenis instance\r\n )\r\n )\r\n return\r\n\r\n if (this.isStopped || this.isLocked) {\r\n event.preventDefault() // this will stop forwarding the event to the parent, this is problematic\r\n return\r\n }\r\n\r\n const isSmooth =\r\n (this.options.syncTouch && isTouch) ||\r\n (this.options.smoothWheel && isWheel)\r\n\r\n if (!isSmooth) {\r\n this.isScrolling = 'native'\r\n this.animate.stop()\r\n return\r\n }\r\n\r\n event.preventDefault()\r\n\r\n let delta = deltaY\r\n if (this.options.gestureOrientation === 'both') {\r\n delta = Math.abs(deltaY) > Math.abs(deltaX) ? deltaY : deltaX\r\n } else if (this.options.gestureOrientation === 'horizontal') {\r\n delta = deltaX\r\n }\r\n\r\n const syncTouch = isTouch && this.options.syncTouch\r\n const isTouchEnd = isTouch && event.type === 'touchend'\r\n\r\n const hasTouchInertia = isTouchEnd && Math.abs(delta) > 5\r\n\r\n if (hasTouchInertia) {\r\n delta = this.velocity * this.options.touchInertiaMultiplier\r\n }\r\n\r\n this.scrollTo(this.targetScroll + delta, {\r\n programmatic: false,\r\n ...(syncTouch\r\n ? {\r\n lerp: hasTouchInertia ? this.options.syncTouchLerp : 1,\r\n }\r\n : {\r\n lerp: this.options.lerp,\r\n duration: this.options.duration,\r\n easing: this.options.easing,\r\n }),\r\n })\r\n }\r\n\r\n resize() {\r\n this.dimensions.resize()\r\n }\r\n\r\n private emit({ userData = {} } = {}) {\r\n this.userData = userData\r\n this.emitter.emit('scroll', this)\r\n this.userData = {}\r\n }\r\n\r\n private onNativeScroll = () => {\r\n clearTimeout(this.__resetVelocityTimeout)\r\n delete this.__resetVelocityTimeout\r\n\r\n if (this.__preventNextNativeScrollEvent) {\r\n delete this.__preventNextNativeScrollEvent\r\n return\r\n }\r\n\r\n if (this.isScrolling === false || this.isScrolling === 'native') {\r\n const lastScroll = this.animatedScroll\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.lastVelocity = this.velocity\r\n this.velocity = this.animatedScroll - lastScroll\r\n this.direction = Math.sign(this.animatedScroll - lastScroll)\r\n // this.isSmooth = false\r\n this.isScrolling = this.hasScrolled ? 'native' : false\r\n this.emit()\r\n\r\n if (this.velocity !== 0) {\r\n this.__resetVelocityTimeout = setTimeout(() => {\r\n this.lastVelocity = this.velocity\r\n this.velocity = 0\r\n this.isScrolling = false\r\n this.emit()\r\n }, 400)\r\n }\r\n\r\n // this.hasScrolled = true\r\n // }, 50)\r\n }\r\n }\r\n\r\n private reset() {\r\n this.isLocked = false\r\n this.isScrolling = false\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.lastVelocity = this.velocity = 0\r\n this.animate.stop()\r\n }\r\n\r\n start() {\r\n if (!this.isStopped) return\r\n this.isStopped = false\r\n\r\n this.reset()\r\n }\r\n\r\n stop() {\r\n if (this.isStopped) return\r\n this.isStopped = true\r\n this.animate.stop()\r\n\r\n this.reset()\r\n }\r\n\r\n raf(time: number) {\r\n const deltaTime = time - (this.time || time)\r\n this.time = time\r\n\r\n this.animate.advance(deltaTime * 0.001)\r\n }\r\n\r\n scrollTo(\r\n target: number | string | HTMLElement,\r\n {\r\n offset = 0,\r\n immediate = false,\r\n lock = false,\r\n duration = this.options.duration,\r\n easing = this.options.easing,\r\n lerp = !duration && this.options.lerp,\r\n onStart,\r\n onComplete,\r\n force = false, // scroll even if stopped\r\n programmatic = true, // called from outside of the class\r\n userData = {},\r\n }: {\r\n offset?: number\r\n immediate?: boolean\r\n lock?: boolean\r\n duration?: number\r\n easing?: EasingFunction\r\n lerp?: number\r\n onStart?: (lenis: Lenis) => void\r\n onComplete?: (lenis: Lenis) => void\r\n force?: boolean\r\n programmatic?: boolean\r\n userData?: object\r\n } = {}\r\n ) {\r\n if ((this.isStopped || this.isLocked) && !force) return\r\n\r\n // keywords\r\n if (['top', 'left', 'start'].includes(target)) {\r\n target = 0\r\n } else if (['bottom', 'right', 'end'].includes(target)) {\r\n target = 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 }\r\n\r\n if (node) {\r\n if (this.options.wrapper !== window) {\r\n // nested scroll offset correction\r\n const wrapperRect = this.options.wrapper.getBoundingClientRect()\r\n offset -= this.isHorizontal ? wrapperRect.left : wrapperRect.top\r\n }\r\n\r\n const rect = node.getBoundingClientRect()\r\n\r\n target =\r\n (this.isHorizontal ? rect.left : rect.top) + this.animatedScroll\r\n }\r\n }\r\n\r\n if (typeof target !== 'number') return\r\n\r\n target += offset\r\n target = Math.round(target)\r\n\r\n if (this.options.infinite) {\r\n if (programmatic) {\r\n this.targetScroll = this.animatedScroll = this.scroll\r\n }\r\n } else {\r\n target = clamp(0, target, this.limit)\r\n }\r\n\r\n if (immediate) {\r\n this.animatedScroll = this.targetScroll = target\r\n this.setScroll(this.scroll)\r\n this.reset()\r\n onComplete?.(this)\r\n return\r\n }\r\n\r\n if (target === this.targetScroll) return\r\n\r\n if (!programmatic) {\r\n this.targetScroll = target\r\n }\r\n\r\n this.animate.fromTo(this.animatedScroll, target, {\r\n duration,\r\n easing,\r\n lerp,\r\n onStart: () => {\r\n // started\r\n if (lock) this.isLocked = true\r\n this.isScrolling = 'smooth'\r\n onStart?.(this)\r\n },\r\n onUpdate: (value: number, completed: boolean) => {\r\n this.isScrolling = 'smooth'\r\n\r\n // updated\r\n this.lastVelocity = this.velocity\r\n this.velocity = value - this.animatedScroll\r\n this.direction = Math.sign(this.velocity)\r\n\r\n this.animatedScroll = value\r\n this.setScroll(this.scroll)\r\n\r\n if (programmatic) {\r\n // wheel during programmatic should stop it\r\n this.targetScroll = value\r\n }\r\n\r\n if (!completed) this.emit({ userData })\r\n\r\n if (completed) {\r\n this.reset()\r\n this.emit({ userData })\r\n onComplete?.(this)\r\n\r\n // avoid emitting event twice\r\n this.__preventNextNativeScrollEvent = true\r\n // requestAnimationFrame(() => {\r\n // delete this.__preventNextNativeScrollEvent\r\n // })\r\n }\r\n },\r\n })\r\n }\r\n\r\n get rootElement() {\r\n return this.options.wrapper === window\r\n ? document.documentElement\r\n : this.options.wrapper\r\n }\r\n\r\n get limit() {\r\n if (this.options.__experimental__naiveDimensions) {\r\n if (this.isHorizontal) {\r\n return this.rootElement.scrollWidth - this.rootElement.clientWidth\r\n } else {\r\n return this.rootElement.scrollHeight - this.rootElement.clientHeight\r\n }\r\n } else {\r\n return this.dimensions.limit[this.isHorizontal ? 'x' : 'y']\r\n }\r\n }\r\n\r\n get isHorizontal() {\r\n return this.options.orientation === 'horizontal'\r\n }\r\n\r\n get actualScroll(): number {\r\n // value browser takes into account\r\n return this.isHorizontal\r\n ? this.rootElement.scrollLeft\r\n : this.rootElement.scrollTop\r\n }\r\n\r\n get scroll(): number {\r\n return this.options.infinite\r\n ? modulo(this.animatedScroll, this.limit)\r\n : this.animatedScroll\r\n }\r\n\r\n get progress(): number {\r\n // avoid progress to be NaN\r\n return this.limit === 0 ? 1 : this.scroll / this.limit\r\n }\r\n\r\n // get isSmooth() {\r\n // return this.__isSmooth\r\n // }\r\n\r\n // private set isSmooth(value: boolean) {\r\n // if (this.__isSmooth !== value) {\r\n // this.__isSmooth = value\r\n // this.updateClassName()\r\n // }\r\n // }\r\n\r\n get isScrolling() {\r\n return this.__isScrolling\r\n }\r\n\r\n private set isScrolling(value: boolean) {\r\n if (this.__isScrolling !== value) {\r\n this.__isScrolling = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isStopped() {\r\n return this.__isStopped\r\n }\r\n\r\n private set isStopped(value: boolean) {\r\n if (this.__isStopped !== value) {\r\n this.__isStopped = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isLocked() {\r\n return this.__isLocked\r\n }\r\n\r\n private set isLocked(value: boolean) {\r\n if (this.__isLocked !== value) {\r\n this.__isLocked = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isSmooth() {\r\n return this.isScrolling === 'smooth'\r\n }\r\n\r\n get className() {\r\n let className = 'lenis'\r\n if (this.isStopped) className += ' lenis-stopped'\r\n if (this.isLocked) className += ' lenis-locked'\r\n if (this.isScrolling) className += ' lenis-scrolling'\r\n if (this.isScrolling === 'smooth') className += ' lenis-smooth'\r\n // if (this.isScrolling === 'native') className += ' lenis-native'\r\n // if (this.isSmooth) className += ' lenis-smooth'\r\n return className\r\n }\r\n\r\n private updateClassName() {\r\n this.cleanUpClassName()\r\n\r\n this.rootElement.className =\r\n `${this.rootElement.className} ${this.className}`.trim()\r\n // this.emitter.emit('className change', this)\r\n }\r\n\r\n private cleanUpClassName() {\r\n this.rootElement.className = this.rootElement.className\r\n .replace(/lenis(-\\w+)?/g, '')\r\n .trim()\r\n }\r\n\r\n // private toggleClassName(name: string, value: boolean) {\r\n // // this.rootElement.classList.toggle(name, value)\r\n // this.rootElement.className = this.className\r\n // this.emitter.emit('className change', this)\r\n // }\r\n}\r\n"],"names":["clamp","min","input","max","Math","Animate","advance","deltaTime","this","isRunning","completed","lerp","value","damp","x","y","lambda","dt","t","exp","to","round","currentTime","linearProgress","duration","easedProgress","easing","from","stop","onUpdate","fromTo","onStart","Dimensions","constructor","wrapper","content","autoResize","debounce","debounceValue","debouncedResize","callback","delay","timer","args","arguments","context","clearTimeout","setTimeout","apply","resize","window","addEventListener","wrapperResizeObserver","ResizeObserver","observe","contentResizeObserver","destroy","disconnect","removeEventListener","onWrapperResize","onContentResize","width","innerWidth","height","innerHeight","clientWidth","clientHeight","scrollHeight","scrollWidth","limit","Emitter","events","emit","event","callbacks","i","length","on","cb","push","filter","off","LINE_HEIGHT","VirtualScroll","element","wheelMultiplier","touchMultiplier","touchStart","emitter","onWindowResize","onWheel","passive","onTouchStart","onTouchMove","onTouchEnd","clientX","clientY","targetTouches","lastDelta","deltaX","deltaY","deltaMode","windowWidth","windowHeight","Lenis","document","documentElement","wheelEventsTarget","eventsTarget","smoothWheel","syncTouch","syncTouchLerp","touchInertiaMultiplier","pow","infinite","orientation","gestureOrientation","prevent","__experimental__naiveDimensions","__isScrolling","__isStopped","__isLocked","onVirtualScroll","ctrlKey","isTouch","type","includes","isWheel","isTouching","options","isStopped","isLocked","reset","isClick","isUnknownGesture","composedPath","slice","indexOf","rootElement","find","node","_a","hasAttribute","call","_b","_c","classList","_d","contains","_e","preventDefault","isScrolling","animate","delta","abs","hasTouchInertia","velocity","scrollTo","targetScroll","Object","assign","programmatic","onNativeScroll","__resetVelocityTimeout","__preventNextNativeScrollEvent","lastScroll","animatedScroll","actualScroll","lastVelocity","direction","sign","hasScrolled","lenisVersion","body","dimensions","updateClassName","userData","time","virtualScroll","cleanUpClassName","setScroll","scroll","isHorizontal","scrollLeft","scrollTop","start","raf","target","offset","immediate","lock","onComplete","force","querySelector","nodeType","wrapperRect","getBoundingClientRect","left","top","rect","modulo","n","d","progress","isSmooth","className","trim","replace"],"mappings":"AACO,SAASA,MAAMC,EAAKC,EAAOC,GAChC,OAAOC,KAAKD,IAAIF,EAAKG,KAAKH,IAAIC,EAAOC,GACvC,CCAO,MAAME,QAEX,OAAAC,CAAQC,GACN,I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ArBpM,KAAK+I,WACb,CAED,aAAIsD,GACF,IAAIA,EAAY,QAOhB,OANIrM,KAAK0H,YAAW2E,GAAa,kBAC7BrM,KAAK2H,WAAU0E,GAAa,iBAC5BrM,KAAK+I,cAAasD,GAAa,oBACV,WAArBrM,KAAK+I,cAA0BsD,GAAa,iBAGzCA,CACR,CAEO,eAAA9B,GACNvK,KAAK2K,mBAEL3K,KAAKkI,YAAYmE,UACf,GAAGrM,KAAKkI,YAAYmE,aAAarM,KAAKqM,YAAYC,MAErD,CAEO,gBAAA3B,GACN3K,KAAKkI,YAAYmE,UAAYrM,KAAKkI,YAAYmE,UAC3CE,QAAQ,gBAAiB,IACzBD,MACJ"} \ No newline at end of file +{"version":3,"file":"lenis.mjs","sources":["../src/maths.js","../src/animate.js","../src/dimensions.js","../src/debounce.js","../src/emitter.js","../src/virtual-scroll.js","../src/index.ts"],"sourcesContent":["// Clamp a value between a minimum and maximum value\r\nexport function clamp(min, input, max) {\r\n return Math.max(min, Math.min(input, max))\r\n}\r\n\r\n// Truncate a floating-point number to a specified number of decimal places\r\nexport function truncate(value, decimals = 0) {\r\n return parseFloat(value.toFixed(decimals))\r\n}\r\n\r\n// Linearly interpolate between two values using an amount (0 <= t <= 1)\r\nexport function lerp(x, y, t) {\r\n return (1 - t) * x + t * y\r\n}\r\n\r\n// http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/\r\nexport function damp(x, y, lambda, dt) {\r\n return lerp(x, y, 1 - Math.exp(-lambda * dt))\r\n}\r\n\r\n// Calculate the modulo of the dividend and divisor while keeping the result within the same sign as the divisor\r\n// https://anguscroll.com/just/just-modulo\r\nexport function modulo(n, d) {\r\n return ((n % d) + d) % d\r\n}\r\n","import { clamp, damp } from './maths'\r\n\r\n// Animate class to handle value animations with lerping or easing\r\nexport class Animate {\r\n // Advance the animation by the given delta time\r\n advance(deltaTime) {\r\n if (!this.isRunning) return\r\n\r\n let completed = false\r\n\r\n if (this.lerp) {\r\n this.value = damp(this.value, this.to, this.lerp * 60, deltaTime)\r\n if (Math.round(this.value) === this.to) {\r\n this.value = this.to\r\n completed = true\r\n }\r\n } else {\r\n this.currentTime += deltaTime\r\n const linearProgress = clamp(0, this.currentTime / this.duration, 1)\r\n\r\n completed = linearProgress >= 1\r\n const easedProgress = completed ? 1 : this.easing(linearProgress)\r\n this.value = this.from + (this.to - this.from) * easedProgress\r\n }\r\n\r\n if (completed) {\r\n this.stop()\r\n }\r\n\r\n // Call the onUpdate callback with the current value and completed status\r\n this.onUpdate?.(this.value, completed)\r\n }\r\n\r\n // Stop the animation\r\n stop() {\r\n this.isRunning = false\r\n }\r\n\r\n // Set up the animation from a starting value to an ending value\r\n // with optional parameters for lerping, duration, easing, and onUpdate callback\r\n fromTo(\r\n from,\r\n to,\r\n { lerp = 0.1, duration = 1, easing = (t) => t, onStart, onUpdate }\r\n ) {\r\n this.from = this.value = from\r\n this.to = to\r\n this.lerp = lerp\r\n this.duration = duration\r\n this.easing = easing\r\n this.currentTime = 0\r\n this.isRunning = true\r\n\r\n onStart?.()\r\n this.onUpdate = onUpdate\r\n }\r\n}\r\n","import { debounce } from './debounce'\r\n\r\nexport class Dimensions {\r\n constructor({\r\n wrapper,\r\n content,\r\n autoResize = true,\r\n debounce: debounceValue = 250,\r\n } = {}) {\r\n this.wrapper = wrapper\r\n this.content = content\r\n\r\n if (autoResize) {\r\n this.debouncedResize = debounce(this.resize, debounceValue)\r\n\r\n if (this.wrapper === window) {\r\n window.addEventListener('resize', this.debouncedResize, false)\r\n } else {\r\n this.wrapperResizeObserver = new ResizeObserver(this.debouncedResize)\r\n this.wrapperResizeObserver.observe(this.wrapper)\r\n }\r\n\r\n this.contentResizeObserver = new ResizeObserver(this.debouncedResize)\r\n this.contentResizeObserver.observe(this.content)\r\n }\r\n\r\n this.resize()\r\n }\r\n\r\n destroy() {\r\n this.wrapperResizeObserver?.disconnect()\r\n this.contentResizeObserver?.disconnect()\r\n window.removeEventListener('resize', this.debouncedResize, false)\r\n }\r\n\r\n resize = () => {\r\n this.onWrapperResize()\r\n this.onContentResize()\r\n }\r\n\r\n onWrapperResize = () => {\r\n if (this.wrapper === window) {\r\n this.width = window.innerWidth\r\n this.height = window.innerHeight\r\n } else {\r\n this.width = this.wrapper.clientWidth\r\n this.height = this.wrapper.clientHeight\r\n }\r\n }\r\n\r\n onContentResize = () => {\r\n if (this.wrapper === window) {\r\n this.scrollHeight = this.content.scrollHeight\r\n this.scrollWidth = this.content.scrollWidth\r\n } else {\r\n this.scrollHeight = this.wrapper.scrollHeight\r\n this.scrollWidth = this.wrapper.scrollWidth\r\n }\r\n }\r\n\r\n get limit() {\r\n return {\r\n x: this.scrollWidth - this.width,\r\n y: this.scrollHeight - this.height,\r\n }\r\n }\r\n}\r\n","export function debounce(callback, delay) {\r\n let timer\r\n return function () {\r\n let args = arguments\r\n let context = this\r\n clearTimeout(timer)\r\n timer = setTimeout(function () {\r\n callback.apply(context, args)\r\n }, delay)\r\n }\r\n}\r\n","export class Emitter {\r\n constructor() {\r\n this.events = {}\r\n }\r\n\r\n emit(event, ...args) {\r\n let callbacks = this.events[event] || []\r\n for (let i = 0, length = callbacks.length; i < length; i++) {\r\n callbacks[i](...args)\r\n }\r\n }\r\n\r\n on(event, cb) {\r\n // Add the callback to the event's callback list, or create a new list with the callback\r\n this.events[event]?.push(cb) || (this.events[event] = [cb])\r\n\r\n // Return an unsubscribe function\r\n return () => {\r\n this.events[event] = this.events[event]?.filter((i) => cb !== i)\r\n }\r\n }\r\n\r\n off(event, callback) {\r\n this.events[event] = this.events[event]?.filter((i) => callback !== i)\r\n }\r\n\r\n destroy() {\r\n this.events = {}\r\n }\r\n}\r\n","import { Emitter } from './emitter'\r\n\r\nconst LINE_HEIGHT = 100 / 6\r\n\r\nexport class VirtualScroll {\r\n constructor(element, { wheelMultiplier = 1, touchMultiplier = 1 }) {\r\n this.element = element\r\n this.wheelMultiplier = wheelMultiplier\r\n this.touchMultiplier = touchMultiplier\r\n\r\n this.touchStart = {\r\n x: null,\r\n y: null,\r\n }\r\n\r\n this.emitter = new Emitter()\r\n window.addEventListener('resize', this.onWindowResize, false)\r\n this.onWindowResize()\r\n\r\n this.element.addEventListener('wheel', this.onWheel, { passive: false })\r\n this.element.addEventListener('touchstart', this.onTouchStart, {\r\n passive: false,\r\n })\r\n this.element.addEventListener('touchmove', this.onTouchMove, {\r\n passive: false,\r\n })\r\n this.element.addEventListener('touchend', this.onTouchEnd, {\r\n passive: false,\r\n })\r\n }\r\n\r\n // Add an event listener for the given event and callback\r\n on(event, callback) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n // Remove all event listeners and clean up\r\n destroy() {\r\n this.emitter.destroy()\r\n\r\n window.removeEventListener('resize', this.onWindowResize, false)\r\n\r\n this.element.removeEventListener('wheel', this.onWheel, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchstart', this.onTouchStart, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchmove', this.onTouchMove, {\r\n passive: false,\r\n })\r\n this.element.removeEventListener('touchend', this.onTouchEnd, {\r\n passive: false,\r\n })\r\n }\r\n\r\n // Event handler for 'touchstart' event\r\n onTouchStart = (event) => {\r\n const { clientX, clientY } = event.targetTouches\r\n ? event.targetTouches[0]\r\n : event\r\n\r\n this.touchStart.x = clientX\r\n this.touchStart.y = clientY\r\n\r\n this.lastDelta = {\r\n x: 0,\r\n y: 0,\r\n }\r\n\r\n this.emitter.emit('scroll', {\r\n deltaX: 0,\r\n deltaY: 0,\r\n event,\r\n })\r\n }\r\n\r\n // Event handler for 'touchmove' event\r\n onTouchMove = (event) => {\r\n const { clientX, clientY } = event.targetTouches\r\n ? event.targetTouches[0]\r\n : event\r\n\r\n const deltaX = -(clientX - this.touchStart.x) * this.touchMultiplier\r\n const deltaY = -(clientY - this.touchStart.y) * this.touchMultiplier\r\n\r\n this.touchStart.x = clientX\r\n this.touchStart.y = clientY\r\n\r\n this.lastDelta = {\r\n x: deltaX,\r\n y: deltaY,\r\n }\r\n\r\n this.emitter.emit('scroll', {\r\n deltaX,\r\n deltaY,\r\n event,\r\n })\r\n }\r\n\r\n onTouchEnd = (event) => {\r\n this.emitter.emit('scroll', {\r\n deltaX: this.lastDelta.x,\r\n deltaY: this.lastDelta.y,\r\n event,\r\n })\r\n }\r\n\r\n // Event handler for 'wheel' event\r\n onWheel = (event) => {\r\n let { deltaX, deltaY, deltaMode } = event\r\n\r\n const multiplierX =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.windowWidth : 1\r\n const multiplierY =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.windowHeight : 1\r\n\r\n deltaX *= multiplierX\r\n deltaY *= multiplierY\r\n\r\n deltaX *= this.wheelMultiplier\r\n deltaY *= this.wheelMultiplier\r\n\r\n this.emitter.emit('scroll', { deltaX, deltaY, event })\r\n }\r\n\r\n onWindowResize = () => {\r\n this.windowWidth = window.innerWidth\r\n this.windowHeight = window.innerHeight\r\n }\r\n}\r\n","import { version } from '../../../package.json'\r\nimport { Animate } from './animate'\r\nimport { Dimensions } from './dimensions'\r\nimport { Emitter } from './emitter'\r\nimport { clamp, modulo } from './maths'\r\nimport { VirtualScroll } from './virtual-scroll'\r\n\r\n// Technical explanation\r\n// - listen to 'wheel' events\r\n// - prevent 'wheel' event to prevent scroll\r\n// - normalize wheel delta\r\n// - add delta to targetScroll\r\n// - animate scroll to targetScroll (smooth context)\r\n// - if animation is not running, listen to 'scroll' events (native context)\r\n\r\ntype EasingFunction = (t: number) => number\r\ntype Orientation = 'vertical' | 'horizontal'\r\ntype GestureOrientation = 'vertical' | 'horizontal' | 'both'\r\n\r\nexport type LenisOptions = {\r\n wrapper?: Window | HTMLElement\r\n content?: HTMLElement\r\n wheelEventsTarget?: Window | HTMLElement\r\n eventsTarget?: Window | HTMLElement\r\n smoothWheel?: boolean\r\n syncTouch?: boolean\r\n syncTouchLerp?: number\r\n touchInertiaMultiplier?: number\r\n duration?: number\r\n easing?: EasingFunction\r\n lerp?: number\r\n infinite?: boolean\r\n orientation?: Orientation\r\n gestureOrientation?: GestureOrientation\r\n touchMultiplier?: number\r\n wheelMultiplier?: number\r\n autoResize?: boolean\r\n prevent?: boolean | ((node: Element) => boolean)\r\n __experimental__naiveDimensions?: boolean\r\n}\r\n\r\nexport default class Lenis {\r\n // __isSmooth: boolean = false // true if scroll should be animated\r\n __isScrolling: boolean | 'native' | 'smooth' = false // true when scroll is animating\r\n __isStopped: boolean = false // true if user should not be able to scroll - enable/disable programmatically\r\n __isLocked: boolean = false // same as isStopped but enabled/disabled when scroll reaches target\r\n\r\n time: number\r\n userData: object\r\n lastVelocity: number\r\n velocity: number\r\n direction: 1 | -1 | undefined\r\n options: LenisOptions\r\n targetScroll: number\r\n animatedScroll: number\r\n // animate: Animate\r\n // emitter: Emitter\r\n // dimensions: Dimensions\r\n // virtualScroll: VirtualScroll\r\n\r\n constructor({\r\n wrapper = window,\r\n content = document.documentElement,\r\n wheelEventsTarget = wrapper, // deprecated\r\n eventsTarget = wheelEventsTarget,\r\n smoothWheel = true,\r\n syncTouch = false,\r\n syncTouchLerp = 0.075,\r\n touchInertiaMultiplier = 35,\r\n duration, // in seconds\r\n easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),\r\n lerp = !duration && 0.1,\r\n infinite = false,\r\n orientation = 'vertical', // vertical, horizontal\r\n gestureOrientation = 'vertical', // vertical, horizontal, both\r\n touchMultiplier = 1,\r\n wheelMultiplier = 1,\r\n autoResize = true,\r\n prevent = false,\r\n __experimental__naiveDimensions = false,\r\n }: LenisOptions = {}) {\r\n window.lenisVersion = version\r\n\r\n // if wrapper is html or body, fallback to window\r\n if (wrapper === document.documentElement || wrapper === document.body) {\r\n wrapper = window\r\n }\r\n\r\n this.options = {\r\n wrapper,\r\n content,\r\n wheelEventsTarget,\r\n eventsTarget,\r\n smoothWheel,\r\n syncTouch,\r\n syncTouchLerp,\r\n touchInertiaMultiplier,\r\n duration,\r\n easing,\r\n lerp,\r\n infinite,\r\n gestureOrientation,\r\n orientation,\r\n touchMultiplier,\r\n wheelMultiplier,\r\n autoResize,\r\n prevent,\r\n __experimental__naiveDimensions,\r\n }\r\n\r\n this.animate = new Animate()\r\n this.emitter = new Emitter()\r\n this.dimensions = new Dimensions({ wrapper, content, autoResize })\r\n // this.toggleClassName('lenis', true)\r\n this.updateClassName()\r\n\r\n this.userData = {}\r\n this.time = 0\r\n this.velocity = this.lastVelocity = 0\r\n this.isLocked = false\r\n this.isStopped = false\r\n // this.hasScrolled = false\r\n // this.isSmooth = syncTouch || smoothWheel\r\n // this.isSmooth = false\r\n this.isScrolling = false\r\n this.targetScroll = this.animatedScroll = this.actualScroll\r\n\r\n this.options.wrapper.addEventListener('scroll', this.onNativeScroll, false)\r\n\r\n this.virtualScroll = new VirtualScroll(eventsTarget, {\r\n touchMultiplier,\r\n wheelMultiplier,\r\n })\r\n this.virtualScroll.on('scroll', this.onVirtualScroll)\r\n }\r\n\r\n destroy() {\r\n this.emitter.destroy()\r\n\r\n this.options.wrapper.removeEventListener(\r\n 'scroll',\r\n this.onNativeScroll,\r\n false\r\n )\r\n\r\n this.virtualScroll.destroy()\r\n this.dimensions.destroy()\r\n\r\n this.cleanUpClassName()\r\n\r\n // this.rootElement.className = ''\r\n\r\n // this.toggleClassName('lenis', false)\r\n // this.toggleClassName('lenis-smooth', false)\r\n // this.toggleClassName('lenis-scrolling', false)\r\n // this.toggleClassName('lenis-stopped', false)\r\n // this.toggleClassName('lenis-locked', false)\r\n }\r\n\r\n on(event: string, callback: Function) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n off(event: string, callback: Function) {\r\n return this.emitter.off(event, callback)\r\n }\r\n\r\n private setScroll(scroll) {\r\n // apply scroll value immediately\r\n if (this.isHorizontal) {\r\n this.rootElement.scrollLeft = scroll\r\n } else {\r\n this.rootElement.scrollTop = scroll\r\n }\r\n }\r\n\r\n private onVirtualScroll = ({ deltaX, deltaY, event }) => {\r\n // keep zoom feature\r\n if (event.ctrlKey) return\r\n\r\n const isTouch = event.type.includes('touch')\r\n const isWheel = event.type.includes('wheel')\r\n\r\n this.isTouching = event.type === 'touchstart' || event.type === 'touchmove'\r\n // if (event.type === 'touchend') {\r\n // console.log('touchend', this.scroll)\r\n // // this.lastVelocity = this.velocity\r\n // // this.velocity = 0\r\n // // this.isScrolling = false\r\n // this.emit({ type: 'touchend' })\r\n // // alert('touchend')\r\n // return\r\n // }\r\n\r\n const isTapToStop =\r\n this.options.syncTouch &&\r\n isTouch &&\r\n event.type === 'touchstart' &&\r\n !this.isStopped &&\r\n !this.isLocked\r\n\r\n if (isTapToStop) {\r\n this.reset()\r\n return\r\n }\r\n\r\n const isClick = deltaX === 0 && deltaY === 0 // click event\r\n\r\n // const isPullToRefresh =\r\n // this.options.gestureOrientation === 'vertical' &&\r\n // this.scroll === 0 &&\r\n // !this.options.infinite &&\r\n // deltaY <= 5 // touch pull to refresh, not reliable yet\r\n\r\n const isUnknownGesture =\r\n (this.options.gestureOrientation === 'vertical' && deltaY === 0) ||\r\n (this.options.gestureOrientation === 'horizontal' && deltaX === 0)\r\n\r\n if (isClick || isUnknownGesture) {\r\n // console.log('prevent')\r\n return\r\n }\r\n\r\n // catch if scrolling on nested scroll elements\r\n let composedPath = event.composedPath()\r\n composedPath = composedPath.slice(0, composedPath.indexOf(this.rootElement)) // remove parents elements\r\n\r\n const prevent = this.options.prevent\r\n\r\n if (\r\n !!composedPath.find(\r\n (node) =>\r\n (typeof prevent === 'function' ? prevent?.(node) : prevent) ||\r\n node.hasAttribute?.('data-lenis-prevent') ||\r\n (isTouch && node.hasAttribute?.('data-lenis-prevent-touch')) ||\r\n (isWheel && node.hasAttribute?.('data-lenis-prevent-wheel')) ||\r\n (node.classList?.contains('lenis') &&\r\n !node.classList?.contains('lenis-stopped')) // nested lenis instance\r\n )\r\n )\r\n return\r\n\r\n if (this.isStopped || this.isLocked) {\r\n event.preventDefault() // this will stop forwarding the event to the parent, this is problematic\r\n return\r\n }\r\n\r\n const isSmooth =\r\n (this.options.syncTouch && isTouch) ||\r\n (this.options.smoothWheel && isWheel)\r\n\r\n if (!isSmooth) {\r\n this.isScrolling = 'native'\r\n this.animate.stop()\r\n return\r\n }\r\n\r\n event.preventDefault()\r\n\r\n let delta = deltaY\r\n if (this.options.gestureOrientation === 'both') {\r\n delta = Math.abs(deltaY) > Math.abs(deltaX) ? deltaY : deltaX\r\n } else if (this.options.gestureOrientation === 'horizontal') {\r\n delta = deltaX\r\n }\r\n\r\n const syncTouch = isTouch && this.options.syncTouch\r\n const isTouchEnd = isTouch && event.type === 'touchend'\r\n\r\n const hasTouchInertia = isTouchEnd && Math.abs(delta) > 5\r\n\r\n if (hasTouchInertia) {\r\n delta = this.velocity * this.options.touchInertiaMultiplier\r\n }\r\n\r\n this.scrollTo(this.targetScroll + delta, {\r\n programmatic: false,\r\n ...(syncTouch\r\n ? {\r\n lerp: hasTouchInertia ? this.options.syncTouchLerp : 1,\r\n }\r\n : {\r\n lerp: this.options.lerp,\r\n duration: this.options.duration,\r\n easing: this.options.easing,\r\n }),\r\n })\r\n }\r\n\r\n resize() {\r\n this.dimensions.resize()\r\n }\r\n\r\n private emit({ userData = {} } = {}) {\r\n this.userData = userData\r\n this.emitter.emit('scroll', this)\r\n this.userData = {}\r\n }\r\n\r\n private onNativeScroll = () => {\r\n clearTimeout(this.__resetVelocityTimeout)\r\n delete this.__resetVelocityTimeout\r\n\r\n if (this.__preventNextNativeScrollEvent) {\r\n delete this.__preventNextNativeScrollEvent\r\n return\r\n }\r\n\r\n if (this.isScrolling === false || this.isScrolling === 'native') {\r\n const lastScroll = this.animatedScroll\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.lastVelocity = this.velocity\r\n this.velocity = this.animatedScroll - lastScroll\r\n this.direction = Math.sign(this.animatedScroll - lastScroll)\r\n // this.isSmooth = false\r\n this.isScrolling = this.hasScrolled ? 'native' : false\r\n this.emit()\r\n\r\n if (this.velocity !== 0) {\r\n this.__resetVelocityTimeout = setTimeout(() => {\r\n this.lastVelocity = this.velocity\r\n this.velocity = 0\r\n this.isScrolling = false\r\n this.emit()\r\n }, 400)\r\n }\r\n\r\n // this.hasScrolled = true\r\n // }, 50)\r\n }\r\n }\r\n\r\n private reset() {\r\n this.isLocked = false\r\n this.isScrolling = false\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.lastVelocity = this.velocity = 0\r\n this.animate.stop()\r\n }\r\n\r\n start() {\r\n if (!this.isStopped) return\r\n this.isStopped = false\r\n\r\n this.reset()\r\n }\r\n\r\n stop() {\r\n if (this.isStopped) return\r\n this.isStopped = true\r\n this.animate.stop()\r\n\r\n this.reset()\r\n }\r\n\r\n raf(time: number) {\r\n const deltaTime = time - (this.time || time)\r\n this.time = time\r\n\r\n this.animate.advance(deltaTime * 0.001)\r\n }\r\n\r\n scrollTo(\r\n target: number | string | HTMLElement,\r\n {\r\n offset = 0,\r\n immediate = false,\r\n lock = false,\r\n duration = this.options.duration,\r\n easing = this.options.easing,\r\n lerp = !duration && this.options.lerp,\r\n onStart,\r\n onComplete,\r\n force = false, // scroll even if stopped\r\n programmatic = true, // called from outside of the class\r\n userData = {},\r\n }: {\r\n offset?: number\r\n immediate?: boolean\r\n lock?: boolean\r\n duration?: number\r\n easing?: EasingFunction\r\n lerp?: number\r\n onStart?: (lenis: Lenis) => void\r\n onComplete?: (lenis: Lenis) => void\r\n force?: boolean\r\n programmatic?: boolean\r\n userData?: object\r\n } = {}\r\n ) {\r\n if ((this.isStopped || this.isLocked) && !force) return\r\n\r\n // keywords\r\n if (['top', 'left', 'start'].includes(target)) {\r\n target = 0\r\n } else if (['bottom', 'right', 'end'].includes(target)) {\r\n target = 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 }\r\n\r\n if (node) {\r\n if (this.options.wrapper !== window) {\r\n // nested scroll offset correction\r\n const wrapperRect = this.options.wrapper.getBoundingClientRect()\r\n offset -= this.isHorizontal ? wrapperRect.left : wrapperRect.top\r\n }\r\n\r\n const rect = node.getBoundingClientRect()\r\n\r\n target =\r\n (this.isHorizontal ? rect.left : rect.top) + this.animatedScroll\r\n }\r\n }\r\n\r\n if (typeof target !== 'number') return\r\n\r\n target += offset\r\n target = Math.round(target)\r\n\r\n if (this.options.infinite) {\r\n if (programmatic) {\r\n this.targetScroll = this.animatedScroll = this.scroll\r\n }\r\n } else {\r\n target = clamp(0, target, this.limit)\r\n }\r\n\r\n if (immediate) {\r\n this.animatedScroll = this.targetScroll = target\r\n this.setScroll(this.scroll)\r\n this.reset()\r\n onComplete?.(this)\r\n return\r\n }\r\n\r\n if (target === this.targetScroll) return\r\n\r\n if (!programmatic) {\r\n this.targetScroll = target\r\n }\r\n\r\n this.animate.fromTo(this.animatedScroll, target, {\r\n duration,\r\n easing,\r\n lerp,\r\n onStart: () => {\r\n // started\r\n if (lock) this.isLocked = true\r\n this.isScrolling = 'smooth'\r\n onStart?.(this)\r\n },\r\n onUpdate: (value: number, completed: boolean) => {\r\n this.isScrolling = 'smooth'\r\n\r\n // updated\r\n this.lastVelocity = this.velocity\r\n this.velocity = value - this.animatedScroll\r\n this.direction = Math.sign(this.velocity)\r\n\r\n this.animatedScroll = value\r\n this.setScroll(this.scroll)\r\n\r\n if (programmatic) {\r\n // wheel during programmatic should stop it\r\n this.targetScroll = value\r\n }\r\n\r\n if (!completed) this.emit({ userData })\r\n\r\n if (completed) {\r\n this.reset()\r\n this.emit({ userData })\r\n onComplete?.(this)\r\n\r\n // avoid emitting event twice\r\n this.__preventNextNativeScrollEvent = true\r\n // requestAnimationFrame(() => {\r\n // delete this.__preventNextNativeScrollEvent\r\n // })\r\n }\r\n },\r\n })\r\n }\r\n\r\n get rootElement() {\r\n return this.options.wrapper === window\r\n ? document.documentElement\r\n : this.options.wrapper\r\n }\r\n\r\n get limit() {\r\n if (this.options.__experimental__naiveDimensions) {\r\n if (this.isHorizontal) {\r\n return this.rootElement.scrollWidth - this.rootElement.clientWidth\r\n } else {\r\n return this.rootElement.scrollHeight - this.rootElement.clientHeight\r\n }\r\n } else {\r\n return this.dimensions.limit[this.isHorizontal ? 'x' : 'y']\r\n }\r\n }\r\n\r\n get isHorizontal() {\r\n return this.options.orientation === 'horizontal'\r\n }\r\n\r\n get actualScroll(): number {\r\n // value browser takes into account\r\n return this.isHorizontal\r\n ? this.rootElement.scrollLeft\r\n : this.rootElement.scrollTop\r\n }\r\n\r\n get scroll(): number {\r\n return this.options.infinite\r\n ? modulo(this.animatedScroll, this.limit)\r\n : this.animatedScroll\r\n }\r\n\r\n get progress(): number {\r\n // avoid progress to be NaN\r\n return this.limit === 0 ? 1 : this.scroll / this.limit\r\n }\r\n\r\n // get isSmooth() {\r\n // return this.__isSmooth\r\n // }\r\n\r\n // private set isSmooth(value: boolean) {\r\n // if (this.__isSmooth !== value) {\r\n // this.__isSmooth = value\r\n // this.updateClassName()\r\n // }\r\n // }\r\n\r\n get isScrolling() {\r\n return this.__isScrolling\r\n }\r\n\r\n private set isScrolling(value: boolean) {\r\n if (this.__isScrolling !== value) {\r\n this.__isScrolling = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isStopped() {\r\n return this.__isStopped\r\n }\r\n\r\n private set isStopped(value: boolean) {\r\n if (this.__isStopped !== value) {\r\n this.__isStopped = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isLocked() {\r\n return this.__isLocked\r\n }\r\n\r\n private set isLocked(value: boolean) {\r\n if (this.__isLocked !== value) {\r\n this.__isLocked = value\r\n this.updateClassName()\r\n }\r\n }\r\n\r\n get isSmooth() {\r\n return this.isScrolling === 'smooth'\r\n }\r\n\r\n get className() {\r\n let className = 'lenis'\r\n if (this.isStopped) className += ' lenis-stopped'\r\n if (this.isLocked) className += ' lenis-locked'\r\n if (this.isScrolling) className += ' lenis-scrolling'\r\n if (this.isScrolling === 'smooth') className += ' lenis-smooth'\r\n // if (this.isScrolling === 'native') className += ' lenis-native'\r\n // if (this.isSmooth) className += ' lenis-smooth'\r\n return className\r\n }\r\n\r\n private updateClassName() {\r\n this.cleanUpClassName()\r\n\r\n this.rootElement.className =\r\n `${this.rootElement.className} ${this.className}`.trim()\r\n // this.emitter.emit('className change', this)\r\n }\r\n\r\n private cleanUpClassName() {\r\n this.rootElement.className = this.rootElement.className\r\n .replace(/lenis(-\\w+)?/g, '')\r\n .trim()\r\n }\r\n\r\n // private toggleClassName(name: string, value: boolean) {\r\n // // this.rootElement.classList.toggle(name, value)\r\n // this.rootElement.className = this.className\r\n // this.emitter.emit('className change', this)\r\n // }\r\n}\r\n"],"names":["clamp","min","input","max","Math","Animate","advance","deltaTime","this","isRunning","completed","lerp","value","damp","x","y","lambda","dt","t","exp","to","round","currentTime","linearProgress","duration","easedProgress","easing","from","stop","onUpdate","fromTo","onStart","Dimensions","constructor","wrapper","content","autoResize","debounce","debounceValue","debouncedResize","callback","delay","timer","args","arguments","context","clearTimeout","setTimeout","apply","resize","window","addEventListener","wrapperResizeObserver","ResizeObserver","observe","contentResizeObserver","destroy","disconnect","removeEventListener","onWrapperResize","onContentResize","width","innerWidth","height","innerHeight","clientWidth","clientHeight","scrollHeight","scrollWidth","limit","Emitter","events","emit","event","callbacks","i","length","on","cb","push","filter","off","LINE_HEIGHT","VirtualScroll","element","wheelMultiplier","touchMultiplier","touchStart","emitter","onWindowResize","onWheel","passive","onTouchStart","onTouchMove","onTouchEnd","clientX","clientY","targetTouches","lastDelta","deltaX","deltaY","deltaMode","windowWidth","windowHeight","Lenis","document","documentElement","wheelEventsTarget","eventsTarget","smoothWheel","syncTouch","syncTouchLerp","touchInertiaMultiplier","pow","infinite","orientation","gestureOrientation","prevent","__experimental__naiveDimensions","__isScrolling","__isStopped","__isLocked","onVirtualScroll","ctrlKey","isTouch","type","includes","isWheel","isTouching","options","isStopped","isLocked","reset","isClick","isUnknownGesture","composedPath","slice","indexOf","rootElement","find","node","_a","hasAttribute","call","_b","_c","classList","_d","contains","_e","preventDefault","isScrolling","animate","delta","abs","hasTouchInertia","velocity","scrollTo","targetScroll","Object","assign","programmatic","onNativeScroll","__resetVelocityTimeout","__preventNextNativeScrollEvent","lastScroll","animatedScroll","actualScroll","lastVelocity","direction","sign","hasScrolled","lenisVersion","body","dimensions","updateClassName","userData","time","virtualScroll","cleanUpClassName","setScroll","scroll","isHorizontal","scrollLeft","scrollTop","start","raf","target","offset","immediate","lock","onComplete","force","querySelector","nodeType","wrapperRect","getBoundingClientRect","left","top","rect","modulo","n","d","progress","isSmooth","className","trim","replace"],"mappings":"AACO,SAASA,MAAMC,EAAKC,EAAOC,GAChC,OAAOC,KAAKD,IAAIF,EAAKG,KAAKH,IAAIC,EAAOC,GACvC,CCAO,MAAME,QAEX,OAAAC,CAAQC,GACN,IAAKC,KAAKC,UAAW,OAErB,IAAIC,GAAY,EAEhB,GAAIF,KAAKG,KACPH,KAAKI,MDKJ,SAASC,KAAKC,EAAGC,EAAGC,EAAQC,GACjC,OANK,SAASN,KAAKG,EAAGC,EAAGG,GACzB,OAAQ,EAAIA,GAAKJ,EAAII,EAAIH,CAC3B,CAISJ,CAAKG,EAAGC,EAAG,EAAIX,KAAKe,KAAKH,EAASC,GAC3C,CCPmBJ,CAAKL,KAAKI,MAAOJ,KAAKY,GAAgB,GAAZZ,KAAKG,KAAWJ,GACnDH,KAAKiB,MAAMb,KAAKI,SAAWJ,KAAKY,KAClCZ,KAAKI,MAAQJ,KAAKY,GAClBV,GAAY,OAET,CACLF,KAAKc,aAAef,EACpB,MAAMgB,EAAiBvB,MAAM,EAAGQ,KAAKc,YAAcd,KAAKgB,SAAU,GAElEd,EAAYa,GAAkB,EAC9B,MAAME,EAAgBf,EAAY,EAAIF,KAAKkB,OAAOH,GAClDf,KAAKI,MAAQJ,KAAKmB,MAAQnB,KAAKY,GAAKZ,KAAKmB,MAAQF,CAClD,CAEGf,GACFF,KAAKoB,OAIPpB,KAAKqB,WAAWrB,KAAKI,MAAOF,EAC7B,CAGD,IAA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