UNPKG

use-elevator

Version:

A React hook for smooth scrolling that transforms boring scroll-to-top actions into playful elevator experiences with customizable settings

27 lines (26 loc) 1.28 kB
/** * Easing function for smooth scrolling animation with quadratic acceleration and deceleration. * * @param {number} time - Current time position in the animation * @param {number} start - Starting value * @param {number} change - Change in value * @param {number} duration - Total duration of animation * @returns {number} The calculated position value for the current time */ export declare const easeInOutQuad: (time: number, start: number, change: number, duration: number) => number; /** * Calculates the scroll position to an element, accounting for its offset parents. * * @param {string} elementId - ID of the target element to scroll to * @param {number} padding - Vertical padding to apply from the element (default: 0) * @returns {number} The vertical scroll position in pixels */ export declare const calculateElementScrollPosition: (elementId: string, padding?: number) => number; /** * Calculates optimal animation duration based on scroll distance. * * @param {number} distance - Distance to scroll in pixels * @param {number} customDuration - Optional user-defined duration * @returns {number} The calculated duration in milliseconds */ export declare const calculateScrollDuration: (distance: number, customDuration?: number) => number;