lenis
Version:
How smooth scroll should be
1 lines • 63.8 kB
Source Map (JSON)
{"version":3,"file":"lenis.mjs","names":[],"sources":["../package.json","../packages/core/src/maths.ts","../packages/core/src/animate.ts","../packages/core/src/debounce.ts","../packages/core/src/dimensions.ts","../packages/core/src/emitter.ts","../packages/core/src/virtual-scroll.ts","../packages/core/src/lenis.ts"],"sourcesContent":["","/**\n * Clamp a value between a minimum and maximum value\n *\n * @param min Minimum value\n * @param input Value to clamp\n * @param max Maximum value\n * @returns Clamped value\n */\nexport function clamp(min: number, input: number, max: number) {\n return Math.max(min, Math.min(input, max))\n}\n\n/**\n * Truncate a floating-point number to a specified number of decimal places\n *\n * @param value Value to truncate\n * @param decimals Number of decimal places to truncate to\n * @returns Truncated value\n */\nexport function truncate(value: number, decimals = 0) {\n return Number.parseFloat(value.toFixed(decimals))\n}\n\n/**\n * Linearly interpolate between two values using an amount (0 <= t <= 1)\n *\n * @param x First value\n * @param y Second value\n * @param t Amount to interpolate (0 <= t <= 1)\n * @returns Interpolated value\n */\nexport function lerp(x: number, y: number, t: number) {\n return (1 - t) * x + t * y\n}\n\n/**\n * Damp a value over time using a damping factor\n * {@link http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/}\n *\n * @param x Initial value\n * @param y Target value\n * @param lambda Damping factor\n * @param dt Time elapsed since the last update\n * @returns Damped value\n */\nexport function damp(x: number, y: number, lambda: number, deltaTime: number) {\n return lerp(x, y, 1 - Math.exp(-lambda * deltaTime))\n}\n\n/**\n * Calculate the modulo of the dividend and divisor while keeping the result within the same sign as the divisor\n * {@link https://anguscroll.com/just/just-modulo}\n *\n * @param n Dividend\n * @param d Divisor\n * @returns Modulo\n */\nexport function modulo(n: number, d: number) {\n return ((n % d) + d) % d\n}\n","import { clamp, damp } from './maths'\nimport type { EasingFunction, FromToOptions, OnUpdateCallback } from './types'\n\n/**\n * Animate class to handle value animations with lerping or easing\n *\n * @example\n * const animate = new Animate()\n * animate.fromTo(0, 100, { duration: 1, easing: (t) => t })\n * animate.advance(0.5) // 50\n */\nexport class Animate {\n isRunning = false\n value = 0\n from = 0\n to = 0\n currentTime = 0\n\n // These are instanciated in the fromTo method\n lerp?: number\n duration?: number\n easing?: EasingFunction\n onUpdate?: OnUpdateCallback\n\n /**\n * Advance the animation by the given delta time\n *\n * @param deltaTime - The time in seconds to advance the animation\n */\n advance(deltaTime: number) {\n if (!this.isRunning) return\n\n let completed = false\n\n if (this.duration && this.easing) {\n this.currentTime += deltaTime\n const linearProgress = clamp(0, this.currentTime / this.duration, 1)\n\n completed = linearProgress >= 1\n const easedProgress = completed ? 1 : this.easing(linearProgress)\n this.value = this.from + (this.to - this.from) * easedProgress\n } else if (this.lerp) {\n this.value = damp(this.value, this.to, this.lerp * 60, deltaTime)\n if (Math.round(this.value) === Math.round(this.to)) {\n this.value = this.to\n completed = true\n }\n } else {\n // If no easing or lerp, just jump to the end value\n this.value = this.to\n completed = true\n }\n\n if (completed) {\n this.stop()\n }\n\n // Call the onUpdate callback with the current value and completed status\n this.onUpdate?.(this.value, completed)\n }\n\n /** Stop the animation */\n stop() {\n this.isRunning = false\n }\n\n /**\n * Set up the animation from a starting value to an ending value\n * with optional parameters for lerping, duration, easing, and onUpdate callback\n *\n * @param from - The starting value\n * @param to - The ending value\n * @param options - Options for the animation\n */\n fromTo(\n from: number,\n to: number,\n { lerp, duration, easing, onStart, onUpdate }: FromToOptions\n ) {\n this.from = this.value = from\n this.to = to\n this.lerp = lerp\n this.duration = duration\n this.easing = easing\n this.currentTime = 0\n this.isRunning = true\n\n onStart?.()\n this.onUpdate = onUpdate\n }\n}\n","export function debounce<CB extends (...args: unknown[]) => void>(\n callback: CB,\n delay: number\n) {\n let timer: number | undefined\n return function <T>(this: T, ...args: Parameters<typeof callback>) {\n clearTimeout(timer)\n timer = setTimeout(() => {\n timer = undefined\n callback.apply(this, args)\n }, delay)\n }\n}\n","import { debounce } from './debounce'\n\n/**\n * Dimensions class to handle the size of the content and wrapper\n *\n * @example\n * const dimensions = new Dimensions(wrapper, content)\n * dimensions.on('resize', (e) => {\n * console.log(e.width, e.height)\n * })\n */\nexport class Dimensions {\n width = 0\n height = 0\n scrollHeight = 0\n scrollWidth = 0\n\n // These are instanciated in the constructor as they need information from the options\n private debouncedResize?: (...args: unknown[]) => void\n private wrapperResizeObserver?: ResizeObserver\n private contentResizeObserver?: ResizeObserver\n\n constructor(\n private wrapper: HTMLElement | Window | Element,\n private content: HTMLElement | Element,\n { autoResize = true, debounce: debounceValue = 250 } = {}\n ) {\n if (autoResize) {\n this.debouncedResize = debounce(this.resize, debounceValue)\n\n if (this.wrapper instanceof Window) {\n window.addEventListener('resize', this.debouncedResize)\n } else {\n this.wrapperResizeObserver = new ResizeObserver(this.debouncedResize)\n this.wrapperResizeObserver.observe(this.wrapper)\n }\n\n this.contentResizeObserver = new ResizeObserver(this.debouncedResize)\n this.contentResizeObserver.observe(this.content)\n }\n\n this.resize()\n }\n\n destroy() {\n this.wrapperResizeObserver?.disconnect()\n this.contentResizeObserver?.disconnect()\n\n if (this.wrapper === window && this.debouncedResize) {\n window.removeEventListener('resize', this.debouncedResize)\n }\n }\n\n resize = () => {\n this.onWrapperResize()\n this.onContentResize()\n }\n\n onWrapperResize = () => {\n if (this.wrapper instanceof Window) {\n this.width = window.innerWidth\n this.height = window.innerHeight\n } else {\n this.width = this.wrapper.clientWidth\n this.height = this.wrapper.clientHeight\n }\n }\n\n onContentResize = () => {\n if (this.wrapper instanceof Window) {\n this.scrollHeight = this.content.scrollHeight\n this.scrollWidth = this.content.scrollWidth\n } else {\n this.scrollHeight = this.wrapper.scrollHeight\n this.scrollWidth = this.wrapper.scrollWidth\n }\n }\n\n get limit() {\n return {\n x: this.scrollWidth - this.width,\n y: this.scrollHeight - this.height,\n }\n }\n}\n","/**\n * Emitter class to handle events\n * @example\n * const emitter = new Emitter()\n * emitter.on('event', (data) => {\n * console.log(data)\n * })\n * emitter.emit('event', 'data')\n */\nexport class Emitter {\n private events: Record<\n string,\n Array<(...args: unknown[]) => void> | undefined\n > = {}\n\n /**\n * Emit an event with the given data\n * @param event Event name\n * @param args Data to pass to the event handlers\n */\n emit(event: string, ...args: unknown[]) {\n const callbacks = this.events[event] || []\n for (let i = 0, length = callbacks.length; i < length; i++) {\n callbacks[i]?.(...args)\n }\n }\n\n /**\n * Add a callback to the event\n * @param event Event name\n * @param cb Callback function\n * @returns Unsubscribe function\n */\n on<CB extends (...args: unknown[]) => void>(event: string, cb: CB) {\n // Add the callback to the event's callback list, or create a new list with the callback\n if (this.events[event]) {\n this.events[event].push(cb)\n } else {\n this.events[event] = [cb]\n }\n\n // Return an unsubscribe function\n return () => {\n this.events[event] = this.events[event]?.filter((i) => cb !== i)\n }\n }\n\n /**\n * Remove a callback from the event\n * @param event Event name\n * @param callback Callback function\n */\n off<CB extends (...args: unknown[]) => void>(event: string, callback: CB) {\n this.events[event] = this.events[event]?.filter((i) => callback !== i)\n }\n\n /**\n * Remove all event listeners and clean up\n */\n destroy() {\n this.events = {}\n }\n}\n","import { Emitter } from './emitter'\nimport type { VirtualScrollCallback } from './types'\n\nconst LINE_HEIGHT = 100 / 6\nconst listenerOptions: AddEventListenerOptions = { passive: false }\n\nfunction getDeltaMultiplier(deltaMode: number, size: number): number {\n if (deltaMode === 1) return LINE_HEIGHT\n if (deltaMode === 2) return size\n return 1\n}\n\nexport class VirtualScroll {\n touchStart = {\n x: 0,\n y: 0,\n }\n lastDelta = {\n x: 0,\n y: 0,\n }\n window = {\n width: 0,\n height: 0,\n }\n private emitter = new Emitter()\n\n constructor(\n private element: HTMLElement,\n private options = { wheelMultiplier: 1, touchMultiplier: 1 }\n ) {\n window.addEventListener('resize', this.onWindowResize)\n this.onWindowResize()\n\n this.element.addEventListener('wheel', this.onWheel, listenerOptions)\n this.element.addEventListener(\n 'touchstart',\n this.onTouchStart,\n listenerOptions\n )\n this.element.addEventListener(\n 'touchmove',\n this.onTouchMove,\n listenerOptions\n )\n this.element.addEventListener('touchend', this.onTouchEnd, listenerOptions)\n }\n\n /**\n * Add an event listener for the given event and callback\n *\n * @param event Event name\n * @param callback Callback function\n */\n on(event: string, callback: VirtualScrollCallback) {\n return this.emitter.on(event, callback as (...args: unknown[]) => void)\n }\n\n /** Remove all event listeners and clean up */\n destroy() {\n this.emitter.destroy()\n\n window.removeEventListener('resize', this.onWindowResize)\n\n this.element.removeEventListener('wheel', this.onWheel, listenerOptions)\n this.element.removeEventListener(\n 'touchstart',\n this.onTouchStart,\n listenerOptions\n )\n this.element.removeEventListener(\n 'touchmove',\n this.onTouchMove,\n listenerOptions\n )\n this.element.removeEventListener(\n 'touchend',\n this.onTouchEnd,\n listenerOptions\n )\n }\n\n /**\n * Event handler for 'touchstart' event\n *\n * @param event Touch event\n */\n onTouchStart = (event: TouchEvent) => {\n // @ts-expect-error - event.targetTouches is not defined\n const { clientX, clientY } = event.targetTouches\n ? event.targetTouches[0]\n : event\n\n this.touchStart.x = clientX\n this.touchStart.y = clientY\n\n this.lastDelta = {\n x: 0,\n y: 0,\n }\n\n this.emitter.emit('scroll', {\n deltaX: 0,\n deltaY: 0,\n event,\n })\n }\n\n /** Event handler for 'touchmove' event */\n onTouchMove = (event: TouchEvent) => {\n // @ts-expect-error - event.targetTouches is not defined\n const { clientX, clientY } = event.targetTouches\n ? event.targetTouches[0]\n : event\n\n const deltaX = -(clientX - this.touchStart.x) * this.options.touchMultiplier\n const deltaY = -(clientY - this.touchStart.y) * this.options.touchMultiplier\n\n this.touchStart.x = clientX\n this.touchStart.y = clientY\n\n this.lastDelta = {\n x: deltaX,\n y: deltaY,\n }\n\n this.emitter.emit('scroll', {\n deltaX,\n deltaY,\n event,\n })\n }\n\n onTouchEnd = (event: TouchEvent) => {\n this.emitter.emit('scroll', {\n deltaX: this.lastDelta.x,\n deltaY: this.lastDelta.y,\n event,\n })\n }\n\n /** Event handler for 'wheel' event */\n onWheel = (event: WheelEvent) => {\n let { deltaX, deltaY, deltaMode } = event\n\n const multiplierX = getDeltaMultiplier(deltaMode, this.window.width)\n const multiplierY = getDeltaMultiplier(deltaMode, this.window.height)\n\n deltaX *= multiplierX\n deltaY *= multiplierY\n\n deltaX *= this.options.wheelMultiplier\n deltaY *= this.options.wheelMultiplier\n\n this.emitter.emit('scroll', { deltaX, deltaY, event })\n }\n\n onWindowResize = () => {\n this.window = {\n width: window.innerWidth,\n height: window.innerHeight,\n }\n }\n}\n","import { version } from '../../../package.json'\nimport { Animate } from './animate'\nimport { Dimensions } from './dimensions'\nimport { Emitter } from './emitter'\nimport { clamp, modulo } from './maths'\nimport type {\n LenisEvent,\n LenisOptions,\n ScrollCallback,\n Scrolling,\n ScrollToOptions,\n UserData,\n VirtualScrollCallback,\n VirtualScrollData,\n} from './types'\nimport { VirtualScroll } from './virtual-scroll'\n\n// Technical explanation\n// - listen to 'wheel' events\n// - prevent 'wheel' event to prevent scroll\n// - normalize wheel delta\n// - add delta to targetScroll\n// - animate scroll to targetScroll (smooth context)\n// - if animation is not running, listen to 'scroll' events (native context)\n\ntype OptionalPick<T, F extends keyof T> = Omit<T, F> & Partial<Pick<T, F>>\n\nconst defaultEasing = (t: number) => Math.min(1, 1.001 - 2 ** (-10 * t))\n\nexport class Lenis {\n private _isScrolling: Scrolling = false // true when scroll is animating\n private _isStopped = false // true if user should not be able to scroll - enable/disable programmatically\n private _isLocked = false // same as isStopped but enabled/disabled when scroll reaches target\n private _preventNextNativeScrollEvent = false\n private _resetVelocityTimeout: ReturnType<typeof setTimeout> | null = null\n private _rafId: number | null = null\n private _isDraggingSelection = false // true while a touch is dragging an iOS selection handle\n\n /**\n * Whether or not the user is touching the screen\n */\n isTouching?: boolean\n /**\n * Whether or not the device is running iOS\n */\n isIos: boolean\n /**\n * The time in ms since the lenis instance was created\n */\n time = 0\n /**\n * User data that will be forwarded through the scroll event\n *\n * @example\n * lenis.scrollTo(100, {\n * userData: {\n * foo: 'bar'\n * }\n * })\n */\n userData: UserData = {}\n /**\n * The last velocity of the scroll\n */\n lastVelocity = 0\n /**\n * The current velocity of the scroll\n */\n velocity = 0\n /**\n * The direction of the scroll\n */\n direction: 1 | -1 | 0 = 0\n /**\n * The options passed to the lenis instance\n */\n options: OptionalPick<\n Required<LenisOptions>,\n | 'duration'\n | 'easing'\n | 'prevent'\n | 'virtualScroll'\n | '__experimental__naiveDimensions'\n >\n /**\n * The target scroll value\n */\n targetScroll: number\n /**\n * The animated scroll value\n */\n animatedScroll: number\n\n // These are instanciated here as they don't need information from the options\n private readonly animate = new Animate()\n private readonly emitter = new Emitter()\n // These are instanciated in the constructor as they need information from the options\n readonly dimensions: Dimensions // This is not private because it's used in the Snap class\n private readonly virtualScroll: VirtualScroll\n\n constructor({\n wrapper = window,\n content = document.documentElement,\n eventsTarget = wrapper,\n smoothWheel = true,\n syncTouch = false,\n syncTouchLerp = 0.075,\n touchInertiaExponent = 1.7,\n duration, // in seconds\n easing,\n lerp = 0.1,\n infinite = false,\n orientation = 'vertical', // vertical, horizontal\n gestureOrientation = orientation === 'horizontal' ? 'both' : 'vertical', // vertical, horizontal, both\n touchMultiplier = 1,\n wheelMultiplier = 1,\n autoResize = true,\n prevent,\n virtualScroll,\n overscroll = true,\n autoRaf = false,\n anchors = false,\n autoToggle = false, // https://caniuse.com/?search=transition-behavior\n allowNestedScroll = false,\n __experimental__naiveDimensions = false,\n naiveDimensions = __experimental__naiveDimensions,\n stopInertiaOnNavigate = false,\n }: LenisOptions = {}) {\n // Set version (deprecated)\n window.lenisVersion = version\n\n if (!window.lenis) {\n window.lenis = {}\n }\n\n window.lenis.version = version\n\n if (orientation === 'horizontal') {\n window.lenis.horizontal = true\n }\n\n if (syncTouch === true) {\n window.lenis.touch = true\n }\n\n this.isIos = /(iPad|iPhone|iPod)/g.test(navigator.userAgent)\n\n // Check if wrapper is <html>, fallback to window\n if (!wrapper || wrapper === document.documentElement) {\n wrapper = window\n }\n\n // flip to easing/time based animation if at least one of them is provided\n if (typeof duration === 'number' && typeof easing !== 'function') {\n easing = defaultEasing\n } else if (typeof easing === 'function' && typeof duration !== 'number') {\n duration = 1\n }\n\n // Setup options\n this.options = {\n wrapper,\n content,\n eventsTarget,\n smoothWheel,\n syncTouch,\n syncTouchLerp,\n touchInertiaExponent,\n duration,\n easing,\n lerp,\n infinite,\n gestureOrientation,\n orientation,\n touchMultiplier,\n wheelMultiplier,\n autoResize,\n prevent,\n virtualScroll,\n overscroll,\n autoRaf,\n anchors,\n autoToggle,\n allowNestedScroll,\n naiveDimensions,\n stopInertiaOnNavigate,\n }\n\n // Setup dimensions instance\n this.dimensions = new Dimensions(wrapper, content, { autoResize })\n\n // Setup class name\n this.updateClassName()\n\n // Set the initial scroll value for all scroll information\n this.targetScroll = this.animatedScroll = this.actualScroll\n\n // Add event listeners\n this.options.wrapper.addEventListener('scroll', this.onNativeScroll)\n\n this.options.wrapper.addEventListener('scrollend', this.onScrollEnd, {\n capture: true,\n })\n\n if (this.options.anchors || this.options.stopInertiaOnNavigate) {\n this.options.wrapper.addEventListener(\n 'click',\n this.onClick as EventListener\n )\n }\n\n this.options.wrapper.addEventListener(\n 'pointerdown',\n this.onPointerDown as EventListener\n )\n\n // Setup virtual scroll instance\n this.virtualScroll = new VirtualScroll(eventsTarget as HTMLElement, {\n touchMultiplier,\n wheelMultiplier,\n })\n this.virtualScroll.on('scroll', this.onVirtualScroll)\n\n if (this.options.autoToggle) {\n this.checkOverflow()\n this.rootElement.addEventListener('transitionend', this.onTransitionEnd)\n }\n\n if (this.options.autoRaf) {\n this._rafId = requestAnimationFrame(this.raf)\n }\n }\n\n /**\n * Destroy the lenis instance, remove all event listeners and clean up the class name\n */\n destroy() {\n this.emitter.destroy()\n\n this.options.wrapper.removeEventListener('scroll', this.onNativeScroll)\n\n this.options.wrapper.removeEventListener('scrollend', this.onScrollEnd, {\n capture: true,\n })\n\n this.options.wrapper.removeEventListener(\n 'pointerdown',\n this.onPointerDown as EventListener\n )\n\n if (this.options.anchors || this.options.stopInertiaOnNavigate) {\n this.options.wrapper.removeEventListener(\n 'click',\n this.onClick as EventListener\n )\n }\n\n this.virtualScroll.destroy()\n this.dimensions.destroy()\n\n this.cleanUpClassName()\n\n if (this._rafId) {\n cancelAnimationFrame(this._rafId)\n }\n }\n\n /**\n * Add an event listener for the given event and callback\n *\n * @param event Event name\n * @param callback Callback function\n * @returns Unsubscribe function\n */\n on(event: 'scroll', callback: ScrollCallback): () => void\n on(event: 'virtual-scroll', callback: VirtualScrollCallback): () => void\n on(event: LenisEvent, callback: ScrollCallback | VirtualScrollCallback) {\n return this.emitter.on(event, callback as (...args: unknown[]) => void)\n }\n\n /**\n * Remove an event listener for the given event and callback\n *\n * @param event Event name\n * @param callback Callback function\n */\n off(event: 'scroll', callback: ScrollCallback): void\n off(event: 'virtual-scroll', callback: VirtualScrollCallback): void\n off(event: LenisEvent, callback: ScrollCallback | VirtualScrollCallback) {\n return this.emitter.off(event, callback as (...args: unknown[]) => void)\n }\n\n private onScrollEnd = (e: Event | CustomEvent) => {\n if (!(e instanceof CustomEvent)) {\n if (this.isScrolling === 'smooth' || this.isScrolling === false) {\n e.stopPropagation()\n }\n }\n }\n\n private dispatchScrollendEvent = () => {\n this.options.wrapper.dispatchEvent(\n new CustomEvent('scrollend', {\n bubbles: this.options.wrapper === window,\n // cancelable: false,\n detail: {\n lenisScrollEnd: true,\n },\n })\n )\n }\n\n get overflow() {\n const property = this.isHorizontal ? 'overflow-x' : 'overflow-y'\n return getComputedStyle(this.rootElement)[\n property as keyof CSSStyleDeclaration\n ] as string\n }\n\n private checkOverflow() {\n if (['hidden', 'clip'].includes(this.overflow)) {\n this.internalStop()\n } else {\n this.internalStart()\n }\n }\n\n private onTransitionEnd = (event: TransitionEvent) => {\n if (\n event.propertyName?.includes('overflow') &&\n event.target === this.rootElement\n ) {\n this.checkOverflow()\n }\n }\n\n private setScroll(scroll: number) {\n // behavior: 'instant' bypasses the scroll-behavior CSS property\n\n if (this.isHorizontal) {\n this.options.wrapper.scrollTo({ left: scroll, behavior: 'instant' })\n } else {\n this.options.wrapper.scrollTo({ top: scroll, behavior: 'instant' })\n }\n }\n\n private onClick = (event: PointerEvent | MouseEvent) => {\n const path = event.composedPath()\n\n // filter anchor elements (elements with a valid href attribute)\n const linkElements = path.filter(\n (node) => node instanceof HTMLAnchorElement && node.href\n ) as HTMLAnchorElement[]\n const linkElementsUrls = linkElements.map(\n (element) => new URL(element.href)\n )\n\n const currentUrl = new URL(window.location.href)\n\n if (this.options.anchors) {\n const anchorElementUrl = linkElementsUrls.find(\n (targetUrl) =>\n currentUrl.host === targetUrl.host &&\n currentUrl.pathname === targetUrl.pathname &&\n targetUrl.hash\n )\n\n if (anchorElementUrl) {\n const options =\n typeof this.options.anchors === 'object' && this.options.anchors\n ? this.options.anchors\n : undefined\n\n // hash is URL-encoded (e.g. `#footnote-%E2%80%A0`); decode so it\n // matches the raw HTML id in scrollTo's getElementById\n const target = decodeURIComponent(anchorElementUrl.hash)\n\n this.scrollTo(target, options)\n return\n }\n }\n\n if (this.options.stopInertiaOnNavigate) {\n const hasPageLinkElementUrl = linkElementsUrls.some(\n (targetUrl) =>\n currentUrl.host === targetUrl.host &&\n currentUrl.pathname !== targetUrl.pathname\n )\n\n if (hasPageLinkElementUrl) {\n this.reset()\n return\n }\n }\n }\n\n private onPointerDown = (event: PointerEvent | MouseEvent) => {\n if (event.button === 1) {\n this.reset()\n }\n }\n\n // iOS renders text-selection handles at the start and end points of the\n // selection. A touch starting within a handle-sized radius of either point is\n // the user grabbing a handle, not scrolling.\n private isTouchOnSelectionHandle(event: TouchEvent) {\n const selection = window.getSelection()\n if (!selection || selection.isCollapsed || selection.rangeCount === 0)\n return false\n\n const touch = event.targetTouches[0] ?? event.changedTouches[0]\n if (!touch) return false\n\n const rects = selection.getRangeAt(0).getClientRects()\n if (rects.length === 0) return false\n\n const first = rects[0]!\n const last = rects[rects.length - 1]!\n const HANDLE_RADIUS = 40 // px — handles are large, finger-sized touch targets\n\n const nearStart =\n Math.hypot(touch.clientX - first.left, touch.clientY - first.top) <=\n HANDLE_RADIUS\n const nearEnd =\n Math.hypot(touch.clientX - last.right, touch.clientY - last.bottom) <=\n HANDLE_RADIUS\n\n return nearStart || nearEnd\n }\n\n private onVirtualScroll = (data: VirtualScrollData) => {\n if (\n typeof this.options.virtualScroll === 'function' &&\n this.options.virtualScroll(data) === false\n )\n return\n\n const { deltaX, deltaY, event } = data\n\n this.emitter.emit('virtual-scroll', { deltaX, deltaY, event })\n\n // keep zoom feature\n if (event.ctrlKey) return\n // @ts-expect-error\n if (event.lenisStopPropagation) return\n\n const isTouch = event.type.includes('touch')\n const isWheel = event.type.includes('wheel')\n\n // If the touch grabbed an iOS text-selection handle, let the OS adjust the\n // selection instead of scrolling. Latched on touchstart, held until touchend.\n if (isTouch && this.isIos) {\n if (event.type === 'touchstart') {\n this._isDraggingSelection = this.isTouchOnSelectionHandle(\n event as TouchEvent\n )\n }\n if (this._isDraggingSelection) {\n if (event.type === 'touchend') this._isDraggingSelection = false\n return\n }\n }\n\n this.isTouching = event.type === 'touchstart' || event.type === 'touchmove'\n\n const isClickOrTap = deltaX === 0 && deltaY === 0\n\n const isTapToStop =\n this.options.syncTouch &&\n isTouch &&\n event.type === 'touchstart' &&\n isClickOrTap &&\n !this.isStopped &&\n !this.isLocked\n\n if (isTapToStop) {\n this.reset()\n return\n }\n\n // const isPullToRefresh =\n // this.options.gestureOrientation === 'vertical' &&\n // this.scroll === 0 &&\n // !this.options.infinite &&\n // deltaY <= 5 // touch pull to refresh, not reliable yet\n\n // most likely a touchpad gesture, this keep prev/next page navigation working\n const isUnknownGesture =\n (this.options.gestureOrientation === 'vertical' && deltaY === 0) ||\n (this.options.gestureOrientation === 'horizontal' && deltaX === 0)\n\n if (isClickOrTap || isUnknownGesture) {\n return\n }\n\n // catch if scrolling on nested scroll elements\n let composedPath = event.composedPath()\n composedPath = composedPath.slice(0, composedPath.indexOf(this.rootElement)) // remove parents elements\n\n const prevent = this.options.prevent\n\n const gestureOrientation =\n Math.abs(deltaX) >= Math.abs(deltaY) ? 'horizontal' : 'vertical'\n\n if (\n composedPath.find(\n (node) =>\n node instanceof HTMLElement &&\n ((typeof prevent === 'function' && prevent?.(node)) ||\n node.hasAttribute?.('data-lenis-prevent') ||\n (gestureOrientation === 'vertical' &&\n node.hasAttribute?.('data-lenis-prevent-vertical')) ||\n (gestureOrientation === 'horizontal' &&\n node.hasAttribute?.('data-lenis-prevent-horizontal')) ||\n (isTouch && node.hasAttribute?.('data-lenis-prevent-touch')) ||\n (isWheel && node.hasAttribute?.('data-lenis-prevent-wheel')) ||\n (this.options.allowNestedScroll &&\n this.hasNestedScroll(node, {\n deltaX,\n deltaY,\n })))\n )\n )\n return\n\n if (this.isStopped || this.isLocked) {\n if (event.cancelable) {\n event.preventDefault() // this will stop forwarding the event to the parent, this is problematic\n }\n return\n }\n\n const isSmooth =\n (this.options.syncTouch && isTouch) ||\n (this.options.smoothWheel && isWheel)\n\n if (!isSmooth) {\n this.isScrolling = 'native'\n this.animate.stop()\n // @ts-expect-error\n event.lenisStopPropagation = true\n return\n }\n\n let delta = deltaY\n if (this.options.gestureOrientation === 'both') {\n delta = Math.abs(deltaY) > Math.abs(deltaX) ? deltaY : deltaX\n } else if (this.options.gestureOrientation === 'horizontal') {\n delta = deltaX\n }\n\n if (\n !this.options.overscroll ||\n this.options.infinite ||\n (this.options.wrapper !== window &&\n this.limit > 0 &&\n ((this.animatedScroll > 0 && this.animatedScroll < this.limit) ||\n (this.animatedScroll === 0 && deltaY > 0) ||\n (this.animatedScroll === this.limit && deltaY < 0)))\n ) {\n // @ts-expect-error\n event.lenisStopPropagation = true\n // event.stopPropagation()\n }\n\n if (event.cancelable) {\n event.preventDefault()\n }\n\n const isSyncTouch = isTouch && this.options.syncTouch\n const isTouchEnd = isTouch && event.type === 'touchend'\n\n const hasTouchInertia = isTouchEnd\n\n if (hasTouchInertia) {\n delta =\n Math.sign(delta) *\n Math.abs(this.velocity) ** this.options.touchInertiaExponent\n }\n\n this.scrollTo(this.targetScroll + delta, {\n programmatic: false,\n ...(isSyncTouch\n ? {\n lerp: hasTouchInertia ? this.options.syncTouchLerp : 1,\n }\n : {\n lerp: this.options.lerp,\n duration: this.options.duration,\n easing: this.options.easing,\n }),\n })\n }\n\n /**\n * Force lenis to recalculate the dimensions\n */\n resize() {\n this.dimensions.resize()\n this.animatedScroll = this.targetScroll = this.actualScroll\n this.emit()\n }\n\n private emit() {\n this.emitter.emit('scroll', this)\n }\n\n private onNativeScroll = () => {\n if (this._resetVelocityTimeout !== null) {\n clearTimeout(this._resetVelocityTimeout)\n this._resetVelocityTimeout = null\n }\n\n if (this._preventNextNativeScrollEvent) {\n this._preventNextNativeScrollEvent = false\n return\n }\n\n if (this.isScrolling === false || this.isScrolling === 'native') {\n const lastScroll = this.animatedScroll\n this.animatedScroll = this.targetScroll = this.actualScroll\n this.lastVelocity = this.velocity\n this.velocity = this.animatedScroll - lastScroll\n this.direction = Math.sign(\n this.animatedScroll - lastScroll\n ) as Lenis['direction']\n\n if (!this.isStopped) {\n this.isScrolling = 'native'\n }\n\n this.emit()\n\n if (this.velocity !== 0) {\n this._resetVelocityTimeout = setTimeout(() => {\n this.lastVelocity = this.velocity\n this.velocity = 0\n this.isScrolling = false\n this.emit()\n }, 400)\n }\n }\n }\n\n private reset() {\n this.isLocked = false\n this.isScrolling = false\n this.animatedScroll = this.targetScroll = this.actualScroll\n this.lastVelocity = this.velocity = 0\n this.animate.stop()\n }\n\n /**\n * Start lenis scroll after it has been stopped\n */\n start() {\n if (!this.isStopped) return\n\n if (this.options.autoToggle) {\n this.rootElement.style.removeProperty('overflow')\n return\n }\n\n this.internalStart()\n }\n\n private internalStart() {\n if (!this.isStopped) return\n\n this.reset()\n this.isStopped = false\n this.emit()\n }\n\n /**\n * Stop lenis scroll\n */\n stop() {\n if (this.isStopped) return\n\n if (this.options.autoToggle) {\n this.rootElement.style.setProperty('overflow', 'clip')\n return\n }\n\n this.internalStop()\n }\n\n private internalStop() {\n if (this.isStopped) return\n\n this.reset()\n this.isStopped = true\n this.emit()\n }\n\n /**\n * RequestAnimationFrame for lenis\n *\n * @param time The time in ms from an external clock like `requestAnimationFrame` or Tempus\n */\n raf = (time: number) => {\n const deltaTime = time - (this.time || time)\n this.time = time\n\n this.animate.advance(deltaTime * 0.001)\n\n if (this.options.autoRaf) {\n this._rafId = requestAnimationFrame(this.raf)\n }\n }\n\n /**\n * Scroll to a target value\n *\n * @param target The target value to scroll to\n * @param options The options for the scroll\n *\n * @example\n * lenis.scrollTo(100, {\n * offset: 100,\n * duration: 1,\n * easing: (t) => 1 - Math.cos((t * Math.PI) / 2),\n * lerp: 0.1,\n * onStart: () => {\n * console.log('onStart')\n * },\n * onComplete: () => {\n * console.log('onComplete')\n * },\n * })\n */\n scrollTo(\n _target: number | string | HTMLElement,\n {\n offset = 0,\n immediate = false,\n lock = false,\n programmatic = true, // called from outside of the class\n lerp = programmatic ? this.options.lerp : undefined,\n duration = programmatic ? this.options.duration : undefined,\n easing = programmatic ? this.options.easing : undefined,\n onStart,\n onComplete,\n force = false, // scroll even if stopped\n userData,\n }: ScrollToOptions = {}\n ) {\n if ((this.isStopped || this.isLocked) && !force) return\n\n let target: number | string | HTMLElement = _target\n let adjustedOffset = offset\n\n // keywords\n if (\n typeof target === 'string' &&\n ['top', 'left', 'start', '#'].includes(target)\n ) {\n target = 0\n } else if (\n typeof target === 'string' &&\n ['bottom', 'right', 'end'].includes(target)\n ) {\n target = this.limit\n } else {\n let node: Element | null = null\n\n if (typeof target === 'string') {\n // getElementById accepts any valid HTML id (e.g. `#footnote-†`),\n // querySelector would reject it as an invalid CSS selector\n node = target.startsWith('#')\n ? document.getElementById(target.slice(1))\n : document.querySelector(target)\n\n if (!node) {\n if (target === '#top') {\n target = 0\n } else {\n console.warn('Lenis: Target not found', target)\n }\n }\n } else if (target instanceof HTMLElement && target?.nodeType) {\n // Node element\n node = target\n }\n\n if (node) {\n if (this.options.wrapper !== window) {\n // nested scroll offset correction\n const wrapperRect = this.rootElement.getBoundingClientRect()\n adjustedOffset -= this.isHorizontal\n ? wrapperRect.left\n : wrapperRect.top\n }\n\n const rect = node.getBoundingClientRect()\n\n // Account for scroll-margin CSS property on the target element\n const targetStyle = getComputedStyle(node)\n const scrollMargin = this.isHorizontal\n ? Number.parseFloat(targetStyle.scrollMarginLeft)\n : Number.parseFloat(targetStyle.scrollMarginTop)\n\n // Account for scroll-padding CSS property on the scroll container\n const containerStyle = getComputedStyle(this.rootElement)\n const scrollPadding = this.isHorizontal\n ? Number.parseFloat(containerStyle.scrollPaddingLeft)\n : Number.parseFloat(containerStyle.scrollPaddingTop)\n\n target =\n (this.isHorizontal ? rect.left : rect.top) +\n this.animatedScroll -\n (Number.isNaN(scrollMargin) ? 0 : scrollMargin) -\n (Number.isNaN(scrollPadding) ? 0 : scrollPadding)\n }\n }\n\n if (typeof target !== 'number') return\n\n target += adjustedOffset\n // target = Math.round(target)\n\n if (this.options.infinite) {\n if (programmatic) {\n this.targetScroll = this.animatedScroll = this.scroll\n\n const distance = target - this.animatedScroll\n\n if (distance > this.limit / 2) {\n target -= this.limit\n } else if (distance < -this.limit / 2) {\n target += this.limit\n }\n }\n } else {\n target = clamp(0, target, this.limit)\n }\n\n if (target === this.targetScroll) {\n onStart?.(this)\n onComplete?.(this)\n return\n }\n\n this.userData = userData ?? {}\n\n if (immediate) {\n this.animatedScroll = this.targetScroll = target\n this.setScroll(this.scroll)\n this.reset()\n this.preventNextNativeScrollEvent()\n this.emit()\n onComplete?.(this)\n this.userData = {}\n\n requestAnimationFrame(() => {\n this.dispatchScrollendEvent()\n })\n return\n }\n\n if (!programmatic) {\n this.targetScroll = target\n }\n\n // flip to easing/time based animation if at least one of them is provided\n if (typeof duration === 'number' && typeof easing !== 'function') {\n easing = defaultEasing\n } else if (typeof easing === 'function' && typeof duration !== 'number') {\n duration = 1\n }\n\n this.animate.fromTo(this.animatedScroll, target, {\n duration,\n easing,\n lerp,\n onStart: () => {\n // started\n if (lock) this.isLocked = true\n this.isScrolling = 'smooth'\n onStart?.(this)\n },\n onUpdate: (value: number, completed: boolean) => {\n this.isScrolling = 'smooth'\n\n // updated\n this.lastVelocity = this.velocity\n this.velocity = value - this.animatedScroll\n this.direction = Math.sign(this.velocity) as Lenis['direction']\n\n this.animatedScroll = value\n this.setScroll(this.scroll)\n\n if (programmatic) {\n // wheel during programmatic should stop it\n this.targetScroll = value\n }\n\n if (!completed) this.emit()\n\n if (completed) {\n this.reset()\n this.emit()\n onComplete?.(this)\n this.userData = {}\n\n requestAnimationFrame(() => {\n this.dispatchScrollendEvent()\n })\n\n // avoid emitting event twice\n this.preventNextNativeScrollEvent()\n }\n },\n })\n }\n\n private preventNextNativeScrollEvent() {\n this._preventNextNativeScrollEvent = true\n\n requestAnimationFrame(() => {\n this._preventNextNativeScrollEvent = false\n })\n }\n\n private hasNestedScroll(\n node: HTMLElement,\n { deltaX, deltaY }: { deltaX: number; deltaY: number }\n ) {\n const time = Date.now()\n\n // @ts-expect-error - _lenis is a custom cache property\n if (!node._lenis) node._lenis = {}\n // @ts-expect-error\n const cache = node._lenis\n\n let hasOverflowX: boolean | undefined\n let hasOverflowY: boolean | undefined\n let isScrollableX: boolean | undefined\n let isScrollableY: boolean | undefined\n let hasOverscrollBehaviorX: boolean | undefined\n let hasOverscrollBehaviorY: boolean | undefined\n let scrollWidth: number\n let scrollHeight: number\n let clientWidth: number\n let clientHeight: number\n\n if (time - (cache.time ?? 0) > 2000) {\n cache.time = Date.now()\n\n const computedStyle = window.getComputedStyle(node)\n cache.computedStyle = computedStyle\n\n hasOverflowX = ['auto', 'overlay', 'scroll'].includes(\n computedStyle.overflowX\n )\n hasOverflowY = ['auto', 'overlay', 'scroll'].includes(\n computedStyle.overflowY\n )\n\n hasOverscrollBehaviorX = ['auto'].includes(\n computedStyle.overscrollBehaviorX\n )\n hasOverscrollBehaviorY = ['auto'].includes(\n computedStyle.overscrollBehaviorY\n )\n\n cache.hasOverflowX = hasOverflowX\n cache.hasOverflowY = hasOverflowY\n\n if (!(hasOverflowX || hasOverflowY)) return false // if no overflow, it's not scrollable no matter what, early return saves some computations\n\n scrollWidth = node.scrollWidth\n scrollHeight = node.scrollHeight\n\n clientWidth = node.clientWidth\n clientHeight = node.clientHeight\n\n isScrollableX = scrollWidth > clientWidth\n isScrollableY = scrollHeight > clientHeight\n\n cache.isScrollableX = isScrollableX\n cache.isScrollableY = isScrollableY\n cache.scrollWidth = scrollWidth\n cache.scrollHeight = scrollHeight\n cache.clientWidth = clientWidth\n cache.clientHeight = clientHeight\n cache.hasOverscrollBehaviorX = hasOverscrollBehaviorX\n cache.hasOverscrollBehaviorY = hasOverscrollBehaviorY\n } else {\n isScrollableX = cache.isScrollableX\n isScrollableY = cache.isScrollableY\n hasOverflowX = cache.hasOverflowX\n hasOverflowY = cache.hasOverflowY\n scrollWidth = cache.scrollWidth\n scrollHeight = cache.scrollHeight\n clientWidth = cache.clientWidth\n clientHeight = cache.clientHeight\n hasOverscrollBehaviorX = cache.hasOverscrollBehaviorX\n hasOverscrollBehaviorY = cache.hasOverscrollBehaviorY\n }\n\n if (!((hasOverflowX && isScrollableX) || (hasOverflowY && isScrollableY))) {\n return false\n }\n\n const orientation =\n Math.abs(deltaX) >= Math.abs(deltaY) ? 'horizontal' : 'vertical'\n\n let scroll: number | undefined\n let maxScroll: number | undefined\n let delta: number | undefined\n let hasOverflow: boolean | undefined\n let isScrollable: boolean | undefined\n let hasOverscrollBehavior: boolean | undefined\n\n if (orientation === 'horizontal') {\n scroll = Math.round(node.scrollLeft)\n maxScroll = scrollWidth - clientWidth\n delta = deltaX\n\n hasOverflow = hasOverflowX\n isScrollable = isScrollableX\n hasOverscrollBehavior = hasOverscrollBehaviorX\n } else if (orientation === 'vertical') {\n scroll = Math.round(node.scrollTop)\n maxScroll = scrollHeight - clientHeight\n delta = deltaY\n\n hasOverflow = hasOverflowY\n isScrollable = isScrollableY\n hasOverscrollBehavior = hasOverscrollBehaviorY\n } else {\n return false\n }\n\n if (!hasOverscrollBehavior && (scroll >= maxScroll || scroll <= 0)) {\n return true\n }\n\n const willScroll = delta > 0 ? scroll < maxScroll : scroll > 0\n\n return willScroll && hasOverflow && isScrollable\n }\n\n /**\n * The root element on which lenis is instanced\n */\n get rootElement() {\n return (\n this.options.wrapper === window\n ? document.documentElement\n : this.options.wrapper\n ) as HTMLElement\n }\n\n /**\n * The limit which is the maximum scroll value\n */\n get limit() {\n if (this.options.naiveDimensions) {\n if (this.isHorizontal) {\n return this.rootElement.scrollWidth - this.rootElement.clientWidth\n }\n return this.rootElement.scrollHeight - this.rootElement.clientHeight\n }\n return this.dimensions.limit[this.isHorizontal ? 'x' : 'y']\n }\n\n /**\n * Whether or not the scroll is horizontal\n */\n get isHorizontal() {\n return this.options.orientation === 'horizontal'\n }\n\n /**\n * The actual scroll value\n */\n get actualScroll() {\n // value browser takes into account\n // it has to be this way because of DOCTYPE declaration\n const wrapper = this.options.wrapper as Window | HTMLElement\n\n return this.isHorizontal\n ? ((wrapper as Window).scrollX ?? (wrapper as HTMLElement).scrollLeft)\n : ((wrapper as Window).scrollY ?? (wrapper as HTMLElement).scrollTop)\n }\n\n /**\n * The current scroll value\n */\n get scroll() {\n return this.options.infinite\n ? modulo(this.animatedScroll, this.limit)\n : this.animatedScroll\n }\n\n /**\n * The progress of the scroll relative to the limit\n */\n get progress() {\n // avoid progress to be NaN\n return this.limit === 0 ? 1 : this.scroll / this.limit\n }\n\n /**\n * Current scroll state\n */\n get isScrolling() {\n return this._isScrolling\n }\n\n private set isScrolling(value: Scrolling) {\n if (this._isScrolling !== value) {\n this._isScrolling = value\n this.updateClassName()\n }\n }\n\n /**\n * Check if lenis is stopped\n */\n get isStopped() {\n return this._isStopped\n }\n\n private set isStopped(value: boolean) {\n if (this._isStopped !== value) {\n this._isStopped = value\n this.updateClassName()\n }\n }\n\n /**\n * Check if lenis is locked\n */\n get isLocked() {\n return this._isLocked\n }\n\n private set isLocked(value: boolean) {\n if (this._isLocked !== value) {\n this._isLocked = value\n this.updateClassName()\n }\n }\n\n /**\n * Check if lenis is smooth scrolling\n */\n get isSmooth() {\n return this.isScrolling === 'smooth'\n }\n\n /**\n * The class name applied to the wrapper element\n */\n get className() {\n let className = 'lenis'\n if (this.options.autoToggle) className += ' lenis-autoToggle'\n if (this.isStopped) className += ' lenis-stopped'\n if (this.isLocked) className += ' lenis-locked'\n if (this.isScrolling) className += ' lenis-scrolling'\n if (this.isScrolling === 'smooth') className += ' lenis-smooth'\n return className\n }\n\n private updateClassName() {\n this.cleanUpClassName()\n\n this.className.split(' ').forEach((className) => {\n this.rootElement.classList.add(className)\n })\n }\n\n private cleanUpClassName() {\n for (const className of Array.from(this.rootElement.classList)) {\n if (className === 'lenis' || className.startsWith('lenis-')) {\n this.rootElement.classList.remove(className)\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;ACQA,SAAgB,MAAM,KAAa,OAAe,KAAa;AAC7D,QAAO,KAAK,IAAI,KAAK,KAAK,IAAI,OAAO,IAAI,CAAC;;;;;;;;;;AAsB5C,SAAgB,KAAK,GAAW,GAAW,GAAW;AACpD,SAAQ,IAAI,KAAK,IAAI,IAAI;;;;;;;;;;;;AAa3B,SAAgB,KAAK,GAAW,GAAW,QAAgB,WAAmB;AAC5E,QAAO,KAAK,GAAG,GAAG,IAAI,KAAK,IAAI,CAAC,SAAS,UAAU,CAAC;;;;;;;;;;AAWtD,SAAgB,OAAO,GAAW,GAAW;AAC3C,SAAS,IAAI,IAAK,KAAK;;;;;;;;;;;;AC/CzB,IAAa,UAAb,MAAqB;CACnB,YAAY;CACZ,QAAQ;CACR,OAAO;CACP,KAAK;CACL,cAAc;CAGd;CACA;CACA;CACA;;;;;;CAOA,QAAQ,WAAmB;AACzB,MAAI,CAAC,KAAK,UAAW;EAErB,IAAI,YAAY;AAEhB,MAAI,KAAK,YAAY,KAAK,QAAQ;AAChC,QAAK,eAAe;GACpB,MAAM,iBAAiB,MAAM,GAAG,KAAK,cAAc,KAAK,UAAU,EAAE;AAEpE,eAAY,kBAAkB;GAC9B,MAAM,gBAAgB,YAAY,IAAI,KAAK,OA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