mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 04:23:01 +00:00
24 lines
513 B
TypeScript
24 lines
513 B
TypeScript
/**
|
|
* Scrolls a element into view.
|
|
* @param className The class to focus
|
|
* @param delay Delay in milliseconds
|
|
* @param pos Positioning of the focus element
|
|
*/
|
|
export default function focusElem(
|
|
className: string,
|
|
delay?: number,
|
|
pos?: any
|
|
) {
|
|
const dom = document.getElementsByClassName(className)[0];
|
|
|
|
setTimeout(() => {
|
|
if (dom) {
|
|
dom.scrollIntoView({
|
|
behavior: "smooth",
|
|
block: `${pos ?? "start"}` as any,
|
|
inline: "center",
|
|
});
|
|
}
|
|
}, delay | 300);
|
|
}
|