diff --git a/hwe/ts/util/scrollHardTo.ts b/hwe/ts/util/scrollHardTo.ts index 3efa8262..8f081afd 100644 --- a/hwe/ts/util/scrollHardTo.ts +++ b/hwe/ts/util/scrollHardTo.ts @@ -1,3 +1,4 @@ +/** @deprecated */ export function scrollHardTo(elementId: string): void { const element = document.getElementById(elementId); if(!element){ diff --git a/hwe/ts/util/scrollToSelector.ts b/hwe/ts/util/scrollToSelector.ts new file mode 100644 index 00000000..b8bee24a --- /dev/null +++ b/hwe/ts/util/scrollToSelector.ts @@ -0,0 +1,9 @@ +export function scrollToSelector(selector: string): void { + const element = document.querySelector(selector); + if(!element){ + return; + } + element.scrollIntoView({ + behavior: 'auto', + }); + } \ No newline at end of file