mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
move utility methods to @/utils
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
Reference in New Issue
Block a user