@studiometa/js-toolkit
Version:
A set of useful little bits of JavaScript to boost your project! 🚀
34 lines (33 loc) • 974 B
TypeScript
import type { TweenOptions } from './tween.js';
export interface ScrollPosition {
left: number;
top: number;
}
export type ScrollTarget = string | HTMLElement | number | Partial<ScrollPosition>;
export interface ScrollToOptions extends TweenOptions {
/**
* Root element that will be scrolled.
*/
rootElement?: HTMLElement | typeof window;
/**
* Scroll direction.
*/
axis?: (typeof scrollTo.axis)[keyof typeof scrollTo.axis];
/**
* Distance from the target.
*/
offset?: number;
}
/**
* Scroll to an element.
*
* @returns {Promise<ScrollPosition>} A promising resolving with the scroll position.
*/
export declare function scrollTo(target: string | HTMLElement | number | Partial<ScrollPosition>, { rootElement, axis, offset, ...tweenOptions }?: ScrollToOptions): Promise<ScrollPosition>;
export declare namespace scrollTo {
var axis: {
x: symbol;
y: symbol;
both: symbol;
};
}