Files
Magent/frontend/app/lib/scrollLock.ts
T
Assclaw f852e7c941
Magent CI/CD / verify (push) Failing after 9m34s
Magent CI/CD / deploy-beta (push) Skipped
chore: standardize security and quality foundations
2026-09-17 20:03:47 +12:00

16 lines
346 B
TypeScript

let locks = 0;
let previous = "";
export function lockBodyScroll() {
if (locks++ === 0) {
previous = document.body.style.overflow;
document.body.style.overflow = "hidden";
}
let released = false;
return () => {
if (released) return;
released = true;
if (--locks === 0) document.body.style.overflow = previous;
};
}