schreiben/src/lib/bodyScroll.ts
Cat /dev/Nulo dc773b14ff
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
cambiar forma de navegación mucho
2023-09-07 12:19:53 -03:00

25 lines
525 B
TypeScript

import type { Readable } from "svelte/store";
// weird way to stop scroll in the body
// when the store is mounted, scroll stops in the body
class BodyScroll implements Readable<boolean> {
num: number = 0;
refresh() {
if (this.num > 0) document.body.style.overflow = "hidden";
else document.body.style.overflow = "";
}
subscribe() {
this.num++;
this.refresh();
return () => {
this.num--;
this.refresh();
};
}
}
const bodyScroll = new BodyScroll();
export default bodyScroll;