refactor not done

This commit is contained in:
Maze Winther
2025-11-26 08:47:03 +01:00
commit efbebd13b8
431 changed files with 51577 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import { useEffect } from 'react';
interface UsePreventScrollOptions {
enabled?: boolean;
element?: HTMLElement;
}
export function usePreventScroll({ enabled = true, element }: UsePreventScrollOptions = {}) {
useEffect(() => {
if (!enabled) return;
const targetElement = element || document.body;
const originalOverflow = targetElement.style.overflow;
const originalPaddingRight = targetElement.style.paddingRight;
const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
targetElement.style.overflow = 'hidden';
if (scrollbarWidth > 0) {
targetElement.style.paddingRight = `${scrollbarWidth}px`;
}
return () => {
targetElement.style.overflow = originalOverflow;
targetElement.style.paddingRight = originalPaddingRight;
};
}, [enabled, element]);
}