diff --git a/README.md b/README.md index 666f1f25..944299bb 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ import Lenis from 'lenis' using scripts: ```html - + ``` @@ -97,7 +97,7 @@ html.lenis, html.lenis body { or link the CSS file: ```html - + ``` or import it: diff --git a/dist/lenis.d.ts b/dist/lenis.d.ts index e831df1a..29dc2fb7 100644 --- a/dist/lenis.d.ts +++ b/dist/lenis.d.ts @@ -226,7 +226,11 @@ declare global { type OptionalPick = Omit & Partial>; declare class Lenis { - #private; + private _isScrolling; + private _isStopped; + private _isLocked; + private _preventNextNativeScrollEvent; + private _resetVelocityTimeout; /** * Whether or not the user is touching the screen */ diff --git a/dist/lenis.js b/dist/lenis.js index b5e0a6d0..984fb0b0 100644 --- a/dist/lenis.js +++ b/dist/lenis.js @@ -1,964 +1,923 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Lenis = factory()); + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Lenis = factory()); })(this, (function () { 'use strict'; - /****************************************************************************** - Copyright (c) Microsoft Corporation. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */ - /* global Reflect, Promise, SuppressedError, Symbol */ - - - function __classPrivateFieldGet(receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); - } - - function __classPrivateFieldSet(receiver, state, value, kind, f) { - if (kind === "m") throw new TypeError("Private method is not writable"); - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); - return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; - } - - typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { - var e = new Error(message); - return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; - }; + var version = "1.1.13"; - var version = "1.1.12"; + /** + * Clamp a value between a minimum and maximum value + * + * @param min Minimum value + * @param input Value to clamp + * @param max Maximum value + * @returns Clamped value + */ + function clamp(min, input, max) { + return Math.max(min, Math.min(input, max)); + } + /** + * Linearly interpolate between two values using an amount (0 <= t <= 1) + * + * @param x First value + * @param y Second value + * @param t Amount to interpolate (0 <= t <= 1) + * @returns Interpolated value + */ + function lerp(x, y, t) { + return (1 - t) * x + t * y; + } + /** + * Damp a value over time using a damping factor + * {@link http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/} + * + * @param x Initial value + * @param y Target value + * @param lambda Damping factor + * @param dt Time elapsed since the last update + * @returns Damped value + */ + function damp(x, y, lambda, deltaTime) { + return lerp(x, y, 1 - Math.exp(-lambda * deltaTime)); + } + /** + * Calculate the modulo of the dividend and divisor while keeping the result within the same sign as the divisor + * {@link https://anguscroll.com/just/just-modulo} + * + * @param n Dividend + * @param d Divisor + * @returns Modulo + */ + function modulo(n, d) { + return ((n % d) + d) % d; + } - /** - * Clamp a value between a minimum and maximum value - * - * @param min Minimum value - * @param input Value to clamp - * @param max Maximum value - * @returns Clamped value - */ - function clamp(min, input, max) { - return Math.max(min, Math.min(input, max)); - } - /** - * Linearly interpolate between two values using an amount (0 <= t <= 1) - * - * @param x First value - * @param y Second value - * @param t Amount to interpolate (0 <= t <= 1) - * @returns Interpolated value - */ - function lerp(x, y, t) { - return (1 - t) * x + t * y; - } - /** - * Damp a value over time using a damping factor - * {@link http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/} - * - * @param x Initial value - * @param y Target value - * @param lambda Damping factor - * @param dt Time elapsed since the last update - * @returns Damped value - */ - function damp(x, y, lambda, deltaTime) { - return lerp(x, y, 1 - Math.exp(-lambda * deltaTime)); - } - /** - * Calculate the modulo of the dividend and divisor while keeping the result within the same sign as the divisor - * {@link https://anguscroll.com/just/just-modulo} - * - * @param n Dividend - * @param d Divisor - * @returns Modulo - */ - function modulo(n, d) { - return ((n % d) + d) % d; - } + /** + * Animate class to handle value animations with lerping or easing + * + * @example + * const animate = new Animate() + * animate.fromTo(0, 100, { duration: 1, easing: (t) => t }) + * animate.advance(0.5) // 50 + */ + class Animate { + constructor() { + this.isRunning = false; + this.value = 0; + this.from = 0; + this.to = 0; + this.currentTime = 0; + } + /** + * Advance the animation by the given delta time + * + * @param deltaTime - The time in seconds to advance the animation + */ + advance(deltaTime) { + var _a; + if (!this.isRunning) + return; + let completed = false; + if (this.duration && this.easing) { + this.currentTime += deltaTime; + const linearProgress = clamp(0, this.currentTime / this.duration, 1); + completed = linearProgress >= 1; + const easedProgress = completed ? 1 : this.easing(linearProgress); + this.value = this.from + (this.to - this.from) * easedProgress; + } + else if (this.lerp) { + this.value = damp(this.value, this.to, this.lerp * 60, deltaTime); + if (Math.round(this.value) === this.to) { + this.value = this.to; + completed = true; + } + } + else { + // If no easing or lerp, just jump to the end value + this.value = this.to; + completed = true; + } + if (completed) { + this.stop(); + } + // Call the onUpdate callback with the current value and completed status + (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.call(this, this.value, completed); + } + /** Stop the animation */ + stop() { + this.isRunning = false; + } + /** + * Set up the animation from a starting value to an ending value + * with optional parameters for lerping, duration, easing, and onUpdate callback + * + * @param from - The starting value + * @param to - The ending value + * @param options - Options for the animation + */ + fromTo(from, to, { lerp, duration, easing, onStart, onUpdate }) { + this.from = this.value = from; + this.to = to; + this.lerp = lerp; + this.duration = duration; + this.easing = easing; + this.currentTime = 0; + this.isRunning = true; + onStart === null || onStart === void 0 ? void 0 : onStart(); + this.onUpdate = onUpdate; + } + } - /** - * Animate class to handle value animations with lerping or easing - * - * @example - * const animate = new Animate() - * animate.fromTo(0, 100, { duration: 1, easing: (t) => t }) - * animate.advance(0.5) // 50 - */ - class Animate { - constructor() { - this.isRunning = false; - this.value = 0; - this.from = 0; - this.to = 0; - this.currentTime = 0; - } - /** - * Advance the animation by the given delta time - * - * @param deltaTime - The time in seconds to advance the animation - */ - advance(deltaTime) { - var _a; - if (!this.isRunning) - return; - let completed = false; - if (this.duration && this.easing) { - this.currentTime += deltaTime; - const linearProgress = clamp(0, this.currentTime / this.duration, 1); - completed = linearProgress >= 1; - const easedProgress = completed ? 1 : this.easing(linearProgress); - this.value = this.from + (this.to - this.from) * easedProgress; - } - else if (this.lerp) { - this.value = damp(this.value, this.to, this.lerp * 60, deltaTime); - if (Math.round(this.value) === this.to) { - this.value = this.to; - completed = true; - } - } - else { - // If no easing or lerp, just jump to the end value - this.value = this.to; - completed = true; - } - if (completed) { - this.stop(); - } - // Call the onUpdate callback with the current value and completed status - (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.call(this, this.value, completed); - } - /** Stop the animation */ - stop() { - this.isRunning = false; - } - /** - * Set up the animation from a starting value to an ending value - * with optional parameters for lerping, duration, easing, and onUpdate callback - * - * @param from - The starting value - * @param to - The ending value - * @param options - Options for the animation - */ - fromTo(from, to, { lerp, duration, easing, onStart, onUpdate }) { - this.from = this.value = from; - this.to = to; - this.lerp = lerp; - this.duration = duration; - this.easing = easing; - this.currentTime = 0; - this.isRunning = true; - onStart === null || onStart === void 0 ? void 0 : onStart(); - this.onUpdate = onUpdate; - } - } + function debounce(callback, delay) { + let timer; + return function (...args) { + let context = this; + clearTimeout(timer); + timer = setTimeout(() => { + timer = undefined; + callback.apply(context, args); + }, delay); + }; + } - function debounce(callback, delay) { - let timer; - return function (...args) { - let context = this; - clearTimeout(timer); - timer = setTimeout(() => { - timer = undefined; - callback.apply(context, args); - }, delay); - }; - } + /** + * Dimensions class to handle the size of the content and wrapper + * + * @example + * const dimensions = new Dimensions(wrapper, content) + * dimensions.on('resize', (e) => { + * console.log(e.width, e.height) + * }) + */ + class Dimensions { + constructor(wrapper, content, { autoResize = true, debounce: debounceValue = 250 } = {}) { + this.wrapper = wrapper; + this.content = content; + this.width = 0; + this.height = 0; + this.scrollHeight = 0; + this.scrollWidth = 0; + this.resize = () => { + this.onWrapperResize(); + this.onContentResize(); + }; + this.onWrapperResize = () => { + if (this.wrapper instanceof Window) { + this.width = window.innerWidth; + this.height = window.innerHeight; + } + else { + this.width = this.wrapper.clientWidth; + this.height = this.wrapper.clientHeight; + } + }; + this.onContentResize = () => { + if (this.wrapper instanceof Window) { + this.scrollHeight = this.content.scrollHeight; + this.scrollWidth = this.content.scrollWidth; + } + else { + this.scrollHeight = this.wrapper.scrollHeight; + this.scrollWidth = this.wrapper.scrollWidth; + } + }; + if (autoResize) { + this.debouncedResize = debounce(this.resize, debounceValue); + if (this.wrapper instanceof Window) { + window.addEventListener('resize', this.debouncedResize, false); + } + else { + 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() { + var _a, _b; + (_a = this.wrapperResizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect(); + (_b = this.contentResizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect(); + if (this.wrapper === window && this.debouncedResize) { + window.removeEventListener('resize', this.debouncedResize, false); + } + } + get limit() { + return { + x: this.scrollWidth - this.width, + y: this.scrollHeight - this.height, + }; + } + } - /** - * Dimensions class to handle the size of the content and wrapper - * - * @example - * const dimensions = new Dimensions(wrapper, content) - * dimensions.on('resize', (e) => { - * console.log(e.width, e.height) - * }) - */ - class Dimensions { - constructor(wrapper, content, { autoResize = true, debounce: debounceValue = 250 } = {}) { - this.wrapper = wrapper; - this.content = content; - this.width = 0; - this.height = 0; - this.scrollHeight = 0; - this.scrollWidth = 0; - this.resize = () => { - this.onWrapperResize(); - this.onContentResize(); - }; - this.onWrapperResize = () => { - if (this.wrapper instanceof Window) { - this.width = window.innerWidth; - this.height = window.innerHeight; - } - else { - this.width = this.wrapper.clientWidth; - this.height = this.wrapper.clientHeight; - } - }; - this.onContentResize = () => { - if (this.wrapper instanceof Window) { - this.scrollHeight = this.content.scrollHeight; - this.scrollWidth = this.content.scrollWidth; - } - else { - this.scrollHeight = this.wrapper.scrollHeight; - this.scrollWidth = this.wrapper.scrollWidth; - } - }; - if (autoResize) { - this.debouncedResize = debounce(this.resize, debounceValue); - if (this.wrapper instanceof Window) { - window.addEventListener('resize', this.debouncedResize, false); - } - else { - 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() { - var _a, _b; - (_a = this.wrapperResizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect(); - (_b = this.contentResizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect(); - if (this.wrapper === window && this.debouncedResize) { - window.removeEventListener('resize', this.debouncedResize, false); - } - } - get limit() { - return { - x: this.scrollWidth - this.width, - y: this.scrollHeight - this.height, - }; - } - } + /** + * Emitter class to handle events + * @example + * const emitter = new Emitter() + * emitter.on('event', (data) => { + * console.log(data) + * }) + * emitter.emit('event', 'data') + */ + class Emitter { + constructor() { + this.events = {}; + } + /** + * Emit an event with the given data + * @param event Event name + * @param args Data to pass to the event handlers + */ + emit(event, ...args) { + var _a; + let callbacks = this.events[event] || []; + for (let i = 0, length = callbacks.length; i < length; i++) { + (_a = callbacks[i]) === null || _a === void 0 ? void 0 : _a.call(callbacks, ...args); + } + } + /** + * Add a callback to the event + * @param event Event name + * @param cb Callback function + * @returns Unsubscribe function + */ + on(event, cb) { + var _a; + // Add the callback to the event's callback list, or create a new list with the callback + ((_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.push(cb)) || (this.events[event] = [cb]); + // Return an unsubscribe function + return () => { + var _a; + this.events[event] = (_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.filter((i) => cb !== i); + }; + } + /** + * Remove a callback from the event + * @param event Event name + * @param callback Callback function + */ + off(event, callback) { + var _a; + this.events[event] = (_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.filter((i) => callback !== i); + } + /** + * Remove all event listeners and clean up + */ + destroy() { + this.events = {}; + } + } - /** - * Emitter class to handle events - * @example - * const emitter = new Emitter() - * emitter.on('event', (data) => { - * console.log(data) - * }) - * emitter.emit('event', 'data') - */ - class Emitter { - constructor() { - this.events = {}; - } - /** - * Emit an event with the given data - * @param event Event name - * @param args Data to pass to the event handlers - */ - emit(event, ...args) { - var _a; - let callbacks = this.events[event] || []; - for (let i = 0, length = callbacks.length; i < length; i++) { - (_a = callbacks[i]) === null || _a === void 0 ? void 0 : _a.call(callbacks, ...args); - } - } - /** - * Add a callback to the event - * @param event Event name - * @param cb Callback function - * @returns Unsubscribe function - */ - on(event, cb) { - var _a; - // Add the callback to the event's callback list, or create a new list with the callback - ((_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.push(cb)) || (this.events[event] = [cb]); - // Return an unsubscribe function - return () => { - var _a; - this.events[event] = (_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.filter((i) => cb !== i); - }; - } - /** - * Remove a callback from the event - * @param event Event name - * @param callback Callback function - */ - off(event, callback) { - var _a; - this.events[event] = (_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.filter((i) => callback !== i); - } - /** - * Remove all event listeners and clean up - */ - destroy() { - this.events = {}; - } - } + const LINE_HEIGHT = 100 / 6; + const listenerOptions = { passive: false }; + class VirtualScroll { + constructor(element, options = { wheelMultiplier: 1, touchMultiplier: 1 }) { + this.element = element; + this.options = options; + this.touchStart = { + x: 0, + y: 0, + }; + this.lastDelta = { + x: 0, + y: 0, + }; + this.window = { + width: 0, + height: 0, + }; + this.emitter = new Emitter(); + /** + * Event handler for 'touchstart' event + * + * @param event Touch event + */ + this.onTouchStart = (event) => { + // @ts-expect-error - event.targetTouches is not defined + const { clientX, clientY } = event.targetTouches + ? event.targetTouches[0] + : event; + this.touchStart.x = clientX; + this.touchStart.y = clientY; + this.lastDelta = { + x: 0, + y: 0, + }; + this.emitter.emit('scroll', { + deltaX: 0, + deltaY: 0, + event, + }); + }; + /** Event handler for 'touchmove' event */ + this.onTouchMove = (event) => { + // @ts-expect-error - event.targetTouches is not defined + const { clientX, clientY } = event.targetTouches + ? event.targetTouches[0] + : event; + const deltaX = -(clientX - this.touchStart.x) * this.options.touchMultiplier; + const deltaY = -(clientY - this.touchStart.y) * this.options.touchMultiplier; + this.touchStart.x = clientX; + this.touchStart.y = clientY; + this.lastDelta = { + x: deltaX, + y: deltaY, + }; + this.emitter.emit('scroll', { + deltaX, + deltaY, + event, + }); + }; + this.onTouchEnd = (event) => { + this.emitter.emit('scroll', { + deltaX: this.lastDelta.x, + deltaY: this.lastDelta.y, + event, + }); + }; + /** Event handler for 'wheel' event */ + this.onWheel = (event) => { + let { deltaX, deltaY, deltaMode } = event; + const multiplierX = deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.window.width : 1; + const multiplierY = deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.window.height : 1; + deltaX *= multiplierX; + deltaY *= multiplierY; + deltaX *= this.options.wheelMultiplier; + deltaY *= this.options.wheelMultiplier; + this.emitter.emit('scroll', { deltaX, deltaY, event }); + }; + this.onWindowResize = () => { + this.window = { + width: window.innerWidth, + height: window.innerHeight, + }; + }; + window.addEventListener('resize', this.onWindowResize, false); + this.onWindowResize(); + this.element.addEventListener('wheel', this.onWheel, listenerOptions); + this.element.addEventListener('touchstart', this.onTouchStart, listenerOptions); + this.element.addEventListener('touchmove', this.onTouchMove, listenerOptions); + this.element.addEventListener('touchend', this.onTouchEnd, listenerOptions); + } + /** + * Add an event listener for the given event and callback + * + * @param event Event name + * @param callback Callback function + */ + on(event, callback) { + return this.emitter.on(event, callback); + } + /** Remove all event listeners and clean up */ + destroy() { + this.emitter.destroy(); + window.removeEventListener('resize', this.onWindowResize, false); + this.element.removeEventListener('wheel', this.onWheel, listenerOptions); + this.element.removeEventListener('touchstart', this.onTouchStart, listenerOptions); + this.element.removeEventListener('touchmove', this.onTouchMove, listenerOptions); + this.element.removeEventListener('touchend', this.onTouchEnd, listenerOptions); + } + } - const LINE_HEIGHT = 100 / 6; - const listenerOptions = { passive: false }; - class VirtualScroll { - constructor(element, options = { wheelMultiplier: 1, touchMultiplier: 1 }) { - this.element = element; - this.options = options; - this.touchStart = { - x: 0, - y: 0, - }; - this.lastDelta = { - x: 0, - y: 0, - }; - this.window = { - width: 0, - height: 0, - }; - this.emitter = new Emitter(); - /** - * Event handler for 'touchstart' event - * - * @param event Touch event - */ - this.onTouchStart = (event) => { - // @ts-expect-error - event.targetTouches is not defined - const { clientX, clientY } = event.targetTouches - ? event.targetTouches[0] - : event; - this.touchStart.x = clientX; - this.touchStart.y = clientY; - this.lastDelta = { - x: 0, - y: 0, - }; - this.emitter.emit('scroll', { - deltaX: 0, - deltaY: 0, - event, - }); - }; - /** Event handler for 'touchmove' event */ - this.onTouchMove = (event) => { - // @ts-expect-error - event.targetTouches is not defined - const { clientX, clientY } = event.targetTouches - ? event.targetTouches[0] - : event; - const deltaX = -(clientX - this.touchStart.x) * this.options.touchMultiplier; - const deltaY = -(clientY - this.touchStart.y) * this.options.touchMultiplier; - this.touchStart.x = clientX; - this.touchStart.y = clientY; - this.lastDelta = { - x: deltaX, - y: deltaY, - }; - this.emitter.emit('scroll', { - deltaX, - deltaY, - event, - }); - }; - this.onTouchEnd = (event) => { - this.emitter.emit('scroll', { - deltaX: this.lastDelta.x, - deltaY: this.lastDelta.y, - event, - }); - }; - /** Event handler for 'wheel' event */ - this.onWheel = (event) => { - let { deltaX, deltaY, deltaMode } = event; - const multiplierX = deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.window.width : 1; - const multiplierY = deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.window.height : 1; - deltaX *= multiplierX; - deltaY *= multiplierY; - deltaX *= this.options.wheelMultiplier; - deltaY *= this.options.wheelMultiplier; - this.emitter.emit('scroll', { deltaX, deltaY, event }); - }; - this.onWindowResize = () => { - this.window = { - width: window.innerWidth, - height: window.innerHeight, - }; - }; - window.addEventListener('resize', this.onWindowResize, false); - this.onWindowResize(); - this.element.addEventListener('wheel', this.onWheel, listenerOptions); - this.element.addEventListener('touchstart', this.onTouchStart, listenerOptions); - this.element.addEventListener('touchmove', this.onTouchMove, listenerOptions); - this.element.addEventListener('touchend', this.onTouchEnd, listenerOptions); - } - /** - * Add an event listener for the given event and callback - * - * @param event Event name - * @param callback Callback function - */ - on(event, callback) { - return this.emitter.on(event, callback); - } - /** Remove all event listeners and clean up */ - destroy() { - this.emitter.destroy(); - window.removeEventListener('resize', this.onWindowResize, false); - this.element.removeEventListener('wheel', this.onWheel, listenerOptions); - this.element.removeEventListener('touchstart', this.onTouchStart, listenerOptions); - this.element.removeEventListener('touchmove', this.onTouchMove, listenerOptions); - this.element.removeEventListener('touchend', this.onTouchEnd, listenerOptions); - } - } + class Lenis { + constructor({ wrapper = window, content = document.documentElement, eventsTarget = wrapper, smoothWheel = true, syncTouch = false, syncTouchLerp = 0.075, touchInertiaMultiplier = 35, duration, // in seconds + easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), lerp = 0.1, infinite = false, orientation = 'vertical', // vertical, horizontal + gestureOrientation = 'vertical', // vertical, horizontal, both + touchMultiplier = 1, wheelMultiplier = 1, autoResize = true, prevent, virtualScroll, __experimental__naiveDimensions = false, } = {}) { + this._isScrolling = false; // true when scroll is animating + this._isStopped = false; // true if user should not be able to scroll - enable/disable programmatically + this._isLocked = false; // same as isStopped but enabled/disabled when scroll reaches target + this._preventNextNativeScrollEvent = false; + this._resetVelocityTimeout = null; + /** + * The time in ms since the lenis instance was created + */ + this.time = 0; + /** + * User data that will be forwarded through the scroll event + * + * @example + * lenis.scrollTo(100, { + * userData: { + * foo: 'bar' + * } + * }) + */ + this.userData = {}; + /** + * The last velocity of the scroll + */ + this.lastVelocity = 0; + /** + * The current velocity of the scroll + */ + this.velocity = 0; + /** + * The direction of the scroll + */ + this.direction = 0; + // These are instanciated here as they don't need information from the options + this.animate = new Animate(); + this.emitter = new Emitter(); + this.onPointerDown = (event) => { + if (event.button === 1) { + this.reset(); + } + }; + this.onVirtualScroll = (data) => { + if (typeof this.options.virtualScroll === 'function' && + this.options.virtualScroll(data) === false) + return; + const { deltaX, deltaY, event } = data; + this.emitter.emit('virtual-scroll', { deltaX, deltaY, event }); + // keep zoom feature + if (event.ctrlKey) + return; + const isTouch = event.type.includes('touch'); + const isWheel = event.type.includes('wheel'); + this.isTouching = event.type === 'touchstart' || event.type === 'touchmove'; + // if (event.type === 'touchend') { + // console.log('touchend', this.scroll) + // // this.lastVelocity = this.velocity + // // this.velocity = 0 + // // this.isScrolling = false + // this.emit({ type: 'touchend' }) + // // alert('touchend') + // return + // } + const isTapToStop = this.options.syncTouch && + isTouch && + event.type === 'touchstart' && + !this.isStopped && + !this.isLocked; + if (isTapToStop) { + this.reset(); + return; + } + const isClick = deltaX === 0 && deltaY === 0; // click event + // const isPullToRefresh = + // this.options.gestureOrientation === 'vertical' && + // this.scroll === 0 && + // !this.options.infinite && + // deltaY <= 5 // touch pull to refresh, not reliable yet + const isUnknownGesture = (this.options.gestureOrientation === 'vertical' && deltaY === 0) || + (this.options.gestureOrientation === 'horizontal' && deltaX === 0); + if (isClick || isUnknownGesture) { + // console.log('prevent') + return; + } + // 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 node instanceof HTMLElement && + ((typeof prevent === 'function' && (prevent === null || prevent === void 0 ? void 0 : prevent(node))) || + ((_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'))) || + (((_d = node.classList) === null || _d === void 0 ? void 0 : _d.contains('lenis')) && + !((_e = node.classList) === null || _e === void 0 ? void 0 : _e.contains('lenis-stopped')))); + } // nested lenis instance + )) + return; + if (this.isStopped || this.isLocked) { + event.preventDefault(); // this will stop forwarding the event to the parent, this is problematic + return; + } + const isSmooth = (this.options.syncTouch && isTouch) || + (this.options.smoothWheel && isWheel); + if (!isSmooth) { + this.isScrolling = 'native'; + this.animate.stop(); + return; + } + event.preventDefault(); + let delta = deltaY; + if (this.options.gestureOrientation === 'both') { + delta = Math.abs(deltaY) > Math.abs(deltaX) ? deltaY : deltaX; + } + else if (this.options.gestureOrientation === 'horizontal') { + delta = deltaX; + } + const syncTouch = isTouch && this.options.syncTouch; + const isTouchEnd = isTouch && event.type === 'touchend'; + const hasTouchInertia = isTouchEnd && Math.abs(delta) > 5; + if (hasTouchInertia) { + delta = this.velocity * this.options.touchInertiaMultiplier; + } + this.scrollTo(this.targetScroll + delta, Object.assign({ programmatic: false }, (syncTouch + ? { + lerp: hasTouchInertia ? this.options.syncTouchLerp : 1, + } + : { + lerp: this.options.lerp, + duration: this.options.duration, + easing: this.options.easing, + }))); + }; + this.onNativeScroll = () => { + if (this._resetVelocityTimeout !== null) { + clearTimeout(this._resetVelocityTimeout); + this._resetVelocityTimeout = null; + } + if (this._preventNextNativeScrollEvent) { + this._preventNextNativeScrollEvent = false; + return; + } + if (this.isScrolling === false || this.isScrolling === 'native') { + const lastScroll = this.animatedScroll; + this.animatedScroll = this.targetScroll = this.actualScroll; + this.lastVelocity = this.velocity; + this.velocity = this.animatedScroll - lastScroll; + this.direction = Math.sign(this.animatedScroll - lastScroll); + this.isScrolling = 'native'; + this.emit(); + if (this.velocity !== 0) { + this._resetVelocityTimeout = setTimeout(() => { + this.lastVelocity = this.velocity; + this.velocity = 0; + this.isScrolling = false; + this.emit(); + }, 400); + } + } + }; + // Set version + window.lenisVersion = version; + // Check if wrapper is html or body, fallback to window + if (!wrapper || + wrapper === document.documentElement || + wrapper === document.body) { + wrapper = window; + } + // Setup options + this.options = { + wrapper, + content, + eventsTarget, + smoothWheel, + syncTouch, + syncTouchLerp, + touchInertiaMultiplier, + duration, + easing, + lerp, + infinite, + gestureOrientation, + orientation, + touchMultiplier, + wheelMultiplier, + autoResize, + prevent, + virtualScroll, + __experimental__naiveDimensions, + }; + // Setup dimensions instance + this.dimensions = new Dimensions(wrapper, content, { autoResize }); + // Setup class name + this.updateClassName(); + // Set the initial scroll value for all scroll information + this.targetScroll = this.animatedScroll = this.actualScroll; + // Add event listeners + this.options.wrapper.addEventListener('scroll', this.onNativeScroll, false); + this.options.wrapper.addEventListener('pointerdown', this.onPointerDown, false); + // Setup virtual scroll instance + this.virtualScroll = new VirtualScroll(eventsTarget, { + touchMultiplier, + wheelMultiplier, + }); + this.virtualScroll.on('scroll', this.onVirtualScroll); + } + /** + * Destroy the lenis instance, remove all event listeners and clean up the class name + */ + destroy() { + this.emitter.destroy(); + this.options.wrapper.removeEventListener('scroll', this.onNativeScroll, false); + this.options.wrapper.removeEventListener('pointerdown', this.onPointerDown, false); + this.virtualScroll.destroy(); + this.dimensions.destroy(); + this.cleanUpClassName(); + } + on(event, callback) { + return this.emitter.on(event, callback); + } + off(event, callback) { + return this.emitter.off(event, callback); + } + setScroll(scroll) { + // apply scroll value immediately + if (this.isHorizontal) { + this.rootElement.scrollLeft = scroll; + } + else { + this.rootElement.scrollTop = scroll; + } + } + /** + * Force lenis to recalculate the dimensions + */ + resize() { + this.dimensions.resize(); + this.animatedScroll = this.targetScroll = this.actualScroll; + this.emit(); + } + emit() { + this.emitter.emit('scroll', this); + } + reset() { + this.isLocked = false; + this.isScrolling = false; + this.animatedScroll = this.targetScroll = this.actualScroll; + this.lastVelocity = this.velocity = 0; + this.animate.stop(); + } + /** + * Start lenis scroll after it has been stopped + */ + start() { + if (!this.isStopped) + return; + this.isStopped = false; + this.reset(); + } + /** + * Stop lenis scroll + */ + stop() { + if (this.isStopped) + return; + this.isStopped = true; + this.animate.stop(); + this.reset(); + } + /** + * RequestAnimationFrame for lenis + * + * @param time The time in ms from an external clock like `requestAnimationFrame` or Tempus + */ + raf(time) { + const deltaTime = time - (this.time || time); + this.time = time; + this.animate.advance(deltaTime * 0.001); + } + /** + * Scroll to a target value + * + * @param target The target value to scroll to + * @param options The options for the scroll + * + * @example + * lenis.scrollTo(100, { + * offset: 100, + * duration: 1, + * easing: (t) => 1 - Math.cos((t * Math.PI) / 2), + * lerp: 0.1, + * onStart: () => { + * console.log('onStart') + * }, + * onComplete: () => { + * console.log('onComplete') + * }, + * }) + */ + scrollTo(target, { offset = 0, immediate = false, lock = false, duration = this.options.duration, easing = this.options.easing, lerp = this.options.lerp, onStart, onComplete, force = false, // scroll even if stopped + programmatic = true, // called from outside of the class + userData, } = {}) { + if ((this.isStopped || this.isLocked) && !force) + return; + // keywords + if (typeof target === 'string' && + ['top', 'left', 'start'].includes(target)) { + target = 0; + } + else if (typeof target === 'string' && + ['bottom', 'right', 'end'].includes(target)) { + target = this.limit; + } + else { + let node; + if (typeof target === 'string') { + // CSS selector + node = document.querySelector(target); + } + else if (target instanceof HTMLElement && (target === null || target === void 0 ? void 0 : target.nodeType)) { + // Node element + node = target; + } + if (node) { + if (this.options.wrapper !== window) { + // nested scroll offset correction + const wrapperRect = this.rootElement.getBoundingClientRect(); + offset -= this.isHorizontal ? wrapperRect.left : wrapperRect.top; + } + const rect = node.getBoundingClientRect(); + target = + (this.isHorizontal ? rect.left : rect.top) + this.animatedScroll; + } + } + if (typeof target !== 'number') + return; + target += offset; + target = Math.round(target); + if (this.options.infinite) { + if (programmatic) { + this.targetScroll = this.animatedScroll = this.scroll; + } + } + else { + target = clamp(0, target, this.limit); + } + if (target === this.targetScroll) { + onStart === null || onStart === void 0 ? void 0 : onStart(this); + onComplete === null || onComplete === void 0 ? void 0 : onComplete(this); + return; + } + this.userData = userData !== null && userData !== void 0 ? userData : {}; + if (immediate) { + this.animatedScroll = this.targetScroll = target; + this.setScroll(this.scroll); + this.reset(); + this.preventNextNativeScrollEvent(); + this.emit(); + onComplete === null || onComplete === void 0 ? void 0 : onComplete(this); + this.userData = {}; + return; + } + if (!programmatic) { + this.targetScroll = target; + } + this.animate.fromTo(this.animatedScroll, target, { + duration, + easing, + lerp, + onStart: () => { + // started + if (lock) + this.isLocked = true; + this.isScrolling = 'smooth'; + onStart === null || onStart === void 0 ? void 0 : onStart(this); + }, + onUpdate: (value, completed) => { + this.isScrolling = 'smooth'; + // updated + this.lastVelocity = this.velocity; + this.velocity = value - this.animatedScroll; + this.direction = Math.sign(this.velocity); + this.animatedScroll = value; + this.setScroll(this.scroll); + if (programmatic) { + // wheel during programmatic should stop it + this.targetScroll = value; + } + if (!completed) + this.emit(); + if (completed) { + this.reset(); + this.emit(); + onComplete === null || onComplete === void 0 ? void 0 : onComplete(this); + this.userData = {}; + // avoid emitting event twice + this.preventNextNativeScrollEvent(); + } + }, + }); + } + preventNextNativeScrollEvent() { + this._preventNextNativeScrollEvent = true; + requestAnimationFrame(() => { + this._preventNextNativeScrollEvent = false; + }); + } + /** + * The root element on which lenis is instanced + */ + get rootElement() { + return (this.options.wrapper === window + ? document.documentElement + : this.options.wrapper); + } + /** + * The limit which is the maximum scroll value + */ + get limit() { + if (this.options.__experimental__naiveDimensions) { + if (this.isHorizontal) { + return this.rootElement.scrollWidth - this.rootElement.clientWidth; + } + else { + return this.rootElement.scrollHeight - this.rootElement.clientHeight; + } + } + else { + return this.dimensions.limit[this.isHorizontal ? 'x' : 'y']; + } + } + /** + * Whether or not the scroll is horizontal + */ + get isHorizontal() { + return this.options.orientation === 'horizontal'; + } + /** + * The actual scroll value + */ + get actualScroll() { + // value browser takes into account + return this.isHorizontal + ? this.rootElement.scrollLeft + : this.rootElement.scrollTop; + } + /** + * The current scroll value + */ + get scroll() { + return this.options.infinite + ? modulo(this.animatedScroll, this.limit) + : this.animatedScroll; + } + /** + * The progress of the scroll relative to the limit + */ + get progress() { + // avoid progress to be NaN + return this.limit === 0 ? 1 : this.scroll / this.limit; + } + /** + * Current scroll state + */ + get isScrolling() { + return this._isScrolling; + } + set isScrolling(value) { + if (this._isScrolling !== value) { + this._isScrolling = value; + this.updateClassName(); + } + } + /** + * Check if lenis is stopped + */ + get isStopped() { + return this._isStopped; + } + set isStopped(value) { + if (this._isStopped !== value) { + this._isStopped = value; + this.updateClassName(); + } + } + /** + * Check if lenis is locked + */ + get isLocked() { + return this._isLocked; + } + set isLocked(value) { + if (this._isLocked !== value) { + this._isLocked = value; + this.updateClassName(); + } + } + /** + * Check if lenis is smooth scrolling + */ + get isSmooth() { + return this.isScrolling === 'smooth'; + } + /** + * The class name applied to the wrapper element + */ + get className() { + let className = 'lenis'; + if (this.isStopped) + className += ' lenis-stopped'; + if (this.isLocked) + className += ' lenis-locked'; + if (this.isScrolling) + className += ' lenis-scrolling'; + if (this.isScrolling === 'smooth') + className += ' lenis-smooth'; + return className; + } + updateClassName() { + this.cleanUpClassName(); + this.rootElement.className = + `${this.rootElement.className} ${this.className}`.trim(); + } + cleanUpClassName() { + this.rootElement.className = this.rootElement.className + .replace(/lenis(-\w+)?/g, '') + .trim(); + } + } - var _Lenis_isScrolling, _Lenis_isStopped, _Lenis_isLocked, _Lenis_preventNextNativeScrollEvent, _Lenis_resetVelocityTimeout; - class Lenis { - constructor({ wrapper = window, content = document.documentElement, eventsTarget = wrapper, smoothWheel = true, syncTouch = false, syncTouchLerp = 0.075, touchInertiaMultiplier = 35, duration, // in seconds - easing = (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), lerp = 0.1, infinite = false, orientation = 'vertical', // vertical, horizontal - gestureOrientation = 'vertical', // vertical, horizontal, both - touchMultiplier = 1, wheelMultiplier = 1, autoResize = true, prevent, virtualScroll, __experimental__naiveDimensions = false, } = {}) { - _Lenis_isScrolling.set(this, false); // true when scroll is animating - _Lenis_isStopped.set(this, false); // true if user should not be able to scroll - enable/disable programmatically - _Lenis_isLocked.set(this, false); // same as isStopped but enabled/disabled when scroll reaches target - _Lenis_preventNextNativeScrollEvent.set(this, false); - _Lenis_resetVelocityTimeout.set(this, null - /** - * Whether or not the user is touching the screen - */ - ); - /** - * The time in ms since the lenis instance was created - */ - this.time = 0; - /** - * User data that will be forwarded through the scroll event - * - * @example - * lenis.scrollTo(100, { - * userData: { - * foo: 'bar' - * } - * }) - */ - this.userData = {}; - /** - * The last velocity of the scroll - */ - this.lastVelocity = 0; - /** - * The current velocity of the scroll - */ - this.velocity = 0; - /** - * The direction of the scroll - */ - this.direction = 0; - // These are instanciated here as they don't need information from the options - this.animate = new Animate(); - this.emitter = new Emitter(); - this.onPointerDown = (event) => { - if (event.button === 1) { - this.reset(); - } - }; - this.onVirtualScroll = (data) => { - if (typeof this.options.virtualScroll === 'function' && - this.options.virtualScroll(data) === false) - return; - const { deltaX, deltaY, event } = data; - this.emitter.emit('virtual-scroll', { deltaX, deltaY, event }); - // keep zoom feature - if (event.ctrlKey) - return; - const isTouch = event.type.includes('touch'); - const isWheel = event.type.includes('wheel'); - this.isTouching = event.type === 'touchstart' || event.type === 'touchmove'; - // if (event.type === 'touchend') { - // console.log('touchend', this.scroll) - // // this.lastVelocity = this.velocity - // // this.velocity = 0 - // // this.isScrolling = false - // this.emit({ type: 'touchend' }) - // // alert('touchend') - // return - // } - const isTapToStop = this.options.syncTouch && - isTouch && - event.type === 'touchstart' && - !this.isStopped && - !this.isLocked; - if (isTapToStop) { - this.reset(); - return; - } - const isClick = deltaX === 0 && deltaY === 0; // click event - // const isPullToRefresh = - // this.options.gestureOrientation === 'vertical' && - // this.scroll === 0 && - // !this.options.infinite && - // deltaY <= 5 // touch pull to refresh, not reliable yet - const isUnknownGesture = (this.options.gestureOrientation === 'vertical' && deltaY === 0) || - (this.options.gestureOrientation === 'horizontal' && deltaX === 0); - if (isClick || isUnknownGesture) { - // console.log('prevent') - return; - } - // 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 node instanceof HTMLElement && - ((typeof prevent === 'function' && (prevent === null || prevent === void 0 ? void 0 : prevent(node))) || - ((_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'))) || - (((_d = node.classList) === null || _d === void 0 ? void 0 : _d.contains('lenis')) && - !((_e = node.classList) === null || _e === void 0 ? void 0 : _e.contains('lenis-stopped')))); - } // nested lenis instance - )) - return; - if (this.isStopped || this.isLocked) { - event.preventDefault(); // this will stop forwarding the event to the parent, this is problematic - return; - } - const isSmooth = (this.options.syncTouch && isTouch) || - (this.options.smoothWheel && isWheel); - if (!isSmooth) { - this.isScrolling = 'native'; - this.animate.stop(); - return; - } - event.preventDefault(); - let delta = deltaY; - if (this.options.gestureOrientation === 'both') { - delta = Math.abs(deltaY) > Math.abs(deltaX) ? deltaY : deltaX; - } - else if (this.options.gestureOrientation === 'horizontal') { - delta = deltaX; - } - const syncTouch = isTouch && this.options.syncTouch; - const isTouchEnd = isTouch && event.type === 'touchend'; - const hasTouchInertia = isTouchEnd && Math.abs(delta) > 5; - if (hasTouchInertia) { - delta = this.velocity * this.options.touchInertiaMultiplier; - } - this.scrollTo(this.targetScroll + delta, Object.assign({ programmatic: false }, (syncTouch - ? { - lerp: hasTouchInertia ? this.options.syncTouchLerp : 1, - } - : { - lerp: this.options.lerp, - duration: this.options.duration, - easing: this.options.easing, - }))); - }; - this.onNativeScroll = () => { - if (__classPrivateFieldGet(this, _Lenis_resetVelocityTimeout, "f") !== null) { - clearTimeout(__classPrivateFieldGet(this, _Lenis_resetVelocityTimeout, "f")); - __classPrivateFieldSet(this, _Lenis_resetVelocityTimeout, null, "f"); - } - if (__classPrivateFieldGet(this, _Lenis_preventNextNativeScrollEvent, "f")) { - __classPrivateFieldSet(this, _Lenis_preventNextNativeScrollEvent, false, "f"); - return; - } - if (this.isScrolling === false || this.isScrolling === 'native') { - const lastScroll = this.animatedScroll; - this.animatedScroll = this.targetScroll = this.actualScroll; - this.lastVelocity = this.velocity; - this.velocity = this.animatedScroll - lastScroll; - this.direction = Math.sign(this.animatedScroll - lastScroll); - this.isScrolling = 'native'; - this.emit(); - if (this.velocity !== 0) { - __classPrivateFieldSet(this, _Lenis_resetVelocityTimeout, setTimeout(() => { - this.lastVelocity = this.velocity; - this.velocity = 0; - this.isScrolling = false; - this.emit(); - }, 400), "f"); - } - } - }; - // Set version - window.lenisVersion = version; - // Check if wrapper is html or body, fallback to window - if (!wrapper || - wrapper === document.documentElement || - wrapper === document.body) { - wrapper = window; - } - // Setup options - this.options = { - wrapper, - content, - eventsTarget, - smoothWheel, - syncTouch, - syncTouchLerp, - touchInertiaMultiplier, - duration, - easing, - lerp, - infinite, - gestureOrientation, - orientation, - touchMultiplier, - wheelMultiplier, - autoResize, - prevent, - virtualScroll, - __experimental__naiveDimensions, - }; - // Setup dimensions instance - this.dimensions = new Dimensions(wrapper, content, { autoResize }); - // Setup class name - this.updateClassName(); - // Set the initial scroll value for all scroll information - this.targetScroll = this.animatedScroll = this.actualScroll; - // Add event listeners - this.options.wrapper.addEventListener('scroll', this.onNativeScroll, false); - this.options.wrapper.addEventListener('pointerdown', this.onPointerDown, false); - // Setup virtual scroll instance - this.virtualScroll = new VirtualScroll(eventsTarget, { - touchMultiplier, - wheelMultiplier, - }); - this.virtualScroll.on('scroll', this.onVirtualScroll); - } - /** - * Destroy the lenis instance, remove all event listeners and clean up the class name - */ - destroy() { - this.emitter.destroy(); - this.options.wrapper.removeEventListener('scroll', this.onNativeScroll, false); - this.options.wrapper.removeEventListener('pointerdown', this.onPointerDown, false); - this.virtualScroll.destroy(); - this.dimensions.destroy(); - this.cleanUpClassName(); - } - on(event, callback) { - return this.emitter.on(event, callback); - } - off(event, callback) { - return this.emitter.off(event, callback); - } - setScroll(scroll) { - // apply scroll value immediately - if (this.isHorizontal) { - this.rootElement.scrollLeft = scroll; - } - else { - this.rootElement.scrollTop = scroll; - } - } - /** - * Force lenis to recalculate the dimensions - */ - resize() { - this.dimensions.resize(); - this.animatedScroll = this.targetScroll = this.actualScroll; - this.emit(); - } - emit() { - this.emitter.emit('scroll', this); - } - reset() { - this.isLocked = false; - this.isScrolling = false; - this.animatedScroll = this.targetScroll = this.actualScroll; - this.lastVelocity = this.velocity = 0; - this.animate.stop(); - } - /** - * Start lenis scroll after it has been stopped - */ - start() { - if (!this.isStopped) - return; - this.isStopped = false; - this.reset(); - } - /** - * Stop lenis scroll - */ - stop() { - if (this.isStopped) - return; - this.isStopped = true; - this.animate.stop(); - this.reset(); - } - /** - * RequestAnimationFrame for lenis - * - * @param time The time in ms from an external clock like `requestAnimationFrame` or Tempus - */ - raf(time) { - const deltaTime = time - (this.time || time); - this.time = time; - this.animate.advance(deltaTime * 0.001); - } - /** - * Scroll to a target value - * - * @param target The target value to scroll to - * @param options The options for the scroll - * - * @example - * lenis.scrollTo(100, { - * offset: 100, - * duration: 1, - * easing: (t) => 1 - Math.cos((t * Math.PI) / 2), - * lerp: 0.1, - * onStart: () => { - * console.log('onStart') - * }, - * onComplete: () => { - * console.log('onComplete') - * }, - * }) - */ - scrollTo(target, { offset = 0, immediate = false, lock = false, duration = this.options.duration, easing = this.options.easing, lerp = this.options.lerp, onStart, onComplete, force = false, // scroll even if stopped - programmatic = true, // called from outside of the class - userData, } = {}) { - if ((this.isStopped || this.isLocked) && !force) - return; - // keywords - if (typeof target === 'string' && - ['top', 'left', 'start'].includes(target)) { - target = 0; - } - else if (typeof target === 'string' && - ['bottom', 'right', 'end'].includes(target)) { - target = this.limit; - } - else { - let node; - if (typeof target === 'string') { - // CSS selector - node = document.querySelector(target); - } - else if (target instanceof HTMLElement && (target === null || target === void 0 ? void 0 : target.nodeType)) { - // Node element - node = target; - } - if (node) { - if (this.options.wrapper !== window) { - // nested scroll offset correction - const wrapperRect = this.rootElement.getBoundingClientRect(); - offset -= this.isHorizontal ? wrapperRect.left : wrapperRect.top; - } - const rect = node.getBoundingClientRect(); - target = - (this.isHorizontal ? rect.left : rect.top) + this.animatedScroll; - } - } - if (typeof target !== 'number') - return; - target += offset; - target = Math.round(target); - if (this.options.infinite) { - if (programmatic) { - this.targetScroll = this.animatedScroll = this.scroll; - } - } - else { - target = clamp(0, target, this.limit); - } - if (target === this.targetScroll) { - onStart === null || onStart === void 0 ? void 0 : onStart(this); - onComplete === null || onComplete === void 0 ? void 0 : onComplete(this); - return; - } - this.userData = userData !== null && userData !== void 0 ? userData : {}; - if (immediate) { - this.animatedScroll = this.targetScroll = target; - this.setScroll(this.scroll); - this.reset(); - this.preventNextNativeScrollEvent(); - this.emit(); - onComplete === null || onComplete === void 0 ? void 0 : onComplete(this); - this.userData = {}; - return; - } - if (!programmatic) { - this.targetScroll = target; - } - this.animate.fromTo(this.animatedScroll, target, { - duration, - easing, - lerp, - onStart: () => { - // started - if (lock) - this.isLocked = true; - this.isScrolling = 'smooth'; - onStart === null || onStart === void 0 ? void 0 : onStart(this); - }, - onUpdate: (value, completed) => { - this.isScrolling = 'smooth'; - // updated - this.lastVelocity = this.velocity; - this.velocity = value - this.animatedScroll; - this.direction = Math.sign(this.velocity); - this.animatedScroll = value; - this.setScroll(this.scroll); - if (programmatic) { - // wheel during programmatic should stop it - this.targetScroll = value; - } - if (!completed) - this.emit(); - if (completed) { - this.reset(); - this.emit(); - onComplete === null || onComplete === void 0 ? void 0 : onComplete(this); - this.userData = {}; - // avoid emitting event twice - this.preventNextNativeScrollEvent(); - } - }, - }); - } - preventNextNativeScrollEvent() { - __classPrivateFieldSet(this, _Lenis_preventNextNativeScrollEvent, true, "f"); - requestAnimationFrame(() => { - __classPrivateFieldSet(this, _Lenis_preventNextNativeScrollEvent, false, "f"); - }); - } - /** - * The root element on which lenis is instanced - */ - get rootElement() { - return (this.options.wrapper === window - ? document.documentElement - : this.options.wrapper); - } - /** - * The limit which is the maximum scroll value - */ - get limit() { - if (this.options.__experimental__naiveDimensions) { - if (this.isHorizontal) { - return this.rootElement.scrollWidth - this.rootElement.clientWidth; - } - else { - return this.rootElement.scrollHeight - this.rootElement.clientHeight; - } - } - else { - return this.dimensions.limit[this.isHorizontal ? 'x' : 'y']; - } - } - /** - * Whether or not the scroll is horizontal - */ - get isHorizontal() { - return this.options.orientation === 'horizontal'; - } - /** - * The actual scroll value - */ - get actualScroll() { - // value browser takes into account - return this.isHorizontal - ? this.rootElement.scrollLeft - : this.rootElement.scrollTop; - } - /** - * The current scroll value - */ - get scroll() { - return this.options.infinite - ? modulo(this.animatedScroll, this.limit) - : this.animatedScroll; - } - /** - * The progress of the scroll relative to the limit - */ - get progress() { - // avoid progress to be NaN - return this.limit === 0 ? 1 : this.scroll / this.limit; - } - /** - * Current scroll state - */ - get isScrolling() { - return __classPrivateFieldGet(this, _Lenis_isScrolling, "f"); - } - set isScrolling(value) { - if (__classPrivateFieldGet(this, _Lenis_isScrolling, "f") !== value) { - __classPrivateFieldSet(this, _Lenis_isScrolling, value, "f"); - this.updateClassName(); - } - } - /** - * Check if lenis is stopped - */ - get isStopped() { - return __classPrivateFieldGet(this, _Lenis_isStopped, "f"); - } - set isStopped(value) { - if (__classPrivateFieldGet(this, _Lenis_isStopped, "f") !== value) { - __classPrivateFieldSet(this, _Lenis_isStopped, value, "f"); - this.updateClassName(); - } - } - /** - * Check if lenis is locked - */ - get isLocked() { - return __classPrivateFieldGet(this, _Lenis_isLocked, "f"); - } - set isLocked(value) { - if (__classPrivateFieldGet(this, _Lenis_isLocked, "f") !== value) { - __classPrivateFieldSet(this, _Lenis_isLocked, value, "f"); - this.updateClassName(); - } - } - /** - * Check if lenis is smooth scrolling - */ - get isSmooth() { - return this.isScrolling === 'smooth'; - } - /** - * The class name applied to the wrapper element - */ - get className() { - let className = 'lenis'; - if (this.isStopped) - className += ' lenis-stopped'; - if (this.isLocked) - className += ' lenis-locked'; - if (this.isScrolling) - className += ' lenis-scrolling'; - if (this.isScrolling === 'smooth') - className += ' lenis-smooth'; - return className; - } - updateClassName() { - this.cleanUpClassName(); - this.rootElement.className = - `${this.rootElement.className} ${this.className}`.trim(); - } - cleanUpClassName() { - this.rootElement.className = this.rootElement.className - .replace(/lenis(-\w+)?/g, '') - .trim(); - } - } - _Lenis_isScrolling = new WeakMap(), _Lenis_isStopped = new WeakMap(), _Lenis_isLocked = new WeakMap(), _Lenis_preventNextNativeScrollEvent = new WeakMap(), _Lenis_resetVelocityTimeout = new WeakMap(); - - return Lenis; + return Lenis; })); //# sourceMappingURL=lenis.js.map diff --git a/dist/lenis.js.map b/dist/lenis.js.map index e75ecfc5..3236115e 100644 --- a/dist/lenis.js.map +++ b/dist/lenis.js.map @@ -1 +1 @@ -{"version":3,"file":"lenis.js","sources":["../../../node_modules/.pnpm/@rollup+plugin-typescript@11.1.6_rollup@4.14.3_tslib@2.6.2_typescript@5.4.5/node_modules/tslib/tslib.es6.js","../../src/maths.ts","../../src/animate.ts","../../src/debounce.ts","../../src/dimensions.ts","../../src/emitter.ts","../../src/virtual-scroll.ts","../../src/index.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n function next() {\r\n while (env.stack.length) {\r\n var rec = env.stack.pop();\r\n try {\r\n var result = rec.dispose && rec.dispose.call(rec.value);\r\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n};\r\n","/**\r\n * Clamp a value between a minimum and maximum value\r\n *\r\n * @param min Minimum value\r\n * @param input Value to clamp\r\n * @param max Maximum value\r\n * @returns Clamped value\r\n */\r\nexport function clamp(min: number, input: number, max: number) {\r\n return Math.max(min, Math.min(input, max))\r\n}\r\n\r\n/**\r\n * Truncate a floating-point number to a specified number of decimal places\r\n *\r\n * @param value Value to truncate\r\n * @param decimals Number of decimal places to truncate to\r\n * @returns Truncated value\r\n */\r\nexport function truncate(value: number, decimals = 0) {\r\n return parseFloat(value.toFixed(decimals))\r\n}\r\n\r\n/**\r\n * Linearly interpolate between two values using an amount (0 <= t <= 1)\r\n *\r\n * @param x First value\r\n * @param y Second value\r\n * @param t Amount to interpolate (0 <= t <= 1)\r\n * @returns Interpolated value\r\n */\r\nexport function lerp(x: number, y: number, t: number) {\r\n return (1 - t) * x + t * y\r\n}\r\n\r\n/**\r\n * Damp a value over time using a damping factor\r\n * {@link http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/}\r\n *\r\n * @param x Initial value\r\n * @param y Target value\r\n * @param lambda Damping factor\r\n * @param dt Time elapsed since the last update\r\n * @returns Damped value\r\n */\r\nexport function damp(x: number, y: number, lambda: number, deltaTime: number) {\r\n return lerp(x, y, 1 - Math.exp(-lambda * deltaTime))\r\n}\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 * {@link https://anguscroll.com/just/just-modulo}\r\n *\r\n * @param n Dividend\r\n * @param d Divisor\r\n * @returns Modulo\r\n */\r\nexport function modulo(n: number, d: number) {\r\n return ((n % d) + d) % d\r\n}\r\n","import { clamp, damp } from './maths'\r\nimport type { EasingFunction, FromToOptions, OnUpdateCallback } from './types'\r\n\r\n/**\r\n * Animate class to handle value animations with lerping or easing\r\n *\r\n * @example\r\n * const animate = new Animate()\r\n * animate.fromTo(0, 100, { duration: 1, easing: (t) => t })\r\n * animate.advance(0.5) // 50\r\n */\r\nexport class Animate {\r\n isRunning = false\r\n value = 0\r\n from = 0\r\n to = 0\r\n currentTime = 0\r\n\r\n // These are instanciated in the fromTo method\r\n lerp?: number\r\n duration?: number\r\n easing?: EasingFunction\r\n onUpdate?: OnUpdateCallback\r\n\r\n /**\r\n * Advance the animation by the given delta time\r\n *\r\n * @param deltaTime - The time in seconds to advance the animation\r\n */\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 /**\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 *\r\n * @param from - The starting value\r\n * @param to - The ending value\r\n * @param options - Options for the animation\r\n */\r\n fromTo(\r\n from: number,\r\n to: number,\r\n { lerp, duration, easing, onStart, onUpdate }: FromToOptions\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 void>(\r\n callback: CB,\r\n delay: number\r\n) {\r\n let timer: number | undefined\r\n return function (this: T, ...args: Parameters) {\r\n let context = this\r\n clearTimeout(timer)\r\n timer = setTimeout(() => {\r\n timer = undefined\r\n callback.apply(context, args)\r\n }, delay)\r\n }\r\n}\r\n","import { debounce } from './debounce'\r\n\r\n/**\r\n * Dimensions class to handle the size of the content and wrapper\r\n *\r\n * @example\r\n * const dimensions = new Dimensions(wrapper, content)\r\n * dimensions.on('resize', (e) => {\r\n * console.log(e.width, e.height)\r\n * })\r\n */\r\nexport class Dimensions {\r\n width = 0\r\n height = 0\r\n scrollHeight = 0\r\n scrollWidth = 0\r\n\r\n // These are instanciated in the constructor as they need information from the options\r\n private debouncedResize?: (...args: unknown[]) => void\r\n private wrapperResizeObserver?: ResizeObserver\r\n private contentResizeObserver?: ResizeObserver\r\n\r\n constructor(\r\n private wrapper: HTMLElement | Window,\r\n private content: HTMLElement,\r\n { autoResize = true, debounce: debounceValue = 250 } = {}\r\n ) {\r\n if (autoResize) {\r\n this.debouncedResize = debounce(this.resize, debounceValue)\r\n\r\n if (this.wrapper instanceof 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\r\n if (this.wrapper === window && this.debouncedResize) {\r\n window.removeEventListener('resize', this.debouncedResize, 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 instanceof 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 instanceof 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","/**\r\n * Emitter class to handle events\r\n * @example\r\n * const emitter = new Emitter()\r\n * emitter.on('event', (data) => {\r\n * console.log(data)\r\n * })\r\n * emitter.emit('event', 'data')\r\n */\r\nexport class Emitter {\r\n private events: Record<\r\n string,\r\n Array<(...args: unknown[]) => void> | undefined\r\n > = {}\r\n\r\n /**\r\n * Emit an event with the given data\r\n * @param event Event name\r\n * @param args Data to pass to the event handlers\r\n */\r\n emit(event: string, ...args: unknown[]) {\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 /**\r\n * Add a callback to the event\r\n * @param event Event name\r\n * @param cb Callback function\r\n * @returns Unsubscribe function\r\n */\r\n on void>(event: string, cb: 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 /**\r\n * Remove a callback from the event\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n off void>(event: string, callback: CB) {\r\n this.events[event] = this.events[event]?.filter((i) => callback !== i)\r\n }\r\n\r\n /**\r\n * Remove all event listeners and clean up\r\n */\r\n destroy() {\r\n this.events = {}\r\n }\r\n}\r\n","import { Emitter } from './emitter'\r\nimport { VirtualScrollCallback } from './types'\r\n\r\nconst LINE_HEIGHT = 100 / 6\r\nconst listenerOptions: AddEventListenerOptions = { passive: false }\r\n\r\nexport class VirtualScroll {\r\n touchStart = {\r\n x: 0,\r\n y: 0,\r\n }\r\n lastDelta = {\r\n x: 0,\r\n y: 0,\r\n }\r\n window = {\r\n width: 0,\r\n height: 0,\r\n }\r\n private emitter = new Emitter()\r\n\r\n constructor(\r\n private element: HTMLElement,\r\n private options = { wheelMultiplier: 1, touchMultiplier: 1 }\r\n ) {\r\n window.addEventListener('resize', this.onWindowResize, false)\r\n this.onWindowResize()\r\n\r\n this.element.addEventListener('wheel', this.onWheel, listenerOptions)\r\n this.element.addEventListener(\r\n 'touchstart',\r\n this.onTouchStart,\r\n listenerOptions\r\n )\r\n this.element.addEventListener(\r\n 'touchmove',\r\n this.onTouchMove,\r\n listenerOptions\r\n )\r\n this.element.addEventListener('touchend', this.onTouchEnd, listenerOptions)\r\n }\r\n\r\n /**\r\n * Add an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n on(event: string, callback: VirtualScrollCallback) {\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, listenerOptions)\r\n this.element.removeEventListener(\r\n 'touchstart',\r\n this.onTouchStart,\r\n listenerOptions\r\n )\r\n this.element.removeEventListener(\r\n 'touchmove',\r\n this.onTouchMove,\r\n listenerOptions\r\n )\r\n this.element.removeEventListener(\r\n 'touchend',\r\n this.onTouchEnd,\r\n listenerOptions\r\n )\r\n }\r\n\r\n /**\r\n * Event handler for 'touchstart' event\r\n *\r\n * @param event Touch event\r\n */\r\n onTouchStart = (event: TouchEvent) => {\r\n // @ts-expect-error - event.targetTouches is not defined\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 - event.targetTouches is not defined\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.options.touchMultiplier\r\n const deltaY = -(clientY - this.touchStart.y) * this.options.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.window.width : 1\r\n const multiplierY =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.window.height : 1\r\n\r\n deltaX *= multiplierX\r\n deltaY *= multiplierY\r\n\r\n deltaX *= this.options.wheelMultiplier\r\n deltaY *= this.options.wheelMultiplier\r\n\r\n this.emitter.emit('scroll', { deltaX, deltaY, event })\r\n }\r\n\r\n onWindowResize = () => {\r\n this.window = {\r\n width: window.innerWidth,\r\n height: window.innerHeight,\r\n }\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 type {\r\n LenisEvent,\r\n LenisOptions,\r\n ScrollCallback,\r\n Scrolling,\r\n ScrollToOptions,\r\n UserData,\r\n VirtualScrollCallback,\r\n VirtualScrollData,\r\n} from './types'\r\nimport { VirtualScroll } from './virtual-scroll'\r\n\r\n// Types\r\nexport * from './types'\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 OptionalPick = Omit & Partial>\r\n\r\nexport default class Lenis {\r\n #isScrolling: Scrolling = false // true when scroll is animating\r\n #isStopped = false // true if user should not be able to scroll - enable/disable programmatically\r\n #isLocked = false // same as isStopped but enabled/disabled when scroll reaches target\r\n #preventNextNativeScrollEvent = false\r\n #resetVelocityTimeout: number | null = null\r\n\r\n /**\r\n * Whether or not the user is touching the screen\r\n */\r\n isTouching?: boolean\r\n /**\r\n * The time in ms since the lenis instance was created\r\n */\r\n time = 0\r\n /**\r\n * User data that will be forwarded through the scroll event\r\n *\r\n * @example\r\n * lenis.scrollTo(100, {\r\n * userData: {\r\n * foo: 'bar'\r\n * }\r\n * })\r\n */\r\n userData: UserData = {}\r\n /**\r\n * The last velocity of the scroll\r\n */\r\n lastVelocity = 0\r\n /**\r\n * The current velocity of the scroll\r\n */\r\n velocity = 0\r\n /**\r\n * The direction of the scroll\r\n */\r\n direction: 1 | -1 | 0 = 0\r\n /**\r\n * The options passed to the lenis instance\r\n */\r\n options: OptionalPick<\r\n Required,\r\n 'duration' | 'prevent' | 'virtualScroll'\r\n >\r\n /**\r\n * The target scroll value\r\n */\r\n targetScroll: number\r\n /**\r\n * The animated scroll value\r\n */\r\n animatedScroll: number\r\n\r\n // These are instanciated here as they don't need information from the options\r\n private readonly animate = new Animate()\r\n private readonly emitter = new Emitter()\r\n // These are instanciated in the constructor as they need information from the options\r\n readonly dimensions: Dimensions // This is not private because it's used in the Snap class\r\n private readonly virtualScroll: VirtualScroll\r\n\r\n constructor({\r\n wrapper = window,\r\n content = document.documentElement,\r\n eventsTarget = wrapper,\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 // Set version\r\n window.lenisVersion = version\r\n\r\n // Check 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 // Setup options\r\n this.options = {\r\n wrapper,\r\n content,\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 }\r\n\r\n // Setup dimensions instance\r\n this.dimensions = new Dimensions(wrapper, content, { autoResize })\r\n\r\n // Setup class name\r\n this.updateClassName()\r\n\r\n // Set the initial scroll value for all scroll information\r\n this.targetScroll = this.animatedScroll = this.actualScroll\r\n\r\n // Add event listeners\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 // Setup virtual scroll instance\r\n this.virtualScroll = new VirtualScroll(eventsTarget as HTMLElement, {\r\n touchMultiplier,\r\n wheelMultiplier,\r\n })\r\n this.virtualScroll.on('scroll', this.onVirtualScroll)\r\n }\r\n\r\n /**\r\n * Destroy the lenis instance, remove all event listeners and clean up the class name\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\r\n /**\r\n * Add an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n * @returns Unsubscribe function\r\n */\r\n on(event: 'scroll', callback: ScrollCallback): () => void\r\n on(event: 'virtual-scroll', callback: VirtualScrollCallback): () => void\r\n on(event: LenisEvent, callback: any) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n /**\r\n * Remove an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n off(event: 'scroll', callback: ScrollCallback): void\r\n off(event: 'virtual-scroll', callback: VirtualScrollCallback): void\r\n off(event: LenisEvent, callback: any) {\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: VirtualScrollData) => {\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 HTMLElement &&\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 /**\r\n * Force lenis to recalculate the dimensions\r\n */\r\n resize() {\r\n this.dimensions.resize()\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.emit()\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 if (this.#resetVelocityTimeout !== null) {\r\n clearTimeout(this.#resetVelocityTimeout)\r\n this.#resetVelocityTimeout = null\r\n }\r\n\r\n if (this.#preventNextNativeScrollEvent) {\r\n this.#preventNextNativeScrollEvent = false\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.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 }\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 /**\r\n * Start lenis scroll after it has been stopped\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 /**\r\n * Stop lenis scroll\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 /**\r\n * RequestAnimationFrame for lenis\r\n *\r\n * @param time The time in ms from an external clock like `requestAnimationFrame` or Tempus\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 /**\r\n * Scroll to a target value\r\n *\r\n * @param target The target value to scroll to\r\n * @param options The options for the scroll\r\n *\r\n * @example\r\n * lenis.scrollTo(100, {\r\n * offset: 100,\r\n * duration: 1,\r\n * easing: (t) => 1 - Math.cos((t * Math.PI) / 2),\r\n * lerp: 0.1,\r\n * onStart: () => {\r\n * console.log('onStart')\r\n * },\r\n * onComplete: () => {\r\n * console.log('onComplete')\r\n * },\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 }: ScrollToOptions = {}\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) {\r\n onStart?.(this)\r\n onComplete?.(this)\r\n return\r\n }\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 // 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 this.#preventNextNativeScrollEvent = false\r\n })\r\n }\r\n\r\n /**\r\n * The root element on which lenis is instanced\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 /**\r\n * The limit which is the maximum scroll value\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 /**\r\n * Whether or not the scroll is horizontal\r\n */\r\n get isHorizontal() {\r\n return this.options.orientation === 'horizontal'\r\n }\r\n\r\n /**\r\n * The actual scroll value\r\n */\r\n get actualScroll() {\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 /**\r\n * The current scroll value\r\n */\r\n get scroll() {\r\n return this.options.infinite\r\n ? modulo(this.animatedScroll, this.limit)\r\n : this.animatedScroll\r\n }\r\n\r\n /**\r\n * The progress of the scroll relative to the limit\r\n */\r\n get progress() {\r\n // avoid progress to be NaN\r\n return this.limit === 0 ? 1 : this.scroll / this.limit\r\n }\r\n\r\n /**\r\n * Current scroll state\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 /**\r\n * Check if lenis is stopped\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 /**\r\n * Check if lenis is locked\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 /**\r\n * Check if lenis is smooth scrolling\r\n */\r\n get isSmooth() {\r\n return this.isScrolling === 'smooth'\r\n }\r\n\r\n /**\r\n * The class name applied to the wrapper element\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 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":[],"mappings":";;;;;;IAAA;IACA;AACA;IACA;IACA;AACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;AACA;AAoQA;IACO,SAAS,sBAAsB,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE;IACjE,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI,CA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CAAA,CAAE,CAAC,IAAI,EAAE,CAAA;SAC3D;QAEO,gBAAgB,GAAA;YACtB,IAAI,CAAC,WAAW,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS;IACpD,aAAA,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;IAC5B,aAAA,IAAI,EAAE,CAAA;SACV;IACF,CAAA;;;;;;;;;","x_google_ignoreList":[0]} \ No newline at end of file +{"version":3,"file":"lenis.js","sources":["../../src/maths.ts","../../src/animate.ts","../../src/debounce.ts","../../src/dimensions.ts","../../src/emitter.ts","../../src/virtual-scroll.ts","../../src/index.ts"],"sourcesContent":["/**\r\n * Clamp a value between a minimum and maximum value\r\n *\r\n * @param min Minimum value\r\n * @param input Value to clamp\r\n * @param max Maximum value\r\n * @returns Clamped value\r\n */\r\nexport function clamp(min: number, input: number, max: number) {\r\n return Math.max(min, Math.min(input, max))\r\n}\r\n\r\n/**\r\n * Truncate a floating-point number to a specified number of decimal places\r\n *\r\n * @param value Value to truncate\r\n * @param decimals Number of decimal places to truncate to\r\n * @returns Truncated value\r\n */\r\nexport function truncate(value: number, decimals = 0) {\r\n return parseFloat(value.toFixed(decimals))\r\n}\r\n\r\n/**\r\n * Linearly interpolate between two values using an amount (0 <= t <= 1)\r\n *\r\n * @param x First value\r\n * @param y Second value\r\n * @param t Amount to interpolate (0 <= t <= 1)\r\n * @returns Interpolated value\r\n */\r\nexport function lerp(x: number, y: number, t: number) {\r\n return (1 - t) * x + t * y\r\n}\r\n\r\n/**\r\n * Damp a value over time using a damping factor\r\n * {@link http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/}\r\n *\r\n * @param x Initial value\r\n * @param y Target value\r\n * @param lambda Damping factor\r\n * @param dt Time elapsed since the last update\r\n * @returns Damped value\r\n */\r\nexport function damp(x: number, y: number, lambda: number, deltaTime: number) {\r\n return lerp(x, y, 1 - Math.exp(-lambda * deltaTime))\r\n}\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 * {@link https://anguscroll.com/just/just-modulo}\r\n *\r\n * @param n Dividend\r\n * @param d Divisor\r\n * @returns Modulo\r\n */\r\nexport function modulo(n: number, d: number) {\r\n return ((n % d) + d) % d\r\n}\r\n","import { clamp, damp } from './maths'\r\nimport type { EasingFunction, FromToOptions, OnUpdateCallback } from './types'\r\n\r\n/**\r\n * Animate class to handle value animations with lerping or easing\r\n *\r\n * @example\r\n * const animate = new Animate()\r\n * animate.fromTo(0, 100, { duration: 1, easing: (t) => t })\r\n * animate.advance(0.5) // 50\r\n */\r\nexport class Animate {\r\n isRunning = false\r\n value = 0\r\n from = 0\r\n to = 0\r\n currentTime = 0\r\n\r\n // These are instanciated in the fromTo method\r\n lerp?: number\r\n duration?: number\r\n easing?: EasingFunction\r\n onUpdate?: OnUpdateCallback\r\n\r\n /**\r\n * Advance the animation by the given delta time\r\n *\r\n * @param deltaTime - The time in seconds to advance the animation\r\n */\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 /**\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 *\r\n * @param from - The starting value\r\n * @param to - The ending value\r\n * @param options - Options for the animation\r\n */\r\n fromTo(\r\n from: number,\r\n to: number,\r\n { lerp, duration, easing, onStart, onUpdate }: FromToOptions\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 void>(\r\n callback: CB,\r\n delay: number\r\n) {\r\n let timer: number | undefined\r\n return function (this: T, ...args: Parameters) {\r\n let context = this\r\n clearTimeout(timer)\r\n timer = setTimeout(() => {\r\n timer = undefined\r\n callback.apply(context, args)\r\n }, delay)\r\n }\r\n}\r\n","import { debounce } from './debounce'\r\n\r\n/**\r\n * Dimensions class to handle the size of the content and wrapper\r\n *\r\n * @example\r\n * const dimensions = new Dimensions(wrapper, content)\r\n * dimensions.on('resize', (e) => {\r\n * console.log(e.width, e.height)\r\n * })\r\n */\r\nexport class Dimensions {\r\n width = 0\r\n height = 0\r\n scrollHeight = 0\r\n scrollWidth = 0\r\n\r\n // These are instanciated in the constructor as they need information from the options\r\n private debouncedResize?: (...args: unknown[]) => void\r\n private wrapperResizeObserver?: ResizeObserver\r\n private contentResizeObserver?: ResizeObserver\r\n\r\n constructor(\r\n private wrapper: HTMLElement | Window,\r\n private content: HTMLElement,\r\n { autoResize = true, debounce: debounceValue = 250 } = {}\r\n ) {\r\n if (autoResize) {\r\n this.debouncedResize = debounce(this.resize, debounceValue)\r\n\r\n if (this.wrapper instanceof 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\r\n if (this.wrapper === window && this.debouncedResize) {\r\n window.removeEventListener('resize', this.debouncedResize, 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 instanceof 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 instanceof 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","/**\r\n * Emitter class to handle events\r\n * @example\r\n * const emitter = new Emitter()\r\n * emitter.on('event', (data) => {\r\n * console.log(data)\r\n * })\r\n * emitter.emit('event', 'data')\r\n */\r\nexport class Emitter {\r\n private events: Record<\r\n string,\r\n Array<(...args: unknown[]) => void> | undefined\r\n > = {}\r\n\r\n /**\r\n * Emit an event with the given data\r\n * @param event Event name\r\n * @param args Data to pass to the event handlers\r\n */\r\n emit(event: string, ...args: unknown[]) {\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 /**\r\n * Add a callback to the event\r\n * @param event Event name\r\n * @param cb Callback function\r\n * @returns Unsubscribe function\r\n */\r\n on void>(event: string, cb: 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 /**\r\n * Remove a callback from the event\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n off void>(event: string, callback: CB) {\r\n this.events[event] = this.events[event]?.filter((i) => callback !== i)\r\n }\r\n\r\n /**\r\n * Remove all event listeners and clean up\r\n */\r\n destroy() {\r\n this.events = {}\r\n }\r\n}\r\n","import { Emitter } from './emitter'\r\nimport { VirtualScrollCallback } from './types'\r\n\r\nconst LINE_HEIGHT = 100 / 6\r\nconst listenerOptions: AddEventListenerOptions = { passive: false }\r\n\r\nexport class VirtualScroll {\r\n touchStart = {\r\n x: 0,\r\n y: 0,\r\n }\r\n lastDelta = {\r\n x: 0,\r\n y: 0,\r\n }\r\n window = {\r\n width: 0,\r\n height: 0,\r\n }\r\n private emitter = new Emitter()\r\n\r\n constructor(\r\n private element: HTMLElement,\r\n private options = { wheelMultiplier: 1, touchMultiplier: 1 }\r\n ) {\r\n window.addEventListener('resize', this.onWindowResize, false)\r\n this.onWindowResize()\r\n\r\n this.element.addEventListener('wheel', this.onWheel, listenerOptions)\r\n this.element.addEventListener(\r\n 'touchstart',\r\n this.onTouchStart,\r\n listenerOptions\r\n )\r\n this.element.addEventListener(\r\n 'touchmove',\r\n this.onTouchMove,\r\n listenerOptions\r\n )\r\n this.element.addEventListener('touchend', this.onTouchEnd, listenerOptions)\r\n }\r\n\r\n /**\r\n * Add an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n on(event: string, callback: VirtualScrollCallback) {\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, listenerOptions)\r\n this.element.removeEventListener(\r\n 'touchstart',\r\n this.onTouchStart,\r\n listenerOptions\r\n )\r\n this.element.removeEventListener(\r\n 'touchmove',\r\n this.onTouchMove,\r\n listenerOptions\r\n )\r\n this.element.removeEventListener(\r\n 'touchend',\r\n this.onTouchEnd,\r\n listenerOptions\r\n )\r\n }\r\n\r\n /**\r\n * Event handler for 'touchstart' event\r\n *\r\n * @param event Touch event\r\n */\r\n onTouchStart = (event: TouchEvent) => {\r\n // @ts-expect-error - event.targetTouches is not defined\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 - event.targetTouches is not defined\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.options.touchMultiplier\r\n const deltaY = -(clientY - this.touchStart.y) * this.options.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.window.width : 1\r\n const multiplierY =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.window.height : 1\r\n\r\n deltaX *= multiplierX\r\n deltaY *= multiplierY\r\n\r\n deltaX *= this.options.wheelMultiplier\r\n deltaY *= this.options.wheelMultiplier\r\n\r\n this.emitter.emit('scroll', { deltaX, deltaY, event })\r\n }\r\n\r\n onWindowResize = () => {\r\n this.window = {\r\n width: window.innerWidth,\r\n height: window.innerHeight,\r\n }\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 type {\r\n LenisEvent,\r\n LenisOptions,\r\n ScrollCallback,\r\n Scrolling,\r\n ScrollToOptions,\r\n UserData,\r\n VirtualScrollCallback,\r\n VirtualScrollData,\r\n} from './types'\r\nimport { VirtualScroll } from './virtual-scroll'\r\n\r\n// Types\r\nexport * from './types'\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 OptionalPick = Omit & Partial>\r\n\r\nexport default class Lenis {\r\n private _isScrolling: Scrolling = false // true when scroll is animating\r\n private _isStopped = false // true if user should not be able to scroll - enable/disable programmatically\r\n private _isLocked = false // same as isStopped but enabled/disabled when scroll reaches target\r\n private _preventNextNativeScrollEvent = false\r\n private _resetVelocityTimeout: number | null = null\r\n\r\n /**\r\n * Whether or not the user is touching the screen\r\n */\r\n isTouching?: boolean\r\n /**\r\n * The time in ms since the lenis instance was created\r\n */\r\n time = 0\r\n /**\r\n * User data that will be forwarded through the scroll event\r\n *\r\n * @example\r\n * lenis.scrollTo(100, {\r\n * userData: {\r\n * foo: 'bar'\r\n * }\r\n * })\r\n */\r\n userData: UserData = {}\r\n /**\r\n * The last velocity of the scroll\r\n */\r\n lastVelocity = 0\r\n /**\r\n * The current velocity of the scroll\r\n */\r\n velocity = 0\r\n /**\r\n * The direction of the scroll\r\n */\r\n direction: 1 | -1 | 0 = 0\r\n /**\r\n * The options passed to the lenis instance\r\n */\r\n options: OptionalPick<\r\n Required,\r\n 'duration' | 'prevent' | 'virtualScroll'\r\n >\r\n /**\r\n * The target scroll value\r\n */\r\n targetScroll: number\r\n /**\r\n * The animated scroll value\r\n */\r\n animatedScroll: number\r\n\r\n // These are instanciated here as they don't need information from the options\r\n private readonly animate = new Animate()\r\n private readonly emitter = new Emitter()\r\n // These are instanciated in the constructor as they need information from the options\r\n readonly dimensions: Dimensions // This is not private because it's used in the Snap class\r\n private readonly virtualScroll: VirtualScroll\r\n\r\n constructor({\r\n wrapper = window,\r\n content = document.documentElement,\r\n eventsTarget = wrapper,\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 // Set version\r\n window.lenisVersion = version\r\n\r\n // Check 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 // Setup options\r\n this.options = {\r\n wrapper,\r\n content,\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 }\r\n\r\n // Setup dimensions instance\r\n this.dimensions = new Dimensions(wrapper, content, { autoResize })\r\n\r\n // Setup class name\r\n this.updateClassName()\r\n\r\n // Set the initial scroll value for all scroll information\r\n this.targetScroll = this.animatedScroll = this.actualScroll\r\n\r\n // Add event listeners\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 // Setup virtual scroll instance\r\n this.virtualScroll = new VirtualScroll(eventsTarget as HTMLElement, {\r\n touchMultiplier,\r\n wheelMultiplier,\r\n })\r\n this.virtualScroll.on('scroll', this.onVirtualScroll)\r\n }\r\n\r\n /**\r\n * Destroy the lenis instance, remove all event listeners and clean up the class name\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\r\n /**\r\n * Add an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n * @returns Unsubscribe function\r\n */\r\n on(event: 'scroll', callback: ScrollCallback): () => void\r\n on(event: 'virtual-scroll', callback: VirtualScrollCallback): () => void\r\n on(event: LenisEvent, callback: any) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n /**\r\n * Remove an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n off(event: 'scroll', callback: ScrollCallback): void\r\n off(event: 'virtual-scroll', callback: VirtualScrollCallback): void\r\n off(event: LenisEvent, callback: any) {\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: VirtualScrollData) => {\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 HTMLElement &&\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 /**\r\n * Force lenis to recalculate the dimensions\r\n */\r\n resize() {\r\n this.dimensions.resize()\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.emit()\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 if (this._resetVelocityTimeout !== null) {\r\n clearTimeout(this._resetVelocityTimeout)\r\n this._resetVelocityTimeout = null\r\n }\r\n\r\n if (this._preventNextNativeScrollEvent) {\r\n this._preventNextNativeScrollEvent = false\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.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 }\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 /**\r\n * Start lenis scroll after it has been stopped\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 /**\r\n * Stop lenis scroll\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 /**\r\n * RequestAnimationFrame for lenis\r\n *\r\n * @param time The time in ms from an external clock like `requestAnimationFrame` or Tempus\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 /**\r\n * Scroll to a target value\r\n *\r\n * @param target The target value to scroll to\r\n * @param options The options for the scroll\r\n *\r\n * @example\r\n * lenis.scrollTo(100, {\r\n * offset: 100,\r\n * duration: 1,\r\n * easing: (t) => 1 - Math.cos((t * Math.PI) / 2),\r\n * lerp: 0.1,\r\n * onStart: () => {\r\n * console.log('onStart')\r\n * },\r\n * onComplete: () => {\r\n * console.log('onComplete')\r\n * },\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 }: ScrollToOptions = {}\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) {\r\n onStart?.(this)\r\n onComplete?.(this)\r\n return\r\n }\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 // 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 this._preventNextNativeScrollEvent = false\r\n })\r\n }\r\n\r\n /**\r\n * The root element on which lenis is instanced\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 /**\r\n * The limit which is the maximum scroll value\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 /**\r\n * Whether or not the scroll is horizontal\r\n */\r\n get isHorizontal() {\r\n return this.options.orientation === 'horizontal'\r\n }\r\n\r\n /**\r\n * The actual scroll value\r\n */\r\n get actualScroll() {\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 /**\r\n * The current scroll value\r\n */\r\n get scroll() {\r\n return this.options.infinite\r\n ? modulo(this.animatedScroll, this.limit)\r\n : this.animatedScroll\r\n }\r\n\r\n /**\r\n * The progress of the scroll relative to the limit\r\n */\r\n get progress() {\r\n // avoid progress to be NaN\r\n return this.limit === 0 ? 1 : this.scroll / this.limit\r\n }\r\n\r\n /**\r\n * Current scroll state\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 /**\r\n * Check if lenis is stopped\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 /**\r\n * Check if lenis is locked\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 /**\r\n * Check if lenis is smooth scrolling\r\n */\r\n get isSmooth() {\r\n return this.isScrolling === 'smooth'\r\n }\r\n\r\n /**\r\n * The class name applied to the wrapper element\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 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":[],"mappings":";;;;;;;;EAAA;;;;;;;EAOG;WACa,KAA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AEO,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;OAC3D;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;EACF;;;;;;;;"} \ No newline at end of file diff --git a/dist/lenis.min.js b/dist/lenis.min.js index 35ee1a19..b5ba5530 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 __classPrivateFieldGet(t,e,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(t):s?s.value:e.get(t)}function __classPrivateFieldSet(t,e,i,s,o){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?o.call(t,i):o?o.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;function clamp(t,e,i){return Math.max(t,Math.min(e,i))}class Animate{constructor(){this.isRunning=!1,this.value=0,this.from=0,this.to=0,this.currentTime=0}advance(t){var e;if(!this.isRunning)return;let i=!1;if(this.duration&&this.easing){this.currentTime+=t;const e=clamp(0,this.currentTime/this.duration,1);i=e>=1;const s=i?1:this.easing(e);this.value=this.from+(this.to-this.from)*s}else 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,i=!0)):(this.value=this.to,i=!0);i&&this.stop(),null===(e=this.onUpdate)||void 0===e||e.call(this,this.value,i)}stop(){this.isRunning=!1}fromTo(t,e,{lerp:i,duration:s,easing:o,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,null==n||n(),this.onUpdate=r}}class Dimensions{constructor(t,e,{autoResize:i=!0,debounce:s=250}={}){this.wrapper=t,this.content=e,this.width=0,this.height=0,this.scrollHeight=0,this.scrollWidth=0,this.resize=()=>{this.onWrapperResize(),this.onContentResize()},this.onWrapperResize=()=>{this.wrapper instanceof Window?(this.width=window.innerWidth,this.height=window.innerHeight):(this.width=this.wrapper.clientWidth,this.height=this.wrapper.clientHeight)},this.onContentResize=()=>{this.wrapper instanceof Window?(this.scrollHeight=this.content.scrollHeight,this.scrollWidth=this.content.scrollWidth):(this.scrollHeight=this.wrapper.scrollHeight,this.scrollWidth=this.wrapper.scrollWidth)},i&&(this.debouncedResize=function debounce(t,e){let i;return function(...s){let o=this;clearTimeout(i),i=setTimeout((()=>{i=void 0,t.apply(o,s)}),e)}}(this.resize,s),this.wrapper instanceof 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(){var t,e;null===(t=this.wrapperResizeObserver)||void 0===t||t.disconnect(),null===(e=this.contentResizeObserver)||void 0===e||e.disconnect(),this.wrapper===window&&this.debouncedResize&&window.removeEventListener("resize",this.debouncedResize,!1)}get limit(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}}class Emitter{constructor(){this.events={}}emit(t,...e){var i;let s=this.events[t]||[];for(let t=0,o=s.length;t{var i;this.events[t]=null===(i=this.events[t])||void 0===i?void 0:i.filter((t=>e!==t))}}off(t,e){var i;this.events[t]=null===(i=this.events[t])||void 0===i?void 0:i.filter((t=>e!==t))}destroy(){this.events={}}}const t=100/6,e={passive:!1};class VirtualScroll{constructor(i,s={wheelMultiplier:1,touchMultiplier:1}){this.element=i,this.options=s,this.touchStart={x:0,y:0},this.lastDelta={x:0,y:0},this.window={width:0,height:0},this.emitter=new Emitter,this.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})},this.onTouchMove=t=>{const{clientX:e,clientY:i}=t.targetTouches?t.targetTouches[0]:t,s=-(e-this.touchStart.x)*this.options.touchMultiplier,o=-(i-this.touchStart.y)*this.options.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})},this.onTouchEnd=t=>{this.emitter.emit("scroll",{deltaX:this.lastDelta.x,deltaY:this.lastDelta.y,event:t})},this.onWheel=e=>{let{deltaX:i,deltaY:s,deltaMode:o}=e;i*=1===o?t:2===o?this.window.width:1,s*=1===o?t:2===o?this.window.height:1,i*=this.options.wheelMultiplier,s*=this.options.wheelMultiplier,this.emitter.emit("scroll",{deltaX:i,deltaY:s,event:e})},this.onWindowResize=()=>{this.window={width:window.innerWidth,height:window.innerHeight}},window.addEventListener("resize",this.onWindowResize,!1),this.onWindowResize(),this.element.addEventListener("wheel",this.onWheel,e),this.element.addEventListener("touchstart",this.onTouchStart,e),this.element.addEventListener("touchmove",this.onTouchMove,e),this.element.addEventListener("touchend",this.onTouchEnd,e)}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,e),this.element.removeEventListener("touchstart",this.onTouchStart,e),this.element.removeEventListener("touchmove",this.onTouchMove,e),this.element.removeEventListener("touchend",this.onTouchEnd,e)}}var i,s,o,n,r;return i=new WeakMap,s=new WeakMap,o=new WeakMap,n=new WeakMap,r=new WeakMap,class Lenis{constructor({wrapper:t=window,content:e=document.documentElement,eventsTarget:l=t,smoothWheel:h=!0,syncTouch:a=!1,syncTouchLerp:c=.075,touchInertiaMultiplier:d=35,duration:u,easing:p=(t=>Math.min(1,1.001-Math.pow(2,-10*t))),lerp:m=.1,infinite:v=!1,orientation:w="vertical",gestureOrientation:f="vertical",touchMultiplier:g=1,wheelMultiplier:S=1,autoResize:y=!0,prevent:E,virtualScroll:_,__experimental__naiveDimensions:T=!1}={}){i.set(this,!1),s.set(this,!1),o.set(this,!1),n.set(this,!1),r.set(this,null),this.time=0,this.userData={},this.lastVelocity=0,this.velocity=0,this.direction=0,this.animate=new Animate,this.emitter=new Emitter,this.onPointerDown=t=>{1===t.button&&this.reset()},this.onVirtualScroll=t=>{if("function"==typeof this.options.virtualScroll&&!1===this.options.virtualScroll(t))return;const{deltaX:e,deltaY:i,event:s}=t;if(this.emitter.emit("virtual-scroll",{deltaX:e,deltaY:i,event:s}),s.ctrlKey)return;const o=s.type.includes("touch"),n=s.type.includes("wheel");this.isTouching="touchstart"===s.type||"touchmove"===s.type;if(this.options.syncTouch&&o&&"touchstart"===s.type&&!this.isStopped&&!this.isLocked)return void this.reset();const r=0===e&&0===i,l="vertical"===this.options.gestureOrientation&&0===i||"horizontal"===this.options.gestureOrientation&&0===e;if(r||l)return;let h=s.composedPath();h=h.slice(0,h.indexOf(this.rootElement));const a=this.options.prevent;if(h.find((t=>{var e,i,s,r,l;return t instanceof HTMLElement&&("function"==typeof a&&(null==a?void 0:a(t))||(null===(e=t.hasAttribute)||void 0===e?void 0:e.call(t,"data-lenis-prevent"))||o&&(null===(i=t.hasAttribute)||void 0===i?void 0:i.call(t,"data-lenis-prevent-touch"))||n&&(null===(s=t.hasAttribute)||void 0===s?void 0:s.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 s.preventDefault();if(!(this.options.syncTouch&&o||this.options.smoothWheel&&n))return this.isScrolling="native",void this.animate.stop();s.preventDefault();let c=i;"both"===this.options.gestureOrientation?c=Math.abs(i)>Math.abs(e)?i:e:"horizontal"===this.options.gestureOrientation&&(c=e);const d=o&&this.options.syncTouch,u=o&&"touchend"===s.type&&Math.abs(c)>5;u&&(c=this.velocity*this.options.touchInertiaMultiplier),this.scrollTo(this.targetScroll+c,Object.assign({programmatic:!1},d?{lerp:u?this.options.syncTouchLerp:1}:{lerp:this.options.lerp,duration:this.options.duration,easing:this.options.easing}))},this.onNativeScroll=()=>{if(null!==__classPrivateFieldGet(this,r,"f")&&(clearTimeout(__classPrivateFieldGet(this,r,"f")),__classPrivateFieldSet(this,r,null,"f")),__classPrivateFieldGet(this,n,"f"))__classPrivateFieldSet(this,n,!1,"f");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="native",this.emit(),0!==this.velocity&&__classPrivateFieldSet(this,r,setTimeout((()=>{this.lastVelocity=this.velocity,this.velocity=0,this.isScrolling=!1,this.emit()}),400),"f")}},window.lenisVersion="1.1.12",t&&t!==document.documentElement&&t!==document.body||(t=window),this.options={wrapper:t,content:e,eventsTarget:l,smoothWheel:h,syncTouch:a,syncTouchLerp:c,touchInertiaMultiplier:d,duration:u,easing:p,lerp:m,infinite:v,gestureOrientation:f,orientation:w,touchMultiplier:g,wheelMultiplier:S,autoResize:y,prevent:E,virtualScroll:_,__experimental__naiveDimensions:T},this.dimensions=new Dimensions(t,e,{autoResize:y}),this.updateClassName(),this.targetScroll=this.animatedScroll=this.actualScroll,this.options.wrapper.addEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.addEventListener("pointerdown",this.onPointerDown,!1),this.virtualScroll=new VirtualScroll(l,{touchMultiplier:g,wheelMultiplier:S}),this.virtualScroll.on("scroll",this.onVirtualScroll)}destroy(){this.emitter.destroy(),this.options.wrapper.removeEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.removeEventListener("pointerdown",this.onPointerDown,!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(),this.animatedScroll=this.targetScroll=this.actualScroll,this.emit()}emit(){this.emitter.emit("scroll",this)}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=this.options.lerp,onStart:l,onComplete:h,force:a=!1,programmatic:c=!0,userData:d}={}){if(!this.isStopped&&!this.isLocked||a){if("string"==typeof t&&["top","left","start"].includes(t))t=0;else if("string"==typeof t&&["bottom","right","end"].includes(t))t=this.limit;else{let i;if("string"==typeof t?i=document.querySelector(t):t instanceof HTMLElement&&(null==t?void 0:t.nodeType)&&(i=t),i){if(this.options.wrapper!==window){const t=this.rootElement.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),t===this.targetScroll)return null==l||l(this),void(null==h||h(this));if(this.userData=null!=d?d:{},i)return this.animatedScroll=this.targetScroll=t,this.setScroll(this.scroll),this.reset(),this.preventNextNativeScrollEvent(),this.emit(),null==h||h(this),void(this.userData={});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(),e&&(this.reset(),this.emit(),null==h||h(this),this.userData={},this.preventNextNativeScrollEvent())}})}}}preventNextNativeScrollEvent(){__classPrivateFieldSet(this,n,!0,"f"),requestAnimationFrame((()=>{__classPrivateFieldSet(this,n,!1,"f")}))}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 __classPrivateFieldGet(this,i,"f")}set isScrolling(t){__classPrivateFieldGet(this,i,"f")!==t&&(__classPrivateFieldSet(this,i,t,"f"),this.updateClassName())}get isStopped(){return __classPrivateFieldGet(this,s,"f")}set isStopped(t){__classPrivateFieldGet(this,s,"f")!==t&&(__classPrivateFieldSet(this,s,t,"f"),this.updateClassName())}get isLocked(){return __classPrivateFieldGet(this,o,"f")}set isLocked(t){__classPrivateFieldGet(this,o,"f")!==t&&(__classPrivateFieldSet(this,o,t,"f"),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,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t="undefined"!=typeof globalThis?globalThis:t||self).Lenis=i()}(this,(function(){"use strict";function clamp(t,i,e){return Math.max(t,Math.min(i,e))}class Animate{constructor(){this.isRunning=!1,this.value=0,this.from=0,this.to=0,this.currentTime=0}advance(t){var i;if(!this.isRunning)return;let e=!1;if(this.duration&&this.easing){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}else this.lerp?(this.value=function damp(t,i,e,s){return function lerp(t,i,e){return(1-e)*t+e*i}(t,i,1-Math.exp(-e*s))}(this.value,this.to,60*this.lerp,t),Math.round(this.value)===this.to&&(this.value=this.to,e=!0)):(this.value=this.to,e=!0);e&&this.stop(),null===(i=this.onUpdate)||void 0===i||i.call(this,this.value,e)}stop(){this.isRunning=!1}fromTo(t,i,{lerp:e,duration:s,easing:o,onStart:n,onUpdate:l}){this.from=this.value=t,this.to=i,this.lerp=e,this.duration=s,this.easing=o,this.currentTime=0,this.isRunning=!0,null==n||n(),this.onUpdate=l}}class Dimensions{constructor(t,i,{autoResize:e=!0,debounce:s=250}={}){this.wrapper=t,this.content=i,this.width=0,this.height=0,this.scrollHeight=0,this.scrollWidth=0,this.resize=()=>{this.onWrapperResize(),this.onContentResize()},this.onWrapperResize=()=>{this.wrapper instanceof Window?(this.width=window.innerWidth,this.height=window.innerHeight):(this.width=this.wrapper.clientWidth,this.height=this.wrapper.clientHeight)},this.onContentResize=()=>{this.wrapper instanceof Window?(this.scrollHeight=this.content.scrollHeight,this.scrollWidth=this.content.scrollWidth):(this.scrollHeight=this.wrapper.scrollHeight,this.scrollWidth=this.wrapper.scrollWidth)},e&&(this.debouncedResize=function debounce(t,i){let e;return function(...s){let o=this;clearTimeout(e),e=setTimeout((()=>{e=void 0,t.apply(o,s)}),i)}}(this.resize,s),this.wrapper instanceof 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(){var t,i;null===(t=this.wrapperResizeObserver)||void 0===t||t.disconnect(),null===(i=this.contentResizeObserver)||void 0===i||i.disconnect(),this.wrapper===window&&this.debouncedResize&&window.removeEventListener("resize",this.debouncedResize,!1)}get limit(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}}class Emitter{constructor(){this.events={}}emit(t,...i){var e;let s=this.events[t]||[];for(let t=0,o=s.length;t{var e;this.events[t]=null===(e=this.events[t])||void 0===e?void 0:e.filter((t=>i!==t))}}off(t,i){var e;this.events[t]=null===(e=this.events[t])||void 0===e?void 0:e.filter((t=>i!==t))}destroy(){this.events={}}}const t=100/6,i={passive:!1};class VirtualScroll{constructor(e,s={wheelMultiplier:1,touchMultiplier:1}){this.element=e,this.options=s,this.touchStart={x:0,y:0},this.lastDelta={x:0,y:0},this.window={width:0,height:0},this.emitter=new Emitter,this.onTouchStart=t=>{const{clientX:i,clientY:e}=t.targetTouches?t.targetTouches[0]:t;this.touchStart.x=i,this.touchStart.y=e,this.lastDelta={x:0,y:0},this.emitter.emit("scroll",{deltaX:0,deltaY:0,event:t})},this.onTouchMove=t=>{const{clientX:i,clientY:e}=t.targetTouches?t.targetTouches[0]:t,s=-(i-this.touchStart.x)*this.options.touchMultiplier,o=-(e-this.touchStart.y)*this.options.touchMultiplier;this.touchStart.x=i,this.touchStart.y=e,this.lastDelta={x:s,y:o},this.emitter.emit("scroll",{deltaX:s,deltaY:o,event:t})},this.onTouchEnd=t=>{this.emitter.emit("scroll",{deltaX:this.lastDelta.x,deltaY:this.lastDelta.y,event:t})},this.onWheel=i=>{let{deltaX:e,deltaY:s,deltaMode:o}=i;e*=1===o?t:2===o?this.window.width:1,s*=1===o?t:2===o?this.window.height:1,e*=this.options.wheelMultiplier,s*=this.options.wheelMultiplier,this.emitter.emit("scroll",{deltaX:e,deltaY:s,event:i})},this.onWindowResize=()=>{this.window={width:window.innerWidth,height:window.innerHeight}},window.addEventListener("resize",this.onWindowResize,!1),this.onWindowResize(),this.element.addEventListener("wheel",this.onWheel,i),this.element.addEventListener("touchstart",this.onTouchStart,i),this.element.addEventListener("touchmove",this.onTouchMove,i),this.element.addEventListener("touchend",this.onTouchEnd,i)}on(t,i){return this.emitter.on(t,i)}destroy(){this.emitter.destroy(),window.removeEventListener("resize",this.onWindowResize,!1),this.element.removeEventListener("wheel",this.onWheel,i),this.element.removeEventListener("touchstart",this.onTouchStart,i),this.element.removeEventListener("touchmove",this.onTouchMove,i),this.element.removeEventListener("touchend",this.onTouchEnd,i)}}return class Lenis{constructor({wrapper:t=window,content:i=document.documentElement,eventsTarget:e=t,smoothWheel:s=!0,syncTouch:o=!1,syncTouchLerp:n=.075,touchInertiaMultiplier:l=35,duration:r,easing:h=(t=>Math.min(1,1.001-Math.pow(2,-10*t))),lerp:a=.1,infinite:c=!1,orientation:u="vertical",gestureOrientation:d="vertical",touchMultiplier:p=1,wheelMultiplier:m=1,autoResize:v=!0,prevent:g,virtualScroll:S,__experimental__naiveDimensions:w=!1}={}){this._isScrolling=!1,this._isStopped=!1,this._isLocked=!1,this._preventNextNativeScrollEvent=!1,this._resetVelocityTimeout=null,this.time=0,this.userData={},this.lastVelocity=0,this.velocity=0,this.direction=0,this.animate=new Animate,this.emitter=new Emitter,this.onPointerDown=t=>{1===t.button&&this.reset()},this.onVirtualScroll=t=>{if("function"==typeof this.options.virtualScroll&&!1===this.options.virtualScroll(t))return;const{deltaX:i,deltaY:e,event:s}=t;if(this.emitter.emit("virtual-scroll",{deltaX:i,deltaY:e,event:s}),s.ctrlKey)return;const o=s.type.includes("touch"),n=s.type.includes("wheel");this.isTouching="touchstart"===s.type||"touchmove"===s.type;if(this.options.syncTouch&&o&&"touchstart"===s.type&&!this.isStopped&&!this.isLocked)return void this.reset();const l=0===i&&0===e,r="vertical"===this.options.gestureOrientation&&0===e||"horizontal"===this.options.gestureOrientation&&0===i;if(l||r)return;let h=s.composedPath();h=h.slice(0,h.indexOf(this.rootElement));const a=this.options.prevent;if(h.find((t=>{var i,e,s,l,r;return t instanceof HTMLElement&&("function"==typeof a&&(null==a?void 0:a(t))||(null===(i=t.hasAttribute)||void 0===i?void 0:i.call(t,"data-lenis-prevent"))||o&&(null===(e=t.hasAttribute)||void 0===e?void 0:e.call(t,"data-lenis-prevent-touch"))||n&&(null===(s=t.hasAttribute)||void 0===s?void 0:s.call(t,"data-lenis-prevent-wheel"))||(null===(l=t.classList)||void 0===l?void 0:l.contains("lenis"))&&!(null===(r=t.classList)||void 0===r?void 0:r.contains("lenis-stopped")))})))return;if(this.isStopped||this.isLocked)return void s.preventDefault();if(!(this.options.syncTouch&&o||this.options.smoothWheel&&n))return this.isScrolling="native",void this.animate.stop();s.preventDefault();let c=e;"both"===this.options.gestureOrientation?c=Math.abs(e)>Math.abs(i)?e:i:"horizontal"===this.options.gestureOrientation&&(c=i);const u=o&&this.options.syncTouch,d=o&&"touchend"===s.type&&Math.abs(c)>5;d&&(c=this.velocity*this.options.touchInertiaMultiplier),this.scrollTo(this.targetScroll+c,Object.assign({programmatic:!1},u?{lerp:d?this.options.syncTouchLerp:1}:{lerp:this.options.lerp,duration:this.options.duration,easing:this.options.easing}))},this.onNativeScroll=()=>{if(null!==this._resetVelocityTimeout&&(clearTimeout(this._resetVelocityTimeout),this._resetVelocityTimeout=null),this._preventNextNativeScrollEvent)this._preventNextNativeScrollEvent=!1;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="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.13",t&&t!==document.documentElement&&t!==document.body||(t=window),this.options={wrapper:t,content:i,eventsTarget:e,smoothWheel:s,syncTouch:o,syncTouchLerp:n,touchInertiaMultiplier:l,duration:r,easing:h,lerp:a,infinite:c,gestureOrientation:d,orientation:u,touchMultiplier:p,wheelMultiplier:m,autoResize:v,prevent:g,virtualScroll:S,__experimental__naiveDimensions:w},this.dimensions=new Dimensions(t,i,{autoResize:v}),this.updateClassName(),this.targetScroll=this.animatedScroll=this.actualScroll,this.options.wrapper.addEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.addEventListener("pointerdown",this.onPointerDown,!1),this.virtualScroll=new VirtualScroll(e,{touchMultiplier:p,wheelMultiplier:m}),this.virtualScroll.on("scroll",this.onVirtualScroll)}destroy(){this.emitter.destroy(),this.options.wrapper.removeEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.removeEventListener("pointerdown",this.onPointerDown,!1),this.virtualScroll.destroy(),this.dimensions.destroy(),this.cleanUpClassName()}on(t,i){return this.emitter.on(t,i)}off(t,i){return this.emitter.off(t,i)}setScroll(t){this.isHorizontal?this.rootElement.scrollLeft=t:this.rootElement.scrollTop=t}resize(){this.dimensions.resize(),this.animatedScroll=this.targetScroll=this.actualScroll,this.emit()}emit(){this.emitter.emit("scroll",this)}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 i=t-(this.time||t);this.time=t,this.animate.advance(.001*i)}scrollTo(t,{offset:i=0,immediate:e=!1,lock:s=!1,duration:o=this.options.duration,easing:n=this.options.easing,lerp:l=this.options.lerp,onStart:r,onComplete:h,force:a=!1,programmatic:c=!0,userData:u}={}){if(!this.isStopped&&!this.isLocked||a){if("string"==typeof t&&["top","left","start"].includes(t))t=0;else if("string"==typeof t&&["bottom","right","end"].includes(t))t=this.limit;else{let e;if("string"==typeof t?e=document.querySelector(t):t instanceof HTMLElement&&(null==t?void 0:t.nodeType)&&(e=t),e){if(this.options.wrapper!==window){const t=this.rootElement.getBoundingClientRect();i-=this.isHorizontal?t.left:t.top}const s=e.getBoundingClientRect();t=(this.isHorizontal?s.left:s.top)+this.animatedScroll}}if("number"==typeof t){if(t+=i,t=Math.round(t),this.options.infinite?c&&(this.targetScroll=this.animatedScroll=this.scroll):t=clamp(0,t,this.limit),t===this.targetScroll)return null==r||r(this),void(null==h||h(this));if(this.userData=null!=u?u:{},e)return this.animatedScroll=this.targetScroll=t,this.setScroll(this.scroll),this.reset(),this.preventNextNativeScrollEvent(),this.emit(),null==h||h(this),void(this.userData={});c||(this.targetScroll=t),this.animate.fromTo(this.animatedScroll,t,{duration:o,easing:n,lerp:l,onStart:()=>{s&&(this.isLocked=!0),this.isScrolling="smooth",null==r||r(this)},onUpdate:(t,i)=>{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),i||this.emit(),i&&(this.reset(),this.emit(),null==h||h(this),this.userData={},this.preventNextNativeScrollEvent())}})}}}preventNextNativeScrollEvent(){this._preventNextNativeScrollEvent=!0,requestAnimationFrame((()=>{this._preventNextNativeScrollEvent=!1}))}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,i){return(t%i+i)%i}(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 aa312b7b..84a589c1 100644 --- a/dist/lenis.min.js.map +++ b/dist/lenis.min.js.map @@ -1 +1 @@ -{"version":3,"file":"lenis.min.js","sources":["../../../node_modules/.pnpm/@rollup+plugin-typescript@11.1.6_rollup@4.14.3_tslib@2.6.2_typescript@5.4.5/node_modules/tslib/tslib.es6.js","../../src/maths.ts","../../src/animate.ts","../../src/dimensions.ts","../../src/debounce.ts","../../src/emitter.ts","../../src/virtual-scroll.ts","../../src/index.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n function next() {\r\n while (env.stack.length) {\r\n var rec = env.stack.pop();\r\n try {\r\n var result = rec.dispose && rec.dispose.call(rec.value);\r\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n};\r\n","/**\r\n * Clamp a value between a minimum and maximum value\r\n *\r\n * @param min Minimum value\r\n * @param input Value to clamp\r\n * @param max Maximum value\r\n * @returns Clamped value\r\n */\r\nexport function clamp(min: number, input: number, max: number) {\r\n return Math.max(min, Math.min(input, max))\r\n}\r\n\r\n/**\r\n * Truncate a floating-point number to a specified number of decimal places\r\n *\r\n * @param value Value to truncate\r\n * @param decimals Number of decimal places to truncate to\r\n * @returns Truncated value\r\n */\r\nexport function truncate(value: number, decimals = 0) {\r\n return parseFloat(value.toFixed(decimals))\r\n}\r\n\r\n/**\r\n * Linearly interpolate between two values using an amount (0 <= t <= 1)\r\n *\r\n * @param x First value\r\n * @param y Second value\r\n * @param t Amount to interpolate (0 <= t <= 1)\r\n * @returns Interpolated value\r\n */\r\nexport function lerp(x: number, y: number, t: number) {\r\n return (1 - t) * x + t * y\r\n}\r\n\r\n/**\r\n * Damp a value over time using a damping factor\r\n * {@link http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/}\r\n *\r\n * @param x Initial value\r\n * @param y Target value\r\n * @param lambda Damping factor\r\n * @param dt Time elapsed since the last update\r\n * @returns Damped value\r\n */\r\nexport function damp(x: number, y: number, lambda: number, deltaTime: number) {\r\n return lerp(x, y, 1 - Math.exp(-lambda * deltaTime))\r\n}\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 * {@link https://anguscroll.com/just/just-modulo}\r\n *\r\n * @param n Dividend\r\n * @param d Divisor\r\n * @returns Modulo\r\n */\r\nexport function modulo(n: number, d: number) {\r\n return ((n % d) + d) % d\r\n}\r\n","import { clamp, damp } from './maths'\r\nimport type { EasingFunction, FromToOptions, OnUpdateCallback } from './types'\r\n\r\n/**\r\n * Animate class to handle value animations with lerping or easing\r\n *\r\n * @example\r\n * const animate = new Animate()\r\n * animate.fromTo(0, 100, { duration: 1, easing: (t) => t })\r\n * animate.advance(0.5) // 50\r\n */\r\nexport class Animate {\r\n isRunning = false\r\n value = 0\r\n from = 0\r\n to = 0\r\n currentTime = 0\r\n\r\n // These are instanciated in the fromTo method\r\n lerp?: number\r\n duration?: number\r\n easing?: EasingFunction\r\n onUpdate?: OnUpdateCallback\r\n\r\n /**\r\n * Advance the animation by the given delta time\r\n *\r\n * @param deltaTime - The time in seconds to advance the animation\r\n */\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 /**\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 *\r\n * @param from - The starting value\r\n * @param to - The ending value\r\n * @param options - Options for the animation\r\n */\r\n fromTo(\r\n from: number,\r\n to: number,\r\n { lerp, duration, easing, onStart, onUpdate }: FromToOptions\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\n/**\r\n * Dimensions class to handle the size of the content and wrapper\r\n *\r\n * @example\r\n * const dimensions = new Dimensions(wrapper, content)\r\n * dimensions.on('resize', (e) => {\r\n * console.log(e.width, e.height)\r\n * })\r\n */\r\nexport class Dimensions {\r\n width = 0\r\n height = 0\r\n scrollHeight = 0\r\n scrollWidth = 0\r\n\r\n // These are instanciated in the constructor as they need information from the options\r\n private debouncedResize?: (...args: unknown[]) => void\r\n private wrapperResizeObserver?: ResizeObserver\r\n private contentResizeObserver?: ResizeObserver\r\n\r\n constructor(\r\n private wrapper: HTMLElement | Window,\r\n private content: HTMLElement,\r\n { autoResize = true, debounce: debounceValue = 250 } = {}\r\n ) {\r\n if (autoResize) {\r\n this.debouncedResize = debounce(this.resize, debounceValue)\r\n\r\n if (this.wrapper instanceof 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\r\n if (this.wrapper === window && this.debouncedResize) {\r\n window.removeEventListener('resize', this.debouncedResize, 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 instanceof 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 instanceof 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 void>(\r\n callback: CB,\r\n delay: number\r\n) {\r\n let timer: number | undefined\r\n return function (this: T, ...args: Parameters) {\r\n let context = this\r\n clearTimeout(timer)\r\n timer = setTimeout(() => {\r\n timer = undefined\r\n callback.apply(context, args)\r\n }, delay)\r\n }\r\n}\r\n","/**\r\n * Emitter class to handle events\r\n * @example\r\n * const emitter = new Emitter()\r\n * emitter.on('event', (data) => {\r\n * console.log(data)\r\n * })\r\n * emitter.emit('event', 'data')\r\n */\r\nexport class Emitter {\r\n private events: Record<\r\n string,\r\n Array<(...args: unknown[]) => void> | undefined\r\n > = {}\r\n\r\n /**\r\n * Emit an event with the given data\r\n * @param event Event name\r\n * @param args Data to pass to the event handlers\r\n */\r\n emit(event: string, ...args: unknown[]) {\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 /**\r\n * Add a callback to the event\r\n * @param event Event name\r\n * @param cb Callback function\r\n * @returns Unsubscribe function\r\n */\r\n on void>(event: string, cb: 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 /**\r\n * Remove a callback from the event\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n off void>(event: string, callback: CB) {\r\n this.events[event] = this.events[event]?.filter((i) => callback !== i)\r\n }\r\n\r\n /**\r\n * Remove all event listeners and clean up\r\n */\r\n destroy() {\r\n this.events = {}\r\n }\r\n}\r\n","import { Emitter } from './emitter'\r\nimport { VirtualScrollCallback } from './types'\r\n\r\nconst LINE_HEIGHT = 100 / 6\r\nconst listenerOptions: AddEventListenerOptions = { passive: false }\r\n\r\nexport class VirtualScroll {\r\n touchStart = {\r\n x: 0,\r\n y: 0,\r\n }\r\n lastDelta = {\r\n x: 0,\r\n y: 0,\r\n }\r\n window = {\r\n width: 0,\r\n height: 0,\r\n }\r\n private emitter = new Emitter()\r\n\r\n constructor(\r\n private element: HTMLElement,\r\n private options = { wheelMultiplier: 1, touchMultiplier: 1 }\r\n ) {\r\n window.addEventListener('resize', this.onWindowResize, false)\r\n this.onWindowResize()\r\n\r\n this.element.addEventListener('wheel', this.onWheel, listenerOptions)\r\n this.element.addEventListener(\r\n 'touchstart',\r\n this.onTouchStart,\r\n listenerOptions\r\n )\r\n this.element.addEventListener(\r\n 'touchmove',\r\n this.onTouchMove,\r\n listenerOptions\r\n )\r\n this.element.addEventListener('touchend', this.onTouchEnd, listenerOptions)\r\n }\r\n\r\n /**\r\n * Add an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n on(event: string, callback: VirtualScrollCallback) {\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, listenerOptions)\r\n this.element.removeEventListener(\r\n 'touchstart',\r\n this.onTouchStart,\r\n listenerOptions\r\n )\r\n this.element.removeEventListener(\r\n 'touchmove',\r\n this.onTouchMove,\r\n listenerOptions\r\n )\r\n this.element.removeEventListener(\r\n 'touchend',\r\n this.onTouchEnd,\r\n listenerOptions\r\n )\r\n }\r\n\r\n /**\r\n * Event handler for 'touchstart' event\r\n *\r\n * @param event Touch event\r\n */\r\n onTouchStart = (event: TouchEvent) => {\r\n // @ts-expect-error - event.targetTouches is not defined\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 - event.targetTouches is not defined\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.options.touchMultiplier\r\n const deltaY = -(clientY - this.touchStart.y) * this.options.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.window.width : 1\r\n const multiplierY =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.window.height : 1\r\n\r\n deltaX *= multiplierX\r\n deltaY *= multiplierY\r\n\r\n deltaX *= this.options.wheelMultiplier\r\n deltaY *= this.options.wheelMultiplier\r\n\r\n this.emitter.emit('scroll', { deltaX, deltaY, event })\r\n }\r\n\r\n onWindowResize = () => {\r\n this.window = {\r\n width: window.innerWidth,\r\n height: window.innerHeight,\r\n }\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 type {\r\n LenisEvent,\r\n LenisOptions,\r\n ScrollCallback,\r\n Scrolling,\r\n ScrollToOptions,\r\n UserData,\r\n VirtualScrollCallback,\r\n VirtualScrollData,\r\n} from './types'\r\nimport { VirtualScroll } from './virtual-scroll'\r\n\r\n// Types\r\nexport * from './types'\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 OptionalPick = Omit & Partial>\r\n\r\nexport default class Lenis {\r\n #isScrolling: Scrolling = false // true when scroll is animating\r\n #isStopped = false // true if user should not be able to scroll - enable/disable programmatically\r\n #isLocked = false // same as isStopped but enabled/disabled when scroll reaches target\r\n #preventNextNativeScrollEvent = false\r\n #resetVelocityTimeout: number | null = null\r\n\r\n /**\r\n * Whether or not the user is touching the screen\r\n */\r\n isTouching?: boolean\r\n /**\r\n * The time in ms since the lenis instance was created\r\n */\r\n time = 0\r\n /**\r\n * User data that will be forwarded through the scroll event\r\n *\r\n * @example\r\n * lenis.scrollTo(100, {\r\n * userData: {\r\n * foo: 'bar'\r\n * }\r\n * })\r\n */\r\n userData: UserData = {}\r\n /**\r\n * The last velocity of the scroll\r\n */\r\n lastVelocity = 0\r\n /**\r\n * The current velocity of the scroll\r\n */\r\n velocity = 0\r\n /**\r\n * The direction of the scroll\r\n */\r\n direction: 1 | -1 | 0 = 0\r\n /**\r\n * The options passed to the lenis instance\r\n */\r\n options: OptionalPick<\r\n Required,\r\n 'duration' | 'prevent' | 'virtualScroll'\r\n >\r\n /**\r\n * The target scroll value\r\n */\r\n targetScroll: number\r\n /**\r\n * The animated scroll value\r\n */\r\n animatedScroll: number\r\n\r\n // These are instanciated here as they don't need information from the options\r\n private readonly animate = new Animate()\r\n private readonly emitter = new Emitter()\r\n // These are instanciated in the constructor as they need information from the options\r\n readonly dimensions: Dimensions // This is not private because it's used in the Snap class\r\n private readonly virtualScroll: VirtualScroll\r\n\r\n constructor({\r\n wrapper = window,\r\n content = document.documentElement,\r\n eventsTarget = wrapper,\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 // Set version\r\n window.lenisVersion = version\r\n\r\n // Check 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 // Setup options\r\n this.options = {\r\n wrapper,\r\n content,\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 }\r\n\r\n // Setup dimensions instance\r\n this.dimensions = new Dimensions(wrapper, content, { autoResize })\r\n\r\n // Setup class name\r\n this.updateClassName()\r\n\r\n // Set the initial scroll value for all scroll information\r\n this.targetScroll = this.animatedScroll = this.actualScroll\r\n\r\n // Add event listeners\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 // Setup virtual scroll instance\r\n this.virtualScroll = new VirtualScroll(eventsTarget as HTMLElement, {\r\n touchMultiplier,\r\n wheelMultiplier,\r\n })\r\n this.virtualScroll.on('scroll', this.onVirtualScroll)\r\n }\r\n\r\n /**\r\n * Destroy the lenis instance, remove all event listeners and clean up the class name\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\r\n /**\r\n * Add an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n * @returns Unsubscribe function\r\n */\r\n on(event: 'scroll', callback: ScrollCallback): () => void\r\n on(event: 'virtual-scroll', callback: VirtualScrollCallback): () => void\r\n on(event: LenisEvent, callback: any) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n /**\r\n * Remove an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n off(event: 'scroll', callback: ScrollCallback): void\r\n off(event: 'virtual-scroll', callback: VirtualScrollCallback): void\r\n off(event: LenisEvent, callback: any) {\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: VirtualScrollData) => {\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 HTMLElement &&\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 /**\r\n * Force lenis to recalculate the dimensions\r\n */\r\n resize() {\r\n this.dimensions.resize()\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.emit()\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 if (this.#resetVelocityTimeout !== null) {\r\n clearTimeout(this.#resetVelocityTimeout)\r\n this.#resetVelocityTimeout = null\r\n }\r\n\r\n if (this.#preventNextNativeScrollEvent) {\r\n this.#preventNextNativeScrollEvent = false\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.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 }\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 /**\r\n * Start lenis scroll after it has been stopped\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 /**\r\n * Stop lenis scroll\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 /**\r\n * RequestAnimationFrame for lenis\r\n *\r\n * @param time The time in ms from an external clock like `requestAnimationFrame` or Tempus\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 /**\r\n * Scroll to a target value\r\n *\r\n * @param target The target value to scroll to\r\n * @param options The options for the scroll\r\n *\r\n * @example\r\n * lenis.scrollTo(100, {\r\n * offset: 100,\r\n * duration: 1,\r\n * easing: (t) => 1 - Math.cos((t * Math.PI) / 2),\r\n * lerp: 0.1,\r\n * onStart: () => {\r\n * console.log('onStart')\r\n * },\r\n * onComplete: () => {\r\n * console.log('onComplete')\r\n * },\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 }: ScrollToOptions = {}\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) {\r\n onStart?.(this)\r\n onComplete?.(this)\r\n return\r\n }\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 // 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 this.#preventNextNativeScrollEvent = false\r\n })\r\n }\r\n\r\n /**\r\n * The root element on which lenis is instanced\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 /**\r\n * The limit which is the maximum scroll value\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 /**\r\n * Whether or not the scroll is horizontal\r\n */\r\n get isHorizontal() {\r\n return this.options.orientation === 'horizontal'\r\n }\r\n\r\n /**\r\n * The actual scroll value\r\n */\r\n get actualScroll() {\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 /**\r\n * The current scroll value\r\n */\r\n get scroll() {\r\n return this.options.infinite\r\n ? modulo(this.animatedScroll, this.limit)\r\n : this.animatedScroll\r\n }\r\n\r\n /**\r\n * The progress of the scroll relative to the limit\r\n */\r\n get progress() {\r\n // avoid progress to be NaN\r\n return this.limit === 0 ? 1 : this.scroll / this.limit\r\n }\r\n\r\n /**\r\n * Current scroll state\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 /**\r\n * Check if lenis is stopped\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 /**\r\n * Check if lenis is locked\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 /**\r\n * Check if lenis is smooth scrolling\r\n */\r\n get isSmooth() {\r\n return this.isScrolling === 'smooth'\r\n }\r\n\r\n /**\r\n * The class name applied to the wrapper element\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 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":["__classPrivateFieldGet","receiver","state","kind","f","TypeError","has","call","value","get","__classPrivateFieldSet","set","SuppressedError","clamp","min","input","max","Math","Animate","constructor","this","isRunning","from","to","currentTime","advance","deltaTime","completed","duration","easing","linearProgress","easedProgress","lerp","damp","x","y","lambda","t","exp","round","stop","_a","onUpdate","fromTo","onStart","Dimensions","wrapper","content","autoResize","debounce","debounceValue","width","height","scrollHeight","scrollWidth","resize","onWrapperResize","onContentResize","Window","window","innerWidth","innerHeight","clientWidth","clientHeight","debouncedResize","callback","delay","timer","args","context","clearTimeout","setTimeout","undefined","apply","addEventListener","wrapperResizeObserver","ResizeObserver","observe","contentResizeObserver","destroy","disconnect","_b","removeEventListener","limit","Emitter","events","emit","event","callbacks","i","length","on","cb","push","filter","off","LINE_HEIGHT","listenerOptions","passive","VirtualScroll","element","options","wheelMultiplier","touchMultiplier","touchStart","lastDelta","emitter","onTouchStart","clientX","clientY","targetTouches","deltaX","deltaY","onTouchMove","onTouchEnd","onWheel","deltaMode","onWindowResize","Lenis","document","documentElement","eventsTarget","smoothWheel","syncTouch","syncTouchLerp","touchInertiaMultiplier","pow","infinite","orientation","gestureOrientation","prevent","virtualScroll","__experimental__naiveDimensions","_Lenis_isScrolling","_Lenis_isStopped","_Lenis_isLocked","_Lenis_preventNextNativeScrollEvent","_Lenis_resetVelocityTimeout","time","userData","lastVelocity","velocity","direction","animate","onPointerDown","button","reset","onVirtualScroll","data","ctrlKey","isTouch","type","includes","isWheel","isTouching","isStopped","isLocked","isClick","isUnknownGesture","composedPath","slice","indexOf","rootElement","find","node","HTMLElement","hasAttribute","_c","classList","_d","contains","_e","preventDefault","isScrolling","delta","abs","hasTouchInertia","scrollTo","targetScroll","Object","assign","programmatic","onNativeScroll","lastScroll","animatedScroll","actualScroll","sign","lenisVersion","body","dimensions","updateClassName","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":"sOAoRO,SAASA,uBAAuBC,EAAUC,EAAOC,EAAMC,GAC1D,GAAa,MAATD,IAAiBC,EAAG,MAAM,IAAIC,UAAU,iDAC5C,GAAqB,mBAAVH,EAAuBD,IAAaC,IAAUE,GAAKF,EAAMI,IAAIL,GAAW,MAAM,IAAII,UAAU,4EACvG,MAAgB,MAATF,EAAeC,EAAa,MAATD,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yD,UACf,GAAGvM,KAAK8I,YAAYyD,aAAavM,KAAKuM,YAAYC,MACrD,CAEO,gBAAA7B,GACN3K,KAAK8I,YAAYyD,UAAYvM,KAAK8I,YAAYyD,UAC3CE,QAAQ,gBAAiB,IACzBD,MACJ","x_google_ignoreList":[0]} \ No newline at end of file +{"version":3,"file":"lenis.min.js","sources":["../../src/maths.ts","../../src/animate.ts","../../src/dimensions.ts","../../src/debounce.ts","../../src/emitter.ts","../../src/virtual-scroll.ts","../../src/index.ts"],"sourcesContent":["/**\r\n * Clamp a value between a minimum and maximum value\r\n *\r\n * @param min Minimum value\r\n * @param input Value to clamp\r\n * @param max Maximum value\r\n * @returns Clamped value\r\n */\r\nexport function clamp(min: number, input: number, max: number) {\r\n return Math.max(min, Math.min(input, max))\r\n}\r\n\r\n/**\r\n * Truncate a floating-point number to a specified number of decimal places\r\n *\r\n * @param value Value to truncate\r\n * @param decimals Number of decimal places to truncate to\r\n * @returns Truncated value\r\n */\r\nexport function truncate(value: number, decimals = 0) {\r\n return parseFloat(value.toFixed(decimals))\r\n}\r\n\r\n/**\r\n * Linearly interpolate between two values using an amount (0 <= t <= 1)\r\n *\r\n * @param x First value\r\n * @param y Second value\r\n * @param t Amount to interpolate (0 <= t <= 1)\r\n * @returns Interpolated value\r\n */\r\nexport function lerp(x: number, y: number, t: number) {\r\n return (1 - t) * x + t * y\r\n}\r\n\r\n/**\r\n * Damp a value over time using a damping factor\r\n * {@link http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/}\r\n *\r\n * @param x Initial value\r\n * @param y Target value\r\n * @param lambda Damping factor\r\n * @param dt Time elapsed since the last update\r\n * @returns Damped value\r\n */\r\nexport function damp(x: number, y: number, lambda: number, deltaTime: number) {\r\n return lerp(x, y, 1 - Math.exp(-lambda * deltaTime))\r\n}\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 * {@link https://anguscroll.com/just/just-modulo}\r\n *\r\n * @param n Dividend\r\n * @param d Divisor\r\n * @returns Modulo\r\n */\r\nexport function modulo(n: number, d: number) {\r\n return ((n % d) + d) % d\r\n}\r\n","import { clamp, damp } from './maths'\r\nimport type { EasingFunction, FromToOptions, OnUpdateCallback } from './types'\r\n\r\n/**\r\n * Animate class to handle value animations with lerping or easing\r\n *\r\n * @example\r\n * const animate = new Animate()\r\n * animate.fromTo(0, 100, { duration: 1, easing: (t) => t })\r\n * animate.advance(0.5) // 50\r\n */\r\nexport class Animate {\r\n isRunning = false\r\n value = 0\r\n from = 0\r\n to = 0\r\n currentTime = 0\r\n\r\n // These are instanciated in the fromTo method\r\n lerp?: number\r\n duration?: number\r\n easing?: EasingFunction\r\n onUpdate?: OnUpdateCallback\r\n\r\n /**\r\n * Advance the animation by the given delta time\r\n *\r\n * @param deltaTime - The time in seconds to advance the animation\r\n */\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 /**\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 *\r\n * @param from - The starting value\r\n * @param to - The ending value\r\n * @param options - Options for the animation\r\n */\r\n fromTo(\r\n from: number,\r\n to: number,\r\n { lerp, duration, easing, onStart, onUpdate }: FromToOptions\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\n/**\r\n * Dimensions class to handle the size of the content and wrapper\r\n *\r\n * @example\r\n * const dimensions = new Dimensions(wrapper, content)\r\n * dimensions.on('resize', (e) => {\r\n * console.log(e.width, e.height)\r\n * })\r\n */\r\nexport class Dimensions {\r\n width = 0\r\n height = 0\r\n scrollHeight = 0\r\n scrollWidth = 0\r\n\r\n // These are instanciated in the constructor as they need information from the options\r\n private debouncedResize?: (...args: unknown[]) => void\r\n private wrapperResizeObserver?: ResizeObserver\r\n private contentResizeObserver?: ResizeObserver\r\n\r\n constructor(\r\n private wrapper: HTMLElement | Window,\r\n private content: HTMLElement,\r\n { autoResize = true, debounce: debounceValue = 250 } = {}\r\n ) {\r\n if (autoResize) {\r\n this.debouncedResize = debounce(this.resize, debounceValue)\r\n\r\n if (this.wrapper instanceof 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\r\n if (this.wrapper === window && this.debouncedResize) {\r\n window.removeEventListener('resize', this.debouncedResize, 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 instanceof 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 instanceof 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 void>(\r\n callback: CB,\r\n delay: number\r\n) {\r\n let timer: number | undefined\r\n return function (this: T, ...args: Parameters) {\r\n let context = this\r\n clearTimeout(timer)\r\n timer = setTimeout(() => {\r\n timer = undefined\r\n callback.apply(context, args)\r\n }, delay)\r\n }\r\n}\r\n","/**\r\n * Emitter class to handle events\r\n * @example\r\n * const emitter = new Emitter()\r\n * emitter.on('event', (data) => {\r\n * console.log(data)\r\n * })\r\n * emitter.emit('event', 'data')\r\n */\r\nexport class Emitter {\r\n private events: Record<\r\n string,\r\n Array<(...args: unknown[]) => void> | undefined\r\n > = {}\r\n\r\n /**\r\n * Emit an event with the given data\r\n * @param event Event name\r\n * @param args Data to pass to the event handlers\r\n */\r\n emit(event: string, ...args: unknown[]) {\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 /**\r\n * Add a callback to the event\r\n * @param event Event name\r\n * @param cb Callback function\r\n * @returns Unsubscribe function\r\n */\r\n on void>(event: string, cb: 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 /**\r\n * Remove a callback from the event\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n off void>(event: string, callback: CB) {\r\n this.events[event] = this.events[event]?.filter((i) => callback !== i)\r\n }\r\n\r\n /**\r\n * Remove all event listeners and clean up\r\n */\r\n destroy() {\r\n this.events = {}\r\n }\r\n}\r\n","import { Emitter } from './emitter'\r\nimport { VirtualScrollCallback } from './types'\r\n\r\nconst LINE_HEIGHT = 100 / 6\r\nconst listenerOptions: AddEventListenerOptions = { passive: false }\r\n\r\nexport class VirtualScroll {\r\n touchStart = {\r\n x: 0,\r\n y: 0,\r\n }\r\n lastDelta = {\r\n x: 0,\r\n y: 0,\r\n }\r\n window = {\r\n width: 0,\r\n height: 0,\r\n }\r\n private emitter = new Emitter()\r\n\r\n constructor(\r\n private element: HTMLElement,\r\n private options = { wheelMultiplier: 1, touchMultiplier: 1 }\r\n ) {\r\n window.addEventListener('resize', this.onWindowResize, false)\r\n this.onWindowResize()\r\n\r\n this.element.addEventListener('wheel', this.onWheel, listenerOptions)\r\n this.element.addEventListener(\r\n 'touchstart',\r\n this.onTouchStart,\r\n listenerOptions\r\n )\r\n this.element.addEventListener(\r\n 'touchmove',\r\n this.onTouchMove,\r\n listenerOptions\r\n )\r\n this.element.addEventListener('touchend', this.onTouchEnd, listenerOptions)\r\n }\r\n\r\n /**\r\n * Add an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n on(event: string, callback: VirtualScrollCallback) {\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, listenerOptions)\r\n this.element.removeEventListener(\r\n 'touchstart',\r\n this.onTouchStart,\r\n listenerOptions\r\n )\r\n this.element.removeEventListener(\r\n 'touchmove',\r\n this.onTouchMove,\r\n listenerOptions\r\n )\r\n this.element.removeEventListener(\r\n 'touchend',\r\n this.onTouchEnd,\r\n listenerOptions\r\n )\r\n }\r\n\r\n /**\r\n * Event handler for 'touchstart' event\r\n *\r\n * @param event Touch event\r\n */\r\n onTouchStart = (event: TouchEvent) => {\r\n // @ts-expect-error - event.targetTouches is not defined\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 - event.targetTouches is not defined\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.options.touchMultiplier\r\n const deltaY = -(clientY - this.touchStart.y) * this.options.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.window.width : 1\r\n const multiplierY =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.window.height : 1\r\n\r\n deltaX *= multiplierX\r\n deltaY *= multiplierY\r\n\r\n deltaX *= this.options.wheelMultiplier\r\n deltaY *= this.options.wheelMultiplier\r\n\r\n this.emitter.emit('scroll', { deltaX, deltaY, event })\r\n }\r\n\r\n onWindowResize = () => {\r\n this.window = {\r\n width: window.innerWidth,\r\n height: window.innerHeight,\r\n }\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 type {\r\n LenisEvent,\r\n LenisOptions,\r\n ScrollCallback,\r\n Scrolling,\r\n ScrollToOptions,\r\n UserData,\r\n VirtualScrollCallback,\r\n VirtualScrollData,\r\n} from './types'\r\nimport { VirtualScroll } from './virtual-scroll'\r\n\r\n// Types\r\nexport * from './types'\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 OptionalPick = Omit & Partial>\r\n\r\nexport default class Lenis {\r\n private _isScrolling: Scrolling = false // true when scroll is animating\r\n private _isStopped = false // true if user should not be able to scroll - enable/disable programmatically\r\n private _isLocked = false // same as isStopped but enabled/disabled when scroll reaches target\r\n private _preventNextNativeScrollEvent = false\r\n private _resetVelocityTimeout: number | null = null\r\n\r\n /**\r\n * Whether or not the user is touching the screen\r\n */\r\n isTouching?: boolean\r\n /**\r\n * The time in ms since the lenis instance was created\r\n */\r\n time = 0\r\n /**\r\n * User data that will be forwarded through the scroll event\r\n *\r\n * @example\r\n * lenis.scrollTo(100, {\r\n * userData: {\r\n * foo: 'bar'\r\n * }\r\n * })\r\n */\r\n userData: UserData = {}\r\n /**\r\n * The last velocity of the scroll\r\n */\r\n lastVelocity = 0\r\n /**\r\n * The current velocity of the scroll\r\n */\r\n velocity = 0\r\n /**\r\n * The direction of the scroll\r\n */\r\n direction: 1 | -1 | 0 = 0\r\n /**\r\n * The options passed to the lenis instance\r\n */\r\n options: OptionalPick<\r\n Required,\r\n 'duration' | 'prevent' | 'virtualScroll'\r\n >\r\n /**\r\n * The target scroll value\r\n */\r\n targetScroll: number\r\n /**\r\n * The animated scroll value\r\n */\r\n animatedScroll: number\r\n\r\n // These are instanciated here as they don't need information from the options\r\n private readonly animate = new Animate()\r\n private readonly emitter = new Emitter()\r\n // These are instanciated in the constructor as they need information from the options\r\n readonly dimensions: Dimensions // This is not private because it's used in the Snap class\r\n private readonly virtualScroll: VirtualScroll\r\n\r\n constructor({\r\n wrapper = window,\r\n content = document.documentElement,\r\n eventsTarget = wrapper,\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 // Set version\r\n window.lenisVersion = version\r\n\r\n // Check 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 // Setup options\r\n this.options = {\r\n wrapper,\r\n content,\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 }\r\n\r\n // Setup dimensions instance\r\n this.dimensions = new Dimensions(wrapper, content, { autoResize })\r\n\r\n // Setup class name\r\n this.updateClassName()\r\n\r\n // Set the initial scroll value for all scroll information\r\n this.targetScroll = this.animatedScroll = this.actualScroll\r\n\r\n // Add event listeners\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 // Setup virtual scroll instance\r\n this.virtualScroll = new VirtualScroll(eventsTarget as HTMLElement, {\r\n touchMultiplier,\r\n wheelMultiplier,\r\n })\r\n this.virtualScroll.on('scroll', this.onVirtualScroll)\r\n }\r\n\r\n /**\r\n * Destroy the lenis instance, remove all event listeners and clean up the class name\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\r\n /**\r\n * Add an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n * @returns Unsubscribe function\r\n */\r\n on(event: 'scroll', callback: ScrollCallback): () => void\r\n on(event: 'virtual-scroll', callback: VirtualScrollCallback): () => void\r\n on(event: LenisEvent, callback: any) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n /**\r\n * Remove an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n off(event: 'scroll', callback: ScrollCallback): void\r\n off(event: 'virtual-scroll', callback: VirtualScrollCallback): void\r\n off(event: LenisEvent, callback: any) {\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: VirtualScrollData) => {\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 HTMLElement &&\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 /**\r\n * Force lenis to recalculate the dimensions\r\n */\r\n resize() {\r\n this.dimensions.resize()\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.emit()\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 if (this._resetVelocityTimeout !== null) {\r\n clearTimeout(this._resetVelocityTimeout)\r\n this._resetVelocityTimeout = null\r\n }\r\n\r\n if (this._preventNextNativeScrollEvent) {\r\n this._preventNextNativeScrollEvent = false\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.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 }\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 /**\r\n * Start lenis scroll after it has been stopped\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 /**\r\n * Stop lenis scroll\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 /**\r\n * RequestAnimationFrame for lenis\r\n *\r\n * @param time The time in ms from an external clock like `requestAnimationFrame` or Tempus\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 /**\r\n * Scroll to a target value\r\n *\r\n * @param target The target value to scroll to\r\n * @param options The options for the scroll\r\n *\r\n * @example\r\n * lenis.scrollTo(100, {\r\n * offset: 100,\r\n * duration: 1,\r\n * easing: (t) => 1 - Math.cos((t * Math.PI) / 2),\r\n * lerp: 0.1,\r\n * onStart: () => {\r\n * console.log('onStart')\r\n * },\r\n * onComplete: () => {\r\n * console.log('onComplete')\r\n * },\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 }: ScrollToOptions = {}\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) {\r\n onStart?.(this)\r\n onComplete?.(this)\r\n return\r\n }\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 // 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 this._preventNextNativeScrollEvent = false\r\n })\r\n }\r\n\r\n /**\r\n * The root element on which lenis is instanced\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 /**\r\n * The limit which is the maximum scroll value\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 /**\r\n * Whether or not the scroll is horizontal\r\n */\r\n get isHorizontal() {\r\n return this.options.orientation === 'horizontal'\r\n }\r\n\r\n /**\r\n * The actual scroll value\r\n */\r\n get actualScroll() {\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 /**\r\n * The current scroll value\r\n */\r\n get scroll() {\r\n return this.options.infinite\r\n ? modulo(this.animatedScroll, this.limit)\r\n : this.animatedScroll\r\n }\r\n\r\n /**\r\n * The progress of the scroll relative to the limit\r\n */\r\n get progress() {\r\n // avoid progress to be NaN\r\n return this.limit === 0 ? 1 : this.scroll / this.limit\r\n }\r\n\r\n /**\r\n * Current scroll state\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 /**\r\n * Check if lenis is stopped\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 /**\r\n * Check if lenis is locked\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 /**\r\n * Check if lenis is smooth scrolling\r\n */\r\n get isSmooth() {\r\n return this.isScrolling === 'smooth'\r\n }\r\n\r\n /**\r\n * The class name applied to the wrapper element\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 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","currentTime","advance","deltaTime","completed","duration","easing","linearProgress","easedProgress","lerp","damp","x","y","lambda","t","exp","round","stop","_a","onUpdate","call","fromTo","onStart","Dimensions","wrapper","content","autoResize","debounce","debounceValue","width","height","scrollHeight","scrollWidth","resize","onWrapperResize","onContentResize","Window","window","innerWidth","innerHeight","clientWidth","clientHeight","debouncedResize","callback","delay","timer","args","context","clearTimeout","setTimeout","undefined","apply","addEventListener","wrapperResizeObserver","ResizeObserver","observe","contentResizeObserver","destroy","disconnect","_b","removeEventListener","limit","Emitter","events","emit","event","callbacks","i","length","on","cb","push","filter","off","LINE_HEIGHT","listenerOptions","passive","VirtualScroll","element","options","wheelMultiplier","touchMultiplier","touchStart","lastDelta","emitter","onTouchStart","clientX","clientY","targetTouches","deltaX","deltaY","onTouchMove","onTouchEnd","onWheel","deltaMode","onWindowResize","Lenis","document","documentElement","eventsTarget","smoothWheel","syncTouch","syncTouchLerp","touchInertiaMultiplier","pow","infinite","orientation","gestureOrientation","prevent","virtualScroll","__experimental__naiveDimensions","_isScrolling","_isStopped","_isLocked","_preventNextNativeScrollEvent","_resetVelocityTimeout","time","userData","lastVelocity","velocity","direction","animate","onPointerDown","button","reset","onVirtualScroll","data","ctrlKey","isTouch","type","includes","isWheel","isTouching","isStopped","isLocked","isClick","isUnknownGesture","composedPath","slice","indexOf","rootElement","find","node","HTMLElement","hasAttribute","_c","classList","_d","contains","_e","preventDefault","isScrolling","delta","abs","hasTouchInertia","scrollTo","targetScroll","Object","assign","programmatic","onNativeScroll","lastScroll","animatedScroll","actualScroll","sign","lenisVersion","body","dimensions","updateClassName","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":"+OAQgBA,MAAMC,EAAaC,EAAeC,GAChD,OAAOC,KAAKD,IAAIF,EAAKG,KAAKH,IAAIC,EAAOC,GACvC,OCCaE,QAAb,WAAAC,GACEC,KAASC,WAAG,EACZD,K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nH,IACrBF,KAAKqH,UAAYnH,EACjBF,KAAK4K,kBAER,CAKD,YAAI4B,GACF,MAA4B,WAArBxM,KAAK2J,WACb,CAKD,aAAI8C,GACF,IAAIA,EAAY,QAKhB,OAJIzM,KAAKyI,YAAWgE,GAAa,kBAC7BzM,KAAK0I,WAAU+D,GAAa,iBAC5BzM,KAAK2J,cAAa8C,GAAa,oBACV,WAArBzM,KAAK2J,cAA0B8C,GAAa,iBACzCA,CACR,CAEO,eAAA7B,GACN5K,KAAK6K,mBAEL7K,KAAKgJ,YAAYyD,UACf,GAAGzM,KAAKgJ,YAAYyD,aAAazM,KAAKyM,YAAYC,MACrD,CAEO,gBAAA7B,GACN7K,KAAKgJ,YAAYyD,UAAYzM,KAAKgJ,YAAYyD,UAC3CE,QAAQ,gBAAiB,IACzBD,MACJ"} \ No newline at end of file diff --git a/dist/lenis.mjs b/dist/lenis.mjs index 046787b9..ecec0ae0 100644 --- a/dist/lenis.mjs +++ b/dist/lenis.mjs @@ -1,2 +1,2 @@ -function __classPrivateFieldGet(t,e,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(t):s?s.value:e.get(t)}function __classPrivateFieldSet(t,e,i,s,o){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?o.call(t,i):o?o.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;function clamp(t,e,i){return Math.max(t,Math.min(e,i))}class Animate{constructor(){this.isRunning=!1,this.value=0,this.from=0,this.to=0,this.currentTime=0}advance(t){var e;if(!this.isRunning)return;let i=!1;if(this.duration&&this.easing){this.currentTime+=t;const e=clamp(0,this.currentTime/this.duration,1);i=e>=1;const s=i?1:this.easing(e);this.value=this.from+(this.to-this.from)*s}else 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,i=!0)):(this.value=this.to,i=!0);i&&this.stop(),null===(e=this.onUpdate)||void 0===e||e.call(this,this.value,i)}stop(){this.isRunning=!1}fromTo(t,e,{lerp:i,duration:s,easing:o,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,null==n||n(),this.onUpdate=r}}class Dimensions{constructor(t,e,{autoResize:i=!0,debounce:s=250}={}){this.wrapper=t,this.content=e,this.width=0,this.height=0,this.scrollHeight=0,this.scrollWidth=0,this.resize=()=>{this.onWrapperResize(),this.onContentResize()},this.onWrapperResize=()=>{this.wrapper instanceof Window?(this.width=window.innerWidth,this.height=window.innerHeight):(this.width=this.wrapper.clientWidth,this.height=this.wrapper.clientHeight)},this.onContentResize=()=>{this.wrapper instanceof Window?(this.scrollHeight=this.content.scrollHeight,this.scrollWidth=this.content.scrollWidth):(this.scrollHeight=this.wrapper.scrollHeight,this.scrollWidth=this.wrapper.scrollWidth)},i&&(this.debouncedResize=function debounce(t,e){let i;return function(...s){let o=this;clearTimeout(i),i=setTimeout((()=>{i=void 0,t.apply(o,s)}),e)}}(this.resize,s),this.wrapper instanceof 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(){var t,e;null===(t=this.wrapperResizeObserver)||void 0===t||t.disconnect(),null===(e=this.contentResizeObserver)||void 0===e||e.disconnect(),this.wrapper===window&&this.debouncedResize&&window.removeEventListener("resize",this.debouncedResize,!1)}get limit(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}}class Emitter{constructor(){this.events={}}emit(t,...e){var i;let s=this.events[t]||[];for(let t=0,o=s.length;t{var i;this.events[t]=null===(i=this.events[t])||void 0===i?void 0:i.filter((t=>e!==t))}}off(t,e){var i;this.events[t]=null===(i=this.events[t])||void 0===i?void 0:i.filter((t=>e!==t))}destroy(){this.events={}}}const t=100/6,e={passive:!1};class VirtualScroll{constructor(i,s={wheelMultiplier:1,touchMultiplier:1}){this.element=i,this.options=s,this.touchStart={x:0,y:0},this.lastDelta={x:0,y:0},this.window={width:0,height:0},this.emitter=new Emitter,this.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})},this.onTouchMove=t=>{const{clientX:e,clientY:i}=t.targetTouches?t.targetTouches[0]:t,s=-(e-this.touchStart.x)*this.options.touchMultiplier,o=-(i-this.touchStart.y)*this.options.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})},this.onTouchEnd=t=>{this.emitter.emit("scroll",{deltaX:this.lastDelta.x,deltaY:this.lastDelta.y,event:t})},this.onWheel=e=>{let{deltaX:i,deltaY:s,deltaMode:o}=e;i*=1===o?t:2===o?this.window.width:1,s*=1===o?t:2===o?this.window.height:1,i*=this.options.wheelMultiplier,s*=this.options.wheelMultiplier,this.emitter.emit("scroll",{deltaX:i,deltaY:s,event:e})},this.onWindowResize=()=>{this.window={width:window.innerWidth,height:window.innerHeight}},window.addEventListener("resize",this.onWindowResize,!1),this.onWindowResize(),this.element.addEventListener("wheel",this.onWheel,e),this.element.addEventListener("touchstart",this.onTouchStart,e),this.element.addEventListener("touchmove",this.onTouchMove,e),this.element.addEventListener("touchend",this.onTouchEnd,e)}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,e),this.element.removeEventListener("touchstart",this.onTouchStart,e),this.element.removeEventListener("touchmove",this.onTouchMove,e),this.element.removeEventListener("touchend",this.onTouchEnd,e)}}var i,s,o,n,r;class Lenis{constructor({wrapper:t=window,content:e=document.documentElement,eventsTarget:l=t,smoothWheel:h=!0,syncTouch:a=!1,syncTouchLerp:c=.075,touchInertiaMultiplier:d=35,duration:u,easing:p=(t=>Math.min(1,1.001-Math.pow(2,-10*t))),lerp:m=.1,infinite:v=!1,orientation:w="vertical",gestureOrientation:f="vertical",touchMultiplier:g=1,wheelMultiplier:S=1,autoResize:y=!0,prevent:E,virtualScroll:_,__experimental__naiveDimensions:T=!1}={}){i.set(this,!1),s.set(this,!1),o.set(this,!1),n.set(this,!1),r.set(this,null),this.time=0,this.userData={},this.lastVelocity=0,this.velocity=0,this.direction=0,this.animate=new Animate,this.emitter=new Emitter,this.onPointerDown=t=>{1===t.button&&this.reset()},this.onVirtualScroll=t=>{if("function"==typeof this.options.virtualScroll&&!1===this.options.virtualScroll(t))return;const{deltaX:e,deltaY:i,event:s}=t;if(this.emitter.emit("virtual-scroll",{deltaX:e,deltaY:i,event:s}),s.ctrlKey)return;const o=s.type.includes("touch"),n=s.type.includes("wheel");this.isTouching="touchstart"===s.type||"touchmove"===s.type;if(this.options.syncTouch&&o&&"touchstart"===s.type&&!this.isStopped&&!this.isLocked)return void this.reset();const r=0===e&&0===i,l="vertical"===this.options.gestureOrientation&&0===i||"horizontal"===this.options.gestureOrientation&&0===e;if(r||l)return;let h=s.composedPath();h=h.slice(0,h.indexOf(this.rootElement));const a=this.options.prevent;if(h.find((t=>{var e,i,s,r,l;return t instanceof HTMLElement&&("function"==typeof a&&(null==a?void 0:a(t))||(null===(e=t.hasAttribute)||void 0===e?void 0:e.call(t,"data-lenis-prevent"))||o&&(null===(i=t.hasAttribute)||void 0===i?void 0:i.call(t,"data-lenis-prevent-touch"))||n&&(null===(s=t.hasAttribute)||void 0===s?void 0:s.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 s.preventDefault();if(!(this.options.syncTouch&&o||this.options.smoothWheel&&n))return this.isScrolling="native",void this.animate.stop();s.preventDefault();let c=i;"both"===this.options.gestureOrientation?c=Math.abs(i)>Math.abs(e)?i:e:"horizontal"===this.options.gestureOrientation&&(c=e);const d=o&&this.options.syncTouch,u=o&&"touchend"===s.type&&Math.abs(c)>5;u&&(c=this.velocity*this.options.touchInertiaMultiplier),this.scrollTo(this.targetScroll+c,Object.assign({programmatic:!1},d?{lerp:u?this.options.syncTouchLerp:1}:{lerp:this.options.lerp,duration:this.options.duration,easing:this.options.easing}))},this.onNativeScroll=()=>{if(null!==__classPrivateFieldGet(this,r,"f")&&(clearTimeout(__classPrivateFieldGet(this,r,"f")),__classPrivateFieldSet(this,r,null,"f")),__classPrivateFieldGet(this,n,"f"))__classPrivateFieldSet(this,n,!1,"f");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="native",this.emit(),0!==this.velocity&&__classPrivateFieldSet(this,r,setTimeout((()=>{this.lastVelocity=this.velocity,this.velocity=0,this.isScrolling=!1,this.emit()}),400),"f")}},window.lenisVersion="1.1.12",t&&t!==document.documentElement&&t!==document.body||(t=window),this.options={wrapper:t,content:e,eventsTarget:l,smoothWheel:h,syncTouch:a,syncTouchLerp:c,touchInertiaMultiplier:d,duration:u,easing:p,lerp:m,infinite:v,gestureOrientation:f,orientation:w,touchMultiplier:g,wheelMultiplier:S,autoResize:y,prevent:E,virtualScroll:_,__experimental__naiveDimensions:T},this.dimensions=new Dimensions(t,e,{autoResize:y}),this.updateClassName(),this.targetScroll=this.animatedScroll=this.actualScroll,this.options.wrapper.addEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.addEventListener("pointerdown",this.onPointerDown,!1),this.virtualScroll=new VirtualScroll(l,{touchMultiplier:g,wheelMultiplier:S}),this.virtualScroll.on("scroll",this.onVirtualScroll)}destroy(){this.emitter.destroy(),this.options.wrapper.removeEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.removeEventListener("pointerdown",this.onPointerDown,!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(),this.animatedScroll=this.targetScroll=this.actualScroll,this.emit()}emit(){this.emitter.emit("scroll",this)}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=this.options.lerp,onStart:l,onComplete:h,force:a=!1,programmatic:c=!0,userData:d}={}){if(!this.isStopped&&!this.isLocked||a){if("string"==typeof t&&["top","left","start"].includes(t))t=0;else if("string"==typeof t&&["bottom","right","end"].includes(t))t=this.limit;else{let i;if("string"==typeof t?i=document.querySelector(t):t instanceof HTMLElement&&(null==t?void 0:t.nodeType)&&(i=t),i){if(this.options.wrapper!==window){const t=this.rootElement.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),t===this.targetScroll)return null==l||l(this),void(null==h||h(this));if(this.userData=null!=d?d:{},i)return this.animatedScroll=this.targetScroll=t,this.setScroll(this.scroll),this.reset(),this.preventNextNativeScrollEvent(),this.emit(),null==h||h(this),void(this.userData={});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(),e&&(this.reset(),this.emit(),null==h||h(this),this.userData={},this.preventNextNativeScrollEvent())}})}}}preventNextNativeScrollEvent(){__classPrivateFieldSet(this,n,!0,"f"),requestAnimationFrame((()=>{__classPrivateFieldSet(this,n,!1,"f")}))}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 __classPrivateFieldGet(this,i,"f")}set isScrolling(t){__classPrivateFieldGet(this,i,"f")!==t&&(__classPrivateFieldSet(this,i,t,"f"),this.updateClassName())}get isStopped(){return __classPrivateFieldGet(this,s,"f")}set isStopped(t){__classPrivateFieldGet(this,s,"f")!==t&&(__classPrivateFieldSet(this,s,t,"f"),this.updateClassName())}get isLocked(){return __classPrivateFieldGet(this,o,"f")}set isLocked(t){__classPrivateFieldGet(this,o,"f")!==t&&(__classPrivateFieldSet(this,o,t,"f"),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()}}i=new WeakMap,s=new WeakMap,o=new WeakMap,n=new WeakMap,r=new WeakMap;export{Lenis as default}; +function clamp(t,i,e){return Math.max(t,Math.min(i,e))}class Animate{constructor(){this.isRunning=!1,this.value=0,this.from=0,this.to=0,this.currentTime=0}advance(t){var i;if(!this.isRunning)return;let e=!1;if(this.duration&&this.easing){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}else this.lerp?(this.value=function damp(t,i,e,s){return function lerp(t,i,e){return(1-e)*t+e*i}(t,i,1-Math.exp(-e*s))}(this.value,this.to,60*this.lerp,t),Math.round(this.value)===this.to&&(this.value=this.to,e=!0)):(this.value=this.to,e=!0);e&&this.stop(),null===(i=this.onUpdate)||void 0===i||i.call(this,this.value,e)}stop(){this.isRunning=!1}fromTo(t,i,{lerp:e,duration:s,easing:o,onStart:n,onUpdate:l}){this.from=this.value=t,this.to=i,this.lerp=e,this.duration=s,this.easing=o,this.currentTime=0,this.isRunning=!0,null==n||n(),this.onUpdate=l}}class Dimensions{constructor(t,i,{autoResize:e=!0,debounce:s=250}={}){this.wrapper=t,this.content=i,this.width=0,this.height=0,this.scrollHeight=0,this.scrollWidth=0,this.resize=()=>{this.onWrapperResize(),this.onContentResize()},this.onWrapperResize=()=>{this.wrapper instanceof Window?(this.width=window.innerWidth,this.height=window.innerHeight):(this.width=this.wrapper.clientWidth,this.height=this.wrapper.clientHeight)},this.onContentResize=()=>{this.wrapper instanceof Window?(this.scrollHeight=this.content.scrollHeight,this.scrollWidth=this.content.scrollWidth):(this.scrollHeight=this.wrapper.scrollHeight,this.scrollWidth=this.wrapper.scrollWidth)},e&&(this.debouncedResize=function debounce(t,i){let e;return function(...s){let o=this;clearTimeout(e),e=setTimeout((()=>{e=void 0,t.apply(o,s)}),i)}}(this.resize,s),this.wrapper instanceof 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(){var t,i;null===(t=this.wrapperResizeObserver)||void 0===t||t.disconnect(),null===(i=this.contentResizeObserver)||void 0===i||i.disconnect(),this.wrapper===window&&this.debouncedResize&&window.removeEventListener("resize",this.debouncedResize,!1)}get limit(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}}class Emitter{constructor(){this.events={}}emit(t,...i){var e;let s=this.events[t]||[];for(let t=0,o=s.length;t{var e;this.events[t]=null===(e=this.events[t])||void 0===e?void 0:e.filter((t=>i!==t))}}off(t,i){var e;this.events[t]=null===(e=this.events[t])||void 0===e?void 0:e.filter((t=>i!==t))}destroy(){this.events={}}}const t=100/6,i={passive:!1};class VirtualScroll{constructor(e,s={wheelMultiplier:1,touchMultiplier:1}){this.element=e,this.options=s,this.touchStart={x:0,y:0},this.lastDelta={x:0,y:0},this.window={width:0,height:0},this.emitter=new Emitter,this.onTouchStart=t=>{const{clientX:i,clientY:e}=t.targetTouches?t.targetTouches[0]:t;this.touchStart.x=i,this.touchStart.y=e,this.lastDelta={x:0,y:0},this.emitter.emit("scroll",{deltaX:0,deltaY:0,event:t})},this.onTouchMove=t=>{const{clientX:i,clientY:e}=t.targetTouches?t.targetTouches[0]:t,s=-(i-this.touchStart.x)*this.options.touchMultiplier,o=-(e-this.touchStart.y)*this.options.touchMultiplier;this.touchStart.x=i,this.touchStart.y=e,this.lastDelta={x:s,y:o},this.emitter.emit("scroll",{deltaX:s,deltaY:o,event:t})},this.onTouchEnd=t=>{this.emitter.emit("scroll",{deltaX:this.lastDelta.x,deltaY:this.lastDelta.y,event:t})},this.onWheel=i=>{let{deltaX:e,deltaY:s,deltaMode:o}=i;e*=1===o?t:2===o?this.window.width:1,s*=1===o?t:2===o?this.window.height:1,e*=this.options.wheelMultiplier,s*=this.options.wheelMultiplier,this.emitter.emit("scroll",{deltaX:e,deltaY:s,event:i})},this.onWindowResize=()=>{this.window={width:window.innerWidth,height:window.innerHeight}},window.addEventListener("resize",this.onWindowResize,!1),this.onWindowResize(),this.element.addEventListener("wheel",this.onWheel,i),this.element.addEventListener("touchstart",this.onTouchStart,i),this.element.addEventListener("touchmove",this.onTouchMove,i),this.element.addEventListener("touchend",this.onTouchEnd,i)}on(t,i){return this.emitter.on(t,i)}destroy(){this.emitter.destroy(),window.removeEventListener("resize",this.onWindowResize,!1),this.element.removeEventListener("wheel",this.onWheel,i),this.element.removeEventListener("touchstart",this.onTouchStart,i),this.element.removeEventListener("touchmove",this.onTouchMove,i),this.element.removeEventListener("touchend",this.onTouchEnd,i)}}class Lenis{constructor({wrapper:t=window,content:i=document.documentElement,eventsTarget:e=t,smoothWheel:s=!0,syncTouch:o=!1,syncTouchLerp:n=.075,touchInertiaMultiplier:l=35,duration:r,easing:h=(t=>Math.min(1,1.001-Math.pow(2,-10*t))),lerp:a=.1,infinite:c=!1,orientation:u="vertical",gestureOrientation:d="vertical",touchMultiplier:p=1,wheelMultiplier:m=1,autoResize:v=!0,prevent:g,virtualScroll:S,__experimental__naiveDimensions:w=!1}={}){this._isScrolling=!1,this._isStopped=!1,this._isLocked=!1,this._preventNextNativeScrollEvent=!1,this._resetVelocityTimeout=null,this.time=0,this.userData={},this.lastVelocity=0,this.velocity=0,this.direction=0,this.animate=new Animate,this.emitter=new Emitter,this.onPointerDown=t=>{1===t.button&&this.reset()},this.onVirtualScroll=t=>{if("function"==typeof this.options.virtualScroll&&!1===this.options.virtualScroll(t))return;const{deltaX:i,deltaY:e,event:s}=t;if(this.emitter.emit("virtual-scroll",{deltaX:i,deltaY:e,event:s}),s.ctrlKey)return;const o=s.type.includes("touch"),n=s.type.includes("wheel");this.isTouching="touchstart"===s.type||"touchmove"===s.type;if(this.options.syncTouch&&o&&"touchstart"===s.type&&!this.isStopped&&!this.isLocked)return void this.reset();const l=0===i&&0===e,r="vertical"===this.options.gestureOrientation&&0===e||"horizontal"===this.options.gestureOrientation&&0===i;if(l||r)return;let h=s.composedPath();h=h.slice(0,h.indexOf(this.rootElement));const a=this.options.prevent;if(h.find((t=>{var i,e,s,l,r;return t instanceof HTMLElement&&("function"==typeof a&&(null==a?void 0:a(t))||(null===(i=t.hasAttribute)||void 0===i?void 0:i.call(t,"data-lenis-prevent"))||o&&(null===(e=t.hasAttribute)||void 0===e?void 0:e.call(t,"data-lenis-prevent-touch"))||n&&(null===(s=t.hasAttribute)||void 0===s?void 0:s.call(t,"data-lenis-prevent-wheel"))||(null===(l=t.classList)||void 0===l?void 0:l.contains("lenis"))&&!(null===(r=t.classList)||void 0===r?void 0:r.contains("lenis-stopped")))})))return;if(this.isStopped||this.isLocked)return void s.preventDefault();if(!(this.options.syncTouch&&o||this.options.smoothWheel&&n))return this.isScrolling="native",void this.animate.stop();s.preventDefault();let c=e;"both"===this.options.gestureOrientation?c=Math.abs(e)>Math.abs(i)?e:i:"horizontal"===this.options.gestureOrientation&&(c=i);const u=o&&this.options.syncTouch,d=o&&"touchend"===s.type&&Math.abs(c)>5;d&&(c=this.velocity*this.options.touchInertiaMultiplier),this.scrollTo(this.targetScroll+c,Object.assign({programmatic:!1},u?{lerp:d?this.options.syncTouchLerp:1}:{lerp:this.options.lerp,duration:this.options.duration,easing:this.options.easing}))},this.onNativeScroll=()=>{if(null!==this._resetVelocityTimeout&&(clearTimeout(this._resetVelocityTimeout),this._resetVelocityTimeout=null),this._preventNextNativeScrollEvent)this._preventNextNativeScrollEvent=!1;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="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.13",t&&t!==document.documentElement&&t!==document.body||(t=window),this.options={wrapper:t,content:i,eventsTarget:e,smoothWheel:s,syncTouch:o,syncTouchLerp:n,touchInertiaMultiplier:l,duration:r,easing:h,lerp:a,infinite:c,gestureOrientation:d,orientation:u,touchMultiplier:p,wheelMultiplier:m,autoResize:v,prevent:g,virtualScroll:S,__experimental__naiveDimensions:w},this.dimensions=new Dimensions(t,i,{autoResize:v}),this.updateClassName(),this.targetScroll=this.animatedScroll=this.actualScroll,this.options.wrapper.addEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.addEventListener("pointerdown",this.onPointerDown,!1),this.virtualScroll=new VirtualScroll(e,{touchMultiplier:p,wheelMultiplier:m}),this.virtualScroll.on("scroll",this.onVirtualScroll)}destroy(){this.emitter.destroy(),this.options.wrapper.removeEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.removeEventListener("pointerdown",this.onPointerDown,!1),this.virtualScroll.destroy(),this.dimensions.destroy(),this.cleanUpClassName()}on(t,i){return this.emitter.on(t,i)}off(t,i){return this.emitter.off(t,i)}setScroll(t){this.isHorizontal?this.rootElement.scrollLeft=t:this.rootElement.scrollTop=t}resize(){this.dimensions.resize(),this.animatedScroll=this.targetScroll=this.actualScroll,this.emit()}emit(){this.emitter.emit("scroll",this)}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 i=t-(this.time||t);this.time=t,this.animate.advance(.001*i)}scrollTo(t,{offset:i=0,immediate:e=!1,lock:s=!1,duration:o=this.options.duration,easing:n=this.options.easing,lerp:l=this.options.lerp,onStart:r,onComplete:h,force:a=!1,programmatic:c=!0,userData:u}={}){if(!this.isStopped&&!this.isLocked||a){if("string"==typeof t&&["top","left","start"].includes(t))t=0;else if("string"==typeof t&&["bottom","right","end"].includes(t))t=this.limit;else{let e;if("string"==typeof t?e=document.querySelector(t):t instanceof HTMLElement&&(null==t?void 0:t.nodeType)&&(e=t),e){if(this.options.wrapper!==window){const t=this.rootElement.getBoundingClientRect();i-=this.isHorizontal?t.left:t.top}const s=e.getBoundingClientRect();t=(this.isHorizontal?s.left:s.top)+this.animatedScroll}}if("number"==typeof t){if(t+=i,t=Math.round(t),this.options.infinite?c&&(this.targetScroll=this.animatedScroll=this.scroll):t=clamp(0,t,this.limit),t===this.targetScroll)return null==r||r(this),void(null==h||h(this));if(this.userData=null!=u?u:{},e)return this.animatedScroll=this.targetScroll=t,this.setScroll(this.scroll),this.reset(),this.preventNextNativeScrollEvent(),this.emit(),null==h||h(this),void(this.userData={});c||(this.targetScroll=t),this.animate.fromTo(this.animatedScroll,t,{duration:o,easing:n,lerp:l,onStart:()=>{s&&(this.isLocked=!0),this.isScrolling="smooth",null==r||r(this)},onUpdate:(t,i)=>{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),i||this.emit(),i&&(this.reset(),this.emit(),null==h||h(this),this.userData={},this.preventNextNativeScrollEvent())}})}}}preventNextNativeScrollEvent(){this._preventNextNativeScrollEvent=!0,requestAnimationFrame((()=>{this._preventNextNativeScrollEvent=!1}))}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,i){return(t%i+i)%i}(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 0f1b6862..1750cf58 100644 --- a/dist/lenis.mjs.map +++ b/dist/lenis.mjs.map @@ -1 +1 @@ -{"version":3,"file":"lenis.mjs","sources":["../../../node_modules/.pnpm/@rollup+plugin-typescript@11.1.6_rollup@4.14.3_tslib@2.6.2_typescript@5.4.5/node_modules/tslib/tslib.es6.js","../../src/maths.ts","../../src/animate.ts","../../src/dimensions.ts","../../src/debounce.ts","../../src/emitter.ts","../../src/virtual-scroll.ts","../../src/index.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n function next() {\r\n while (env.stack.length) {\r\n var rec = env.stack.pop();\r\n try {\r\n var result = rec.dispose && rec.dispose.call(rec.value);\r\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n};\r\n","/**\r\n * Clamp a value between a minimum and maximum value\r\n *\r\n * @param min Minimum value\r\n * @param input Value to clamp\r\n * @param max Maximum value\r\n * @returns Clamped value\r\n */\r\nexport function clamp(min: number, input: number, max: number) {\r\n return Math.max(min, Math.min(input, max))\r\n}\r\n\r\n/**\r\n * Truncate a floating-point number to a specified number of decimal places\r\n *\r\n * @param value Value to truncate\r\n * @param decimals Number of decimal places to truncate to\r\n * @returns Truncated value\r\n */\r\nexport function truncate(value: number, decimals = 0) {\r\n return parseFloat(value.toFixed(decimals))\r\n}\r\n\r\n/**\r\n * Linearly interpolate between two values using an amount (0 <= t <= 1)\r\n *\r\n * @param x First value\r\n * @param y Second value\r\n * @param t Amount to interpolate (0 <= t <= 1)\r\n * @returns Interpolated value\r\n */\r\nexport function lerp(x: number, y: number, t: number) {\r\n return (1 - t) * x + t * y\r\n}\r\n\r\n/**\r\n * Damp a value over time using a damping factor\r\n * {@link http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/}\r\n *\r\n * @param x Initial value\r\n * @param y Target value\r\n * @param lambda Damping factor\r\n * @param dt Time elapsed since the last update\r\n * @returns Damped value\r\n */\r\nexport function damp(x: number, y: number, lambda: number, deltaTime: number) {\r\n return lerp(x, y, 1 - Math.exp(-lambda * deltaTime))\r\n}\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 * {@link https://anguscroll.com/just/just-modulo}\r\n *\r\n * @param n Dividend\r\n * @param d Divisor\r\n * @returns Modulo\r\n */\r\nexport function modulo(n: number, d: number) {\r\n return ((n % d) + d) % d\r\n}\r\n","import { clamp, damp } from './maths'\r\nimport type { EasingFunction, FromToOptions, OnUpdateCallback } from './types'\r\n\r\n/**\r\n * Animate class to handle value animations with lerping or easing\r\n *\r\n * @example\r\n * const animate = new Animate()\r\n * animate.fromTo(0, 100, { duration: 1, easing: (t) => t })\r\n * animate.advance(0.5) // 50\r\n */\r\nexport class Animate {\r\n isRunning = false\r\n value = 0\r\n from = 0\r\n to = 0\r\n currentTime = 0\r\n\r\n // These are instanciated in the fromTo method\r\n lerp?: number\r\n duration?: number\r\n easing?: EasingFunction\r\n onUpdate?: OnUpdateCallback\r\n\r\n /**\r\n * Advance the animation by the given delta time\r\n *\r\n * @param deltaTime - The time in seconds to advance the animation\r\n */\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 /**\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 *\r\n * @param from - The starting value\r\n * @param to - The ending value\r\n * @param options - Options for the animation\r\n */\r\n fromTo(\r\n from: number,\r\n to: number,\r\n { lerp, duration, easing, onStart, onUpdate }: FromToOptions\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\n/**\r\n * Dimensions class to handle the size of the content and wrapper\r\n *\r\n * @example\r\n * const dimensions = new Dimensions(wrapper, content)\r\n * dimensions.on('resize', (e) => {\r\n * console.log(e.width, e.height)\r\n * })\r\n */\r\nexport class Dimensions {\r\n width = 0\r\n height = 0\r\n scrollHeight = 0\r\n scrollWidth = 0\r\n\r\n // These are instanciated in the constructor as they need information from the options\r\n private debouncedResize?: (...args: unknown[]) => void\r\n private wrapperResizeObserver?: ResizeObserver\r\n private contentResizeObserver?: ResizeObserver\r\n\r\n constructor(\r\n private wrapper: HTMLElement | Window,\r\n private content: HTMLElement,\r\n { autoResize = true, debounce: debounceValue = 250 } = {}\r\n ) {\r\n if (autoResize) {\r\n this.debouncedResize = debounce(this.resize, debounceValue)\r\n\r\n if (this.wrapper instanceof 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\r\n if (this.wrapper === window && this.debouncedResize) {\r\n window.removeEventListener('resize', this.debouncedResize, 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 instanceof 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 instanceof 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 void>(\r\n callback: CB,\r\n delay: number\r\n) {\r\n let timer: number | undefined\r\n return function (this: T, ...args: Parameters) {\r\n let context = this\r\n clearTimeout(timer)\r\n timer = setTimeout(() => {\r\n timer = undefined\r\n callback.apply(context, args)\r\n }, delay)\r\n }\r\n}\r\n","/**\r\n * Emitter class to handle events\r\n * @example\r\n * const emitter = new Emitter()\r\n * emitter.on('event', (data) => {\r\n * console.log(data)\r\n * })\r\n * emitter.emit('event', 'data')\r\n */\r\nexport class Emitter {\r\n private events: Record<\r\n string,\r\n Array<(...args: unknown[]) => void> | undefined\r\n > = {}\r\n\r\n /**\r\n * Emit an event with the given data\r\n * @param event Event name\r\n * @param args Data to pass to the event handlers\r\n */\r\n emit(event: string, ...args: unknown[]) {\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 /**\r\n * Add a callback to the event\r\n * @param event Event name\r\n * @param cb Callback function\r\n * @returns Unsubscribe function\r\n */\r\n on void>(event: string, cb: 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 /**\r\n * Remove a callback from the event\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n off void>(event: string, callback: CB) {\r\n this.events[event] = this.events[event]?.filter((i) => callback !== i)\r\n }\r\n\r\n /**\r\n * Remove all event listeners and clean up\r\n */\r\n destroy() {\r\n this.events = {}\r\n }\r\n}\r\n","import { Emitter } from './emitter'\r\nimport { VirtualScrollCallback } from './types'\r\n\r\nconst LINE_HEIGHT = 100 / 6\r\nconst listenerOptions: AddEventListenerOptions = { passive: false }\r\n\r\nexport class VirtualScroll {\r\n touchStart = {\r\n x: 0,\r\n y: 0,\r\n }\r\n lastDelta = {\r\n x: 0,\r\n y: 0,\r\n }\r\n window = {\r\n width: 0,\r\n height: 0,\r\n }\r\n private emitter = new Emitter()\r\n\r\n constructor(\r\n private element: HTMLElement,\r\n private options = { wheelMultiplier: 1, touchMultiplier: 1 }\r\n ) {\r\n window.addEventListener('resize', this.onWindowResize, false)\r\n this.onWindowResize()\r\n\r\n this.element.addEventListener('wheel', this.onWheel, listenerOptions)\r\n this.element.addEventListener(\r\n 'touchstart',\r\n this.onTouchStart,\r\n listenerOptions\r\n )\r\n this.element.addEventListener(\r\n 'touchmove',\r\n this.onTouchMove,\r\n listenerOptions\r\n )\r\n this.element.addEventListener('touchend', this.onTouchEnd, listenerOptions)\r\n }\r\n\r\n /**\r\n * Add an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n on(event: string, callback: VirtualScrollCallback) {\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, listenerOptions)\r\n this.element.removeEventListener(\r\n 'touchstart',\r\n this.onTouchStart,\r\n listenerOptions\r\n )\r\n this.element.removeEventListener(\r\n 'touchmove',\r\n this.onTouchMove,\r\n listenerOptions\r\n )\r\n this.element.removeEventListener(\r\n 'touchend',\r\n this.onTouchEnd,\r\n listenerOptions\r\n )\r\n }\r\n\r\n /**\r\n * Event handler for 'touchstart' event\r\n *\r\n * @param event Touch event\r\n */\r\n onTouchStart = (event: TouchEvent) => {\r\n // @ts-expect-error - event.targetTouches is not defined\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 - event.targetTouches is not defined\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.options.touchMultiplier\r\n const deltaY = -(clientY - this.touchStart.y) * this.options.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.window.width : 1\r\n const multiplierY =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.window.height : 1\r\n\r\n deltaX *= multiplierX\r\n deltaY *= multiplierY\r\n\r\n deltaX *= this.options.wheelMultiplier\r\n deltaY *= this.options.wheelMultiplier\r\n\r\n this.emitter.emit('scroll', { deltaX, deltaY, event })\r\n }\r\n\r\n onWindowResize = () => {\r\n this.window = {\r\n width: window.innerWidth,\r\n height: window.innerHeight,\r\n }\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 type {\r\n LenisEvent,\r\n LenisOptions,\r\n ScrollCallback,\r\n Scrolling,\r\n ScrollToOptions,\r\n UserData,\r\n VirtualScrollCallback,\r\n VirtualScrollData,\r\n} from './types'\r\nimport { VirtualScroll } from './virtual-scroll'\r\n\r\n// Types\r\nexport * from './types'\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 OptionalPick = Omit & Partial>\r\n\r\nexport default class Lenis {\r\n #isScrolling: Scrolling = false // true when scroll is animating\r\n #isStopped = false // true if user should not be able to scroll - enable/disable programmatically\r\n #isLocked = false // same as isStopped but enabled/disabled when scroll reaches target\r\n #preventNextNativeScrollEvent = false\r\n #resetVelocityTimeout: number | null = null\r\n\r\n /**\r\n * Whether or not the user is touching the screen\r\n */\r\n isTouching?: boolean\r\n /**\r\n * The time in ms since the lenis instance was created\r\n */\r\n time = 0\r\n /**\r\n * User data that will be forwarded through the scroll event\r\n *\r\n * @example\r\n * lenis.scrollTo(100, {\r\n * userData: {\r\n * foo: 'bar'\r\n * }\r\n * })\r\n */\r\n userData: UserData = {}\r\n /**\r\n * The last velocity of the scroll\r\n */\r\n lastVelocity = 0\r\n /**\r\n * The current velocity of the scroll\r\n */\r\n velocity = 0\r\n /**\r\n * The direction of the scroll\r\n */\r\n direction: 1 | -1 | 0 = 0\r\n /**\r\n * The options passed to the lenis instance\r\n */\r\n options: OptionalPick<\r\n Required,\r\n 'duration' | 'prevent' | 'virtualScroll'\r\n >\r\n /**\r\n * The target scroll value\r\n */\r\n targetScroll: number\r\n /**\r\n * The animated scroll value\r\n */\r\n animatedScroll: number\r\n\r\n // These are instanciated here as they don't need information from the options\r\n private readonly animate = new Animate()\r\n private readonly emitter = new Emitter()\r\n // These are instanciated in the constructor as they need information from the options\r\n readonly dimensions: Dimensions // This is not private because it's used in the Snap class\r\n private readonly virtualScroll: VirtualScroll\r\n\r\n constructor({\r\n wrapper = window,\r\n content = document.documentElement,\r\n eventsTarget = wrapper,\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 // Set version\r\n window.lenisVersion = version\r\n\r\n // Check 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 // Setup options\r\n this.options = {\r\n wrapper,\r\n content,\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 }\r\n\r\n // Setup dimensions instance\r\n this.dimensions = new Dimensions(wrapper, content, { autoResize })\r\n\r\n // Setup class name\r\n this.updateClassName()\r\n\r\n // Set the initial scroll value for all scroll information\r\n this.targetScroll = this.animatedScroll = this.actualScroll\r\n\r\n // Add event listeners\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 // Setup virtual scroll instance\r\n this.virtualScroll = new VirtualScroll(eventsTarget as HTMLElement, {\r\n touchMultiplier,\r\n wheelMultiplier,\r\n })\r\n this.virtualScroll.on('scroll', this.onVirtualScroll)\r\n }\r\n\r\n /**\r\n * Destroy the lenis instance, remove all event listeners and clean up the class name\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\r\n /**\r\n * Add an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n * @returns Unsubscribe function\r\n */\r\n on(event: 'scroll', callback: ScrollCallback): () => void\r\n on(event: 'virtual-scroll', callback: VirtualScrollCallback): () => void\r\n on(event: LenisEvent, callback: any) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n /**\r\n * Remove an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n off(event: 'scroll', callback: ScrollCallback): void\r\n off(event: 'virtual-scroll', callback: VirtualScrollCallback): void\r\n off(event: LenisEvent, callback: any) {\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: VirtualScrollData) => {\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 HTMLElement &&\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 /**\r\n * Force lenis to recalculate the dimensions\r\n */\r\n resize() {\r\n this.dimensions.resize()\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.emit()\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 if (this.#resetVelocityTimeout !== null) {\r\n clearTimeout(this.#resetVelocityTimeout)\r\n this.#resetVelocityTimeout = null\r\n }\r\n\r\n if (this.#preventNextNativeScrollEvent) {\r\n this.#preventNextNativeScrollEvent = false\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.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 }\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 /**\r\n * Start lenis scroll after it has been stopped\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 /**\r\n * Stop lenis scroll\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 /**\r\n * RequestAnimationFrame for lenis\r\n *\r\n * @param time The time in ms from an external clock like `requestAnimationFrame` or Tempus\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 /**\r\n * Scroll to a target value\r\n *\r\n * @param target The target value to scroll to\r\n * @param options The options for the scroll\r\n *\r\n * @example\r\n * lenis.scrollTo(100, {\r\n * offset: 100,\r\n * duration: 1,\r\n * easing: (t) => 1 - Math.cos((t * Math.PI) / 2),\r\n * lerp: 0.1,\r\n * onStart: () => {\r\n * console.log('onStart')\r\n * },\r\n * onComplete: () => {\r\n * console.log('onComplete')\r\n * },\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 }: ScrollToOptions = {}\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) {\r\n onStart?.(this)\r\n onComplete?.(this)\r\n return\r\n }\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 // 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 this.#preventNextNativeScrollEvent = false\r\n })\r\n }\r\n\r\n /**\r\n * The root element on which lenis is instanced\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 /**\r\n * The limit which is the maximum scroll value\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 /**\r\n * Whether or not the scroll is horizontal\r\n */\r\n get isHorizontal() {\r\n return this.options.orientation === 'horizontal'\r\n }\r\n\r\n /**\r\n * The actual scroll value\r\n */\r\n get actualScroll() {\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 /**\r\n * The current scroll value\r\n */\r\n get scroll() {\r\n return this.options.infinite\r\n ? modulo(this.animatedScroll, this.limit)\r\n : this.animatedScroll\r\n }\r\n\r\n /**\r\n * The progress of the scroll relative to the limit\r\n */\r\n get progress() {\r\n // avoid progress to be NaN\r\n return this.limit === 0 ? 1 : this.scroll / this.limit\r\n }\r\n\r\n /**\r\n * Current scroll state\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 /**\r\n * Check if lenis is stopped\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 /**\r\n * Check if lenis is locked\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 /**\r\n * Check if lenis is smooth scrolling\r\n */\r\n get isSmooth() {\r\n return this.isScrolling === 'smooth'\r\n }\r\n\r\n /**\r\n * The class name applied to the wrapper element\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 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":["__classPrivateFieldGet","receiver","state","kind","f","TypeError","has","call","value","get","__classPrivateFieldSet","set","SuppressedError","clamp","min","input","max","Math","Animate","constructor","this","isRunning","from","to","currentTime","advance","deltaTime","completed","duration","easing","linearProgress","easedProgress","lerp","damp","x","y","lambda","t","exp","round","stop","_a","onUpdate","fromTo","onStart","Dimensions","wrapper","content","autoResize","debounce","debounceValue","width","height","scrollHeight","scrollWidth","resize","onWrapperResize","onContentResize","Window","window","innerWidth","innerHeight","clientWidth","clientHeight","debouncedResize","callback","delay","timer","args","context","clearTimeout","setTimeout","undefined","apply","addEventListener","wrapperResizeObserver","ResizeObserver","observe","contentResizeObserver","destroy","disconnect","_b","removeEventListener","limit","Emitter","events","emit","event","callbacks","i","length","on","cb","push","filter","off","LINE_HEIGHT","listenerOptions","passive","VirtualScroll","element","options","wheelMultiplier","touchMultiplier","touchStart","lastDelta","emitter","onTouchStart","clientX","clientY","targetTouches","deltaX","deltaY","onTouchMove","onTouchEnd","onWheel","deltaMode","onWindowResize","Lenis","document","documentElement","eventsTarget","smoothWheel","syncTouch","syncTouchLerp","touchInertiaMultiplier","pow","infinite","orientation","gestureOrientation","prevent","virtualScroll","__experimental__naiveDimensions","_Lenis_isScrolling","_Lenis_isStopped","_Lenis_isLocked","_Lenis_preventNextNativeScrollEvent","_Lenis_resetVelocityTimeout","time","userData","lastVelocity","velocity","direction","animate","onPointerDown","button","reset","onVirtualScroll","data","ctrlKey","isTouch","type","includes","isWheel","isTouching","isStopped","isLocked","isClick","isUnknownGesture","composedPath","slice","indexOf","rootElement","find","node","HTMLElement","hasAttribute","_c","classList","_d","contains","_e","preventDefault","isScrolling","delta","abs","hasTouchInertia","scrollTo","targetScroll","Object","assign","programmatic","onNativeScroll","lastScroll","animatedScroll","actualScroll","sign","lenisVersion","body","dimensions","updateClassName","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":"AAoRO,SAASA,uBAAuBC,EAAUC,EAAOC,EAAMC,GAC1D,GAAa,MAATD,IAAiBC,EAAG,MAAM,IAAIC,UAAU,iDAC5C,GAAqB,mBAAVH,EAAuBD,IAAaC,IAAUE,GAAKF,EAAMI,IAAIL,GAAW,MAAM,IAAII,UAAU,4EACvG,MAAgB,MAATF,EAAeC,EAAa,MAATD,EAAeC,EAAEG,KAAKN,GAAYG,EAAIA,EAAEI,MAAQN,EAAMO,IAAIR,EACxF,CAEO,SAASS,uBAAuBT,EAAUC,EAAOM,EAAOL,EAAMC,GACjE,GAAa,MAAT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AAQ,gBAAiB,IACzBD,MACJ","x_google_ignoreList":[0]} \ No newline at end of file +{"version":3,"file":"lenis.mjs","sources":["../../src/maths.ts","../../src/animate.ts","../../src/dimensions.ts","../../src/debounce.ts","../../src/emitter.ts","../../src/virtual-scroll.ts","../../src/index.ts"],"sourcesContent":["/**\r\n * Clamp a value between a minimum and maximum value\r\n *\r\n * @param min Minimum value\r\n * @param input Value to clamp\r\n * @param max Maximum value\r\n * @returns Clamped value\r\n */\r\nexport function clamp(min: number, input: number, max: number) {\r\n return Math.max(min, Math.min(input, max))\r\n}\r\n\r\n/**\r\n * Truncate a floating-point number to a specified number of decimal places\r\n *\r\n * @param value Value to truncate\r\n * @param decimals Number of decimal places to truncate to\r\n * @returns Truncated value\r\n */\r\nexport function truncate(value: number, decimals = 0) {\r\n return parseFloat(value.toFixed(decimals))\r\n}\r\n\r\n/**\r\n * Linearly interpolate between two values using an amount (0 <= t <= 1)\r\n *\r\n * @param x First value\r\n * @param y Second value\r\n * @param t Amount to interpolate (0 <= t <= 1)\r\n * @returns Interpolated value\r\n */\r\nexport function lerp(x: number, y: number, t: number) {\r\n return (1 - t) * x + t * y\r\n}\r\n\r\n/**\r\n * Damp a value over time using a damping factor\r\n * {@link http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/}\r\n *\r\n * @param x Initial value\r\n * @param y Target value\r\n * @param lambda Damping factor\r\n * @param dt Time elapsed since the last update\r\n * @returns Damped value\r\n */\r\nexport function damp(x: number, y: number, lambda: number, deltaTime: number) {\r\n return lerp(x, y, 1 - Math.exp(-lambda * deltaTime))\r\n}\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 * {@link https://anguscroll.com/just/just-modulo}\r\n *\r\n * @param n Dividend\r\n * @param d Divisor\r\n * @returns Modulo\r\n */\r\nexport function modulo(n: number, d: number) {\r\n return ((n % d) + d) % d\r\n}\r\n","import { clamp, damp } from './maths'\r\nimport type { EasingFunction, FromToOptions, OnUpdateCallback } from './types'\r\n\r\n/**\r\n * Animate class to handle value animations with lerping or easing\r\n *\r\n * @example\r\n * const animate = new Animate()\r\n * animate.fromTo(0, 100, { duration: 1, easing: (t) => t })\r\n * animate.advance(0.5) // 50\r\n */\r\nexport class Animate {\r\n isRunning = false\r\n value = 0\r\n from = 0\r\n to = 0\r\n currentTime = 0\r\n\r\n // These are instanciated in the fromTo method\r\n lerp?: number\r\n duration?: number\r\n easing?: EasingFunction\r\n onUpdate?: OnUpdateCallback\r\n\r\n /**\r\n * Advance the animation by the given delta time\r\n *\r\n * @param deltaTime - The time in seconds to advance the animation\r\n */\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 /**\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 *\r\n * @param from - The starting value\r\n * @param to - The ending value\r\n * @param options - Options for the animation\r\n */\r\n fromTo(\r\n from: number,\r\n to: number,\r\n { lerp, duration, easing, onStart, onUpdate }: FromToOptions\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\n/**\r\n * Dimensions class to handle the size of the content and wrapper\r\n *\r\n * @example\r\n * const dimensions = new Dimensions(wrapper, content)\r\n * dimensions.on('resize', (e) => {\r\n * console.log(e.width, e.height)\r\n * })\r\n */\r\nexport class Dimensions {\r\n width = 0\r\n height = 0\r\n scrollHeight = 0\r\n scrollWidth = 0\r\n\r\n // These are instanciated in the constructor as they need information from the options\r\n private debouncedResize?: (...args: unknown[]) => void\r\n private wrapperResizeObserver?: ResizeObserver\r\n private contentResizeObserver?: ResizeObserver\r\n\r\n constructor(\r\n private wrapper: HTMLElement | Window,\r\n private content: HTMLElement,\r\n { autoResize = true, debounce: debounceValue = 250 } = {}\r\n ) {\r\n if (autoResize) {\r\n this.debouncedResize = debounce(this.resize, debounceValue)\r\n\r\n if (this.wrapper instanceof 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\r\n if (this.wrapper === window && this.debouncedResize) {\r\n window.removeEventListener('resize', this.debouncedResize, 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 instanceof 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 instanceof 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 void>(\r\n callback: CB,\r\n delay: number\r\n) {\r\n let timer: number | undefined\r\n return function (this: T, ...args: Parameters) {\r\n let context = this\r\n clearTimeout(timer)\r\n timer = setTimeout(() => {\r\n timer = undefined\r\n callback.apply(context, args)\r\n }, delay)\r\n }\r\n}\r\n","/**\r\n * Emitter class to handle events\r\n * @example\r\n * const emitter = new Emitter()\r\n * emitter.on('event', (data) => {\r\n * console.log(data)\r\n * })\r\n * emitter.emit('event', 'data')\r\n */\r\nexport class Emitter {\r\n private events: Record<\r\n string,\r\n Array<(...args: unknown[]) => void> | undefined\r\n > = {}\r\n\r\n /**\r\n * Emit an event with the given data\r\n * @param event Event name\r\n * @param args Data to pass to the event handlers\r\n */\r\n emit(event: string, ...args: unknown[]) {\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 /**\r\n * Add a callback to the event\r\n * @param event Event name\r\n * @param cb Callback function\r\n * @returns Unsubscribe function\r\n */\r\n on void>(event: string, cb: 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 /**\r\n * Remove a callback from the event\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n off void>(event: string, callback: CB) {\r\n this.events[event] = this.events[event]?.filter((i) => callback !== i)\r\n }\r\n\r\n /**\r\n * Remove all event listeners and clean up\r\n */\r\n destroy() {\r\n this.events = {}\r\n }\r\n}\r\n","import { Emitter } from './emitter'\r\nimport { VirtualScrollCallback } from './types'\r\n\r\nconst LINE_HEIGHT = 100 / 6\r\nconst listenerOptions: AddEventListenerOptions = { passive: false }\r\n\r\nexport class VirtualScroll {\r\n touchStart = {\r\n x: 0,\r\n y: 0,\r\n }\r\n lastDelta = {\r\n x: 0,\r\n y: 0,\r\n }\r\n window = {\r\n width: 0,\r\n height: 0,\r\n }\r\n private emitter = new Emitter()\r\n\r\n constructor(\r\n private element: HTMLElement,\r\n private options = { wheelMultiplier: 1, touchMultiplier: 1 }\r\n ) {\r\n window.addEventListener('resize', this.onWindowResize, false)\r\n this.onWindowResize()\r\n\r\n this.element.addEventListener('wheel', this.onWheel, listenerOptions)\r\n this.element.addEventListener(\r\n 'touchstart',\r\n this.onTouchStart,\r\n listenerOptions\r\n )\r\n this.element.addEventListener(\r\n 'touchmove',\r\n this.onTouchMove,\r\n listenerOptions\r\n )\r\n this.element.addEventListener('touchend', this.onTouchEnd, listenerOptions)\r\n }\r\n\r\n /**\r\n * Add an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n on(event: string, callback: VirtualScrollCallback) {\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, listenerOptions)\r\n this.element.removeEventListener(\r\n 'touchstart',\r\n this.onTouchStart,\r\n listenerOptions\r\n )\r\n this.element.removeEventListener(\r\n 'touchmove',\r\n this.onTouchMove,\r\n listenerOptions\r\n )\r\n this.element.removeEventListener(\r\n 'touchend',\r\n this.onTouchEnd,\r\n listenerOptions\r\n )\r\n }\r\n\r\n /**\r\n * Event handler for 'touchstart' event\r\n *\r\n * @param event Touch event\r\n */\r\n onTouchStart = (event: TouchEvent) => {\r\n // @ts-expect-error - event.targetTouches is not defined\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 - event.targetTouches is not defined\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.options.touchMultiplier\r\n const deltaY = -(clientY - this.touchStart.y) * this.options.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.window.width : 1\r\n const multiplierY =\r\n deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.window.height : 1\r\n\r\n deltaX *= multiplierX\r\n deltaY *= multiplierY\r\n\r\n deltaX *= this.options.wheelMultiplier\r\n deltaY *= this.options.wheelMultiplier\r\n\r\n this.emitter.emit('scroll', { deltaX, deltaY, event })\r\n }\r\n\r\n onWindowResize = () => {\r\n this.window = {\r\n width: window.innerWidth,\r\n height: window.innerHeight,\r\n }\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 type {\r\n LenisEvent,\r\n LenisOptions,\r\n ScrollCallback,\r\n Scrolling,\r\n ScrollToOptions,\r\n UserData,\r\n VirtualScrollCallback,\r\n VirtualScrollData,\r\n} from './types'\r\nimport { VirtualScroll } from './virtual-scroll'\r\n\r\n// Types\r\nexport * from './types'\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 OptionalPick = Omit & Partial>\r\n\r\nexport default class Lenis {\r\n private _isScrolling: Scrolling = false // true when scroll is animating\r\n private _isStopped = false // true if user should not be able to scroll - enable/disable programmatically\r\n private _isLocked = false // same as isStopped but enabled/disabled when scroll reaches target\r\n private _preventNextNativeScrollEvent = false\r\n private _resetVelocityTimeout: number | null = null\r\n\r\n /**\r\n * Whether or not the user is touching the screen\r\n */\r\n isTouching?: boolean\r\n /**\r\n * The time in ms since the lenis instance was created\r\n */\r\n time = 0\r\n /**\r\n * User data that will be forwarded through the scroll event\r\n *\r\n * @example\r\n * lenis.scrollTo(100, {\r\n * userData: {\r\n * foo: 'bar'\r\n * }\r\n * })\r\n */\r\n userData: UserData = {}\r\n /**\r\n * The last velocity of the scroll\r\n */\r\n lastVelocity = 0\r\n /**\r\n * The current velocity of the scroll\r\n */\r\n velocity = 0\r\n /**\r\n * The direction of the scroll\r\n */\r\n direction: 1 | -1 | 0 = 0\r\n /**\r\n * The options passed to the lenis instance\r\n */\r\n options: OptionalPick<\r\n Required,\r\n 'duration' | 'prevent' | 'virtualScroll'\r\n >\r\n /**\r\n * The target scroll value\r\n */\r\n targetScroll: number\r\n /**\r\n * The animated scroll value\r\n */\r\n animatedScroll: number\r\n\r\n // These are instanciated here as they don't need information from the options\r\n private readonly animate = new Animate()\r\n private readonly emitter = new Emitter()\r\n // These are instanciated in the constructor as they need information from the options\r\n readonly dimensions: Dimensions // This is not private because it's used in the Snap class\r\n private readonly virtualScroll: VirtualScroll\r\n\r\n constructor({\r\n wrapper = window,\r\n content = document.documentElement,\r\n eventsTarget = wrapper,\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 // Set version\r\n window.lenisVersion = version\r\n\r\n // Check 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 // Setup options\r\n this.options = {\r\n wrapper,\r\n content,\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 }\r\n\r\n // Setup dimensions instance\r\n this.dimensions = new Dimensions(wrapper, content, { autoResize })\r\n\r\n // Setup class name\r\n this.updateClassName()\r\n\r\n // Set the initial scroll value for all scroll information\r\n this.targetScroll = this.animatedScroll = this.actualScroll\r\n\r\n // Add event listeners\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 // Setup virtual scroll instance\r\n this.virtualScroll = new VirtualScroll(eventsTarget as HTMLElement, {\r\n touchMultiplier,\r\n wheelMultiplier,\r\n })\r\n this.virtualScroll.on('scroll', this.onVirtualScroll)\r\n }\r\n\r\n /**\r\n * Destroy the lenis instance, remove all event listeners and clean up the class name\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\r\n /**\r\n * Add an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n * @returns Unsubscribe function\r\n */\r\n on(event: 'scroll', callback: ScrollCallback): () => void\r\n on(event: 'virtual-scroll', callback: VirtualScrollCallback): () => void\r\n on(event: LenisEvent, callback: any) {\r\n return this.emitter.on(event, callback)\r\n }\r\n\r\n /**\r\n * Remove an event listener for the given event and callback\r\n *\r\n * @param event Event name\r\n * @param callback Callback function\r\n */\r\n off(event: 'scroll', callback: ScrollCallback): void\r\n off(event: 'virtual-scroll', callback: VirtualScrollCallback): void\r\n off(event: LenisEvent, callback: any) {\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: VirtualScrollData) => {\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 HTMLElement &&\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 /**\r\n * Force lenis to recalculate the dimensions\r\n */\r\n resize() {\r\n this.dimensions.resize()\r\n this.animatedScroll = this.targetScroll = this.actualScroll\r\n this.emit()\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 if (this._resetVelocityTimeout !== null) {\r\n clearTimeout(this._resetVelocityTimeout)\r\n this._resetVelocityTimeout = null\r\n }\r\n\r\n if (this._preventNextNativeScrollEvent) {\r\n this._preventNextNativeScrollEvent = false\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.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 }\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 /**\r\n * Start lenis scroll after it has been stopped\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 /**\r\n * Stop lenis scroll\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 /**\r\n * RequestAnimationFrame for lenis\r\n *\r\n * @param time The time in ms from an external clock like `requestAnimationFrame` or Tempus\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 /**\r\n * Scroll to a target value\r\n *\r\n * @param target The target value to scroll to\r\n * @param options The options for the scroll\r\n *\r\n * @example\r\n * lenis.scrollTo(100, {\r\n * offset: 100,\r\n * duration: 1,\r\n * easing: (t) => 1 - Math.cos((t * Math.PI) / 2),\r\n * lerp: 0.1,\r\n * onStart: () => {\r\n * console.log('onStart')\r\n * },\r\n * onComplete: () => {\r\n * console.log('onComplete')\r\n * },\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 }: ScrollToOptions = {}\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) {\r\n onStart?.(this)\r\n onComplete?.(this)\r\n return\r\n }\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 // 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 this._preventNextNativeScrollEvent = false\r\n })\r\n }\r\n\r\n /**\r\n * The root element on which lenis is instanced\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 /**\r\n * The limit which is the maximum scroll value\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 /**\r\n * Whether or not the scroll is horizontal\r\n */\r\n get isHorizontal() {\r\n return this.options.orientation === 'horizontal'\r\n }\r\n\r\n /**\r\n * The actual scroll value\r\n */\r\n get actualScroll() {\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 /**\r\n * The current scroll value\r\n */\r\n get scroll() {\r\n return this.options.infinite\r\n ? modulo(this.animatedScroll, this.limit)\r\n : this.animatedScroll\r\n }\r\n\r\n /**\r\n * The progress of the scroll relative to the limit\r\n */\r\n get progress() {\r\n // avoid progress to be NaN\r\n return this.limit === 0 ? 1 : this.scroll / this.limit\r\n }\r\n\r\n /**\r\n * Current scroll state\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 /**\r\n * Check if lenis is stopped\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 /**\r\n * Check if lenis is locked\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 /**\r\n * Check if lenis is smooth scrolling\r\n */\r\n get isSmooth() {\r\n return this.isScrolling === 'smooth'\r\n }\r\n\r\n /**\r\n * The class name applied to the wrapper element\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 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","currentTime","advance","deltaTime","completed","duration","easing","linearProgress","easedProgress","lerp","damp","x","y","lambda","t","exp","round","stop","_a","onUpdate","call","fromTo","onStart","Dimensions","wrapper","content","autoResize","debounce","debounceValue","width","height","scrollHeight","scrollWidth","resize","onWrapperResize","onContentResize","Window","window","innerWidth","innerHeight","clientWidth","clientHeight","debouncedResize","callback","delay","timer","args","context","clearTimeout","setTimeout","undefined","apply","addEventListener","wrapperResizeObserver","ResizeObserver","observe","contentResizeObserver","destroy","disconnect","_b","removeEventListener","limit","Emitter","events","emit","event","callbacks","i","length","on","cb","push","filter","off","LINE_HEIGHT","listenerOptions","passive","VirtualScroll","element","options","wheelMultiplier","touchMultiplier","touchStart","lastDelta","emitter","onTouchStart","clientX","clientY","targetTouches","deltaX","deltaY","onTouchMove","onTouchEnd","onWheel","deltaMode","onWindowResize","Lenis","document","documentElement","eventsTarget","smoothWheel","syncTouch","syncTouchLerp","touchInertiaMultiplier","pow","infinite","orientation","gestureOrientation","prevent","virtualScroll","__experimental__naiveDimensions","_isScrolling","_isStopped","_isLocked","_preventNextNativeScrollEvent","_resetVelocityTimeout","time","userData","lastVelocity","velocity","direction","animate","onPointerDown","button","reset","onVirtualScroll","data","ctrlKey","isTouch","type","includes","isWheel","isTouching","isStopped","isLocked","isClick","isUnknownGesture","composedPath","slice","indexOf","rootElement","find","node","HTMLElement","hasAttribute","_c","classList","_d","contains","_e","preventDefault","isScrolling","delta","abs","hasTouchInertia","scrollTo","targetScroll","Object","assign","programmatic","onNativeScroll","lastScroll","animatedScroll","actualScroll","sign","lenisVersion","body","dimensions","updateClassName","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":"SAQgBA,MAAMC,EAAaC,EAAeC,GAChD,OAAOC,KAAKD,IAAIF,EAAKG,KAAKH,IAAIC,EAAOC,GACvC,OCCaE,QAAb,WAAAC,GACEC,KAASC,WAAG,EACZD,KAAKE,MAAG,EACRF,KAAIG,KAAG,EACPH,KAAEI,GAAG,EACLJ,KAAWK,YAAG,CA0Ef,CA7DC,OAAAC,CAAQC,SACN,IAAKP,KAAKC,UAAW,OAErB,IAAIO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