1
0
mirror of https://github.com/flarum/core.git synced 2025-08-08 01:16:52 +02:00
Files
php-flarum/js/dist-typings/common/utils/anchorScroll.d.ts
flarum-bot 3d62a6af27 Bundled output for commit d268894e61
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-27 19:02:33 +00:00

15 lines
807 B
TypeScript

/**
* The `anchorScroll` utility saves the scroll position relative to an element,
* and then restores it after a callback has been run.
*
* This is useful if a redraw will change the page's content above the viewport.
* Normally doing this will result in the content in the viewport being pushed
* down or pulled up. By wrapping the redraw with this utility, the scroll
* position can be anchor to an element that is in or below the viewport, so
* the content in the viewport will stay the same.
*
* @param {HTMLElement | SVGElement | Element} element The element to anchor the scroll position to.
* @param {() => void} callback The callback to run that will change page content.
*/
export default function anchorScroll(element: HTMLElement | SVGElement | Element, callback: () => void): void;