Navbar angepasst
This commit is contained in:
1 parent
ca61513fdd
commit
ff6cb12162
2 files changed
+12
-11
No files matched your search
@@ -11,15 +11,19 @@ export function useToggleBodyOverflow(locked: boolean, options: Options = {}) {
|
||||
|
||||
useEffect(() => {
|
||||
const root = document.documentElement;
|
||||
const body = document.body;
|
||||
|
||||
root.classList.toggle(className, locked);
|
||||
|
||||
const prevOverflow = document.body.style.overflow;
|
||||
document.body.style.overflow = locked ? "hidden" : "";
|
||||
if (locked) {
|
||||
root.classList.add(className);
|
||||
body.style.overflow = "hidden";
|
||||
} else {
|
||||
root.classList.remove(className);
|
||||
body.style.overflow = "";
|
||||
}
|
||||
|
||||
return () => {
|
||||
root.classList.remove(className);
|
||||
document.body.style.overflow = prevOverflow;
|
||||
body.style.overflow = "";
|
||||
};
|
||||
}, [locked, className]);
|
||||
}
|
||||
Reference in new issue
Block a user