{"version":3,"file":"lenis.min.js","sources":["../src/maths.js","../../src/animate.ts","../../src/dimensions.ts","../src/debounce.js","../../src/emitter.ts","../../src/virtual-scroll.ts","../../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 isRunning: boolean = false\r\n value: number = 0\r\n from: number = 0\r\n to: number = 0\r\n lerp?: number\r\n duration?: number = 0\r\n easing?: Function\r\n currentTime: number = 0\r\n onUpdate?: Function\r\n\r\n // Advance the animation by the given delta time\r\n advance(deltaTime: number) {\r\n if (!this.isRunning) return\r\n\r\n let completed = false\r\n\r\n if (this.duration && this.easing) {\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 } else 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 // If no easing or lerp, just jump to the end value\r\n this.value = this.to\r\n completed = true\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: number,\r\n to: number,\r\n {\r\n lerp,\r\n duration,\r\n easing,\r\n onStart,\r\n onUpdate,\r\n }: {\r\n lerp?: number\r\n duration?: number\r\n easing?: Function\r\n onStart?: Function\r\n onUpdate?: Function\r\n }\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\ntype DimensionsOptions = {\r\n wrapper: Window | HTMLElement\r\n content: HTMLElement\r\n autoResize?: boolean\r\n debounce?: number\r\n}\r\n\r\nexport class Dimensions {\r\n wrapper: Window | HTMLElement\r\n content: HTMLElement\r\n width: number = 0\r\n height: number = 0\r\n scrollWidth: number = 0\r\n scrollHeight: number = 0\r\n debouncedResize?: Function\r\n wrapperResizeObserver?: ResizeObserver\r\n contentResizeObserver?: ResizeObserver\r\n\r\n // @ts-ignore\r\n constructor({\r\n wrapper,\r\n content,\r\n autoResize = true,\r\n debounce: debounceValue = 250,\r\n }: DimensionsOptions = {}) {\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(\r\n 'resize',\r\n this.debouncedResize as EventListener,\r\n false\r\n )\r\n } else {\r\n this.wrapperResizeObserver = new ResizeObserver(\r\n this.debouncedResize as ResizeObserverCallback\r\n )\r\n this.wrapperResizeObserver.observe(this.wrapper as HTMLElement)\r\n }\r\n\r\n this.contentResizeObserver = new ResizeObserver(\r\n this.debouncedResize as ResizeObserverCallback\r\n )\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(\r\n 'resize',\r\n this.debouncedResize as EventListener,\r\n false\r\n )\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 if (this.wrapper instanceof HTMLElement) {\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 if (this.wrapper instanceof HTMLElement) {\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 x: number\r\n y: number\r\n } {\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 events: Record\r\n\r\n constructor() {\r\n this.events = {}\r\n }\r\n\r\n emit(event: string, ...args: any[]) {\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: string, callback: Function) {\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(callback) || (this.events[event] = [callback])\r\n\r\n // Return an unsubscribe function\r\n return () => {\r\n this.events[event] = this.events[event]?.filter((i) => callback !== i)\r\n }\r\n }\r\n\r\n off(event: string, callback: Function) {\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 element: HTMLElement | Window\r\n wheelMultiplier: number\r\n touchMultiplier: number\r\n touchStart: {\r\n x: number | null\r\n y: number | null\r\n }\r\n emitter: Emitter\r\n lastDelta: {\r\n x: number\r\n y: number\r\n } = {\r\n x: 0,\r\n y: 0,\r\n }\r\n windowWidth: number = 0\r\n windowHeight: number = 0\r\n\r\n constructor(\r\n element: HTMLElement | Window,\r\n { wheelMultiplier = 1, touchMultiplier = 1 }\r\n ) {\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 as EventListener, {\r\n passive: false,\r\n })\r\n this.element.addEventListener(\r\n 'touchstart',\r\n this.onTouchStart as EventListener,\r\n {\r\n passive: false,\r\n }\r\n )\r\n this.element.addEventListener(\r\n 'touchmove',\r\n this.onTouchMove as EventListener,\r\n {\r\n passive: false,\r\n }\r\n )\r\n this.element.addEventListener(\r\n 'touchend',\r\n this.onTouchEnd as EventListener,\r\n {\r\n passive: false,\r\n }\r\n )\r\n }\r\n\r\n // Add an event listener for the given event and callback\r\n on(event: string, callback: Function) {\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 as EventListener)\r\n this.element.removeEventListener(\r\n 'touchstart',\r\n this.onTouchStart as EventListener\r\n )\r\n this.element.removeEventListener(\r\n 'touchmove',\r\n this.onTouchMove as EventListener\r\n )\r\n this.element.removeEventListener(\r\n 'touchend',\r\n this.onTouchEnd as EventListener\r\n )\r\n }\r\n\r\n // Event handler for 'touchstart' event\r\n onTouchStart = (event: TouchEvent) => {\r\n // @ts-expect-error\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: TouchEvent) => {\r\n // @ts-expect-error\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 ?? 0)) * this.touchMultiplier\r\n const deltaY = -(clientY - (this.touchStart?.y ?? 0)) * 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: TouchEvent) => {\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: WheelEvent) => {\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 Overwrite = Omit & R\r\n\r\ntype EasingFunction = (t: number) => number\r\ntype Orientation = 'vertical' | 'horizontal'\r\ntype GestureOrientation = 'vertical' | 'horizontal' | 'both'\r\ntype Scrolling = boolean | 'native' | 'smooth'\r\n\r\ntype onVirtualScrollOptions = {\r\n deltaX: number\r\n deltaY: number\r\n event: WheelEvent | TouchEvent\r\n}\r\n\r\nexport type LenisOptions = Partial<{\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: (node: Element) => boolean\r\n virtualScroll: (data: onVirtualScrollOptions) => 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: Scrolling = 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 __preventNextNativeScrollEvent?: boolean\r\n __resetVelocityTimeout?: number\r\n\r\n isTouching?: boolean\r\n time: number\r\n userData: Object = {}\r\n lastVelocity: number = 0\r\n velocity: number = 0\r\n direction: 1 | -1 | 0 = 0\r\n options: Overwrite<\r\n LenisOptions,\r\n {\r\n wrapper: NonNullable\r\n }\r\n >\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 = 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,\r\n virtualScroll,\r\n __experimental__naiveDimensions = false,\r\n }: LenisOptions = {}) {\r\n // @ts-expect-error\r\n window.lenisVersion = version\r\n\r\n // if wrapper is html or body, fallback to window\r\n if (\r\n !wrapper ||\r\n wrapper === document.documentElement ||\r\n wrapper === document.body\r\n ) {\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 virtualScroll,\r\n __experimental__naiveDimensions,\r\n } as LenisOptions\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.options.wrapper.addEventListener(\r\n 'pointerdown',\r\n this.onPointerDown as EventListener,\r\n false\r\n )\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 this.options.wrapper.removeEventListener(\r\n 'pointerdown',\r\n this.onPointerDown as EventListener,\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: number) {\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 onPointerDown = (event: PointerEvent | MouseEvent) => {\r\n if (event.button === 1) {\r\n this.reset()\r\n }\r\n }\r\n\r\n private onVirtualScroll = (data: onVirtualScrollOptions) => {\r\n if (\r\n typeof this.options.virtualScroll === 'function' &&\r\n this.options.virtualScroll(data) === false\r\n )\r\n return\r\n\r\n const { deltaX, deltaY, event } = data\r\n\r\n this.emitter.emit('virtual-scroll', { deltaX, deltaY, event })\r\n\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 node instanceof Element &&\r\n ((typeof prevent === 'function' && 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() {\r\n this.emitter.emit('scroll', this)\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(\r\n this.animatedScroll - lastScroll\r\n ) as Lenis['direction']\r\n // this.isSmooth = false\r\n this.isScrolling = 'native'\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 = 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 (\r\n typeof target === 'string' &&\r\n ['top', 'left', 'start'].includes(target)\r\n ) {\r\n target = 0\r\n } else if (\r\n typeof target === 'string' &&\r\n ['bottom', 'right', 'end'].includes(target)\r\n ) {\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 instanceof HTMLElement && 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.rootElement.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 (target === this.targetScroll) return\r\n\r\n this.userData = userData\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 this.preventNextNativeScrollEvent()\r\n this.emit()\r\n onComplete?.(this)\r\n this.userData = {}\r\n return\r\n }\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) as Lenis['direction']\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()\r\n\r\n if (completed) {\r\n this.reset()\r\n this.emit()\r\n onComplete?.(this)\r\n this.userData = {}\r\n\r\n // avoid emitting event twice\r\n this.preventNextNativeScrollEvent()\r\n }\r\n },\r\n })\r\n }\r\n\r\n private preventNextNativeScrollEvent() {\r\n this.__preventNextNativeScrollEvent = true\r\n\r\n requestAnimationFrame(() => {\r\n delete this.__preventNextNativeScrollEvent\r\n })\r\n }\r\n\r\n get rootElement() {\r\n return (\r\n this.options.wrapper === window\r\n ? document.documentElement\r\n : this.options.wrapper\r\n ) as HTMLElement\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: Scrolling) {\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 }\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"],"names":["clamp","min","input","max","Math","Animate","constructor","this","isRunning","value","from","to","duration","currentTime","advance","deltaTime","completed","easing","linearProgress","easedProgress","lerp","damp","x","y","lambda","dt","t","exp","round","stop","_a","onUpdate","call","fromTo","onStart","Dimensions","wrapper","content","autoResize","debounce","debounceValue","width","height","scrollWidth","scrollHeight","resize","onWrapperResize","onContentResize","window","innerWidth","innerHeight","HTMLElement","clientWidth","clientHeight","debouncedResize","callback","delay","timer","args","arguments","context","clearTimeout","setTimeout","apply","addEventListener","wrapperResizeObserver","ResizeObserver","observe","contentResizeObserver","destroy","disconnect","_b","removeEventListener","limit","Emitter","events","emit","event","callbacks","i","length","on","push","filter","off","LINE_HEIGHT","VirtualScroll","element","wheelMultiplier","touchMultiplier","lastDelta","windowWidth","windowHeight","onTouchStart","clientX","clientY","targetTouches","touchStart","emitter","deltaX","deltaY","onTouchMove","_d","_c","onTouchEnd","onWheel","deltaMode","onWindowResize","passive","Lenis","document","documentElement","wheelEventsTarget","eventsTarget","smoothWheel","syncTouch","syncTouchLerp","touchInertiaMultiplier","pow","infinite","orientation","gestureOrientation","prevent","virtualScroll","__experimental__naiveDimensions","__isScrolling","__isStopped","__isLocked","userData","lastVelocity","velocity","direction","onPointerDown","button","reset","onVirtualScroll","data","options","ctrlKey","isTouch","type","includes","isWheel","isTouching","isStopped","isLocked","isClick","isUnknownGesture","composedPath","slice","indexOf","rootElement","find","node","Element","hasAttribute","classList","contains","_e","preventDefault","isScrolling","animate","delta","abs","hasTouchInertia","scrollTo","targetScroll","Object","assign","programmatic","onNativeScroll","__resetVelocityTimeout","__preventNextNativeScrollEvent","lastScroll","animatedScroll","actualScroll","sign","lenisVersion","body","dimensions","updateClassName","time","cleanUpClassName","setScroll","scroll","isHorizontal","scrollLeft","scrollTop","start","raf","target","offset","immediate","lock","onComplete","force","querySelector","nodeType","wrapperRect","getBoundingClientRect","left","top","rect","preventNextNativeScrollEvent","requestAnimationFrame","modulo","n","d","progress","isSmooth","className","trim","replace"],"mappings":"sOACO,SAASA,MAAMC,EAAKC,EAAOC,GAChC,OAAOC,KAAKD,IAAIF,EAAKG,KAAKH,IAAIC,EAAOC,GACvC,OCAaE,QAAb,WAAAC,GACEC,KAASC,WAAY,EACrBD,KAAKE,MAAW,EAChBF,KAAIG,KAAW,EACfH,KAAEI,GAAW,EAEbJ,KAAQK,SAAY,EAEpBL,KAAWM,YAAW,CAuEvB,CAnEC,OAAAC,CAAQC,SACN,IAAKR,KAAKC,UAAW,OAErB,IAAIQ,GAAY,EAEhB,GAAIT,KAAKK,UAAYL,KAAKU,OAAQ,CAChCV,KAAKM,aAAeE,EACpB,MAAMG,EAAiBlB,MAAM,EAAGO,KAAKM,YAAcN,KAAKK,SAAU,GAElEI,EAAYE,GAAkB,EAC9B,MAA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