We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents e2c7806 + 043cd27 commit 42164b2Copy full SHA for 42164b2
src/utils/scrollUtils.ts
@@ -0,0 +1,14 @@
1
+// Scroll utility functions
2
+export function scrollToElement(id: string, offset: number = 80): void {
3
+ const el = document.getElementById(id);
4
+ if (el) { const y = el.getBoundingClientRect().top + window.scrollY - offset; window.scrollTo({ top: y, behavior: 'smooth' }); }
5
+}
6
+
7
+export function lockScroll(): () => void {
8
+ const scrollY = window.scrollY;
9
+ document.body.style.position = 'fixed';
10
+ document.body.style.top = '-' + scrollY + 'px';
11
+ document.body.style.width = '100%';
12
+ return () => { document.body.style.position = ''; document.body.style.top = ''; document.body.style.width = ''; window.scrollTo(0, scrollY); };
13
14
0 commit comments