I assume you need more information regarding the structure?
I try to give you more detail.
So I have many filters that are displayed on the left side of my query on desktop devices. These filters should be accessible via popup on mobile devices.
At the moment I use a button that adds the class “.filter-visible” to the filter wrapper div and makes it visible that way. So everything works perfectly fine (partly because of your help a few hours ago
) the only thing that is missing is the prevention of scrolling.
I tried code like this:
const showDialog = () => {
const scrollY = document.documentElement.style.getPropertyValue("--scroll-y");
const body = document.body;
body.style.position = "fixed";
body.style.top = `-${scrollY}`;
};
const closeDialog = () => {
const body = document.body;
const scrollY = body.style.top;
body.style.position = "";
body.style.top = "";
window.scrollTo(0, parseInt(scrollY || "0") * -1);
};
window.addEventListener("scroll", () => {
document.documentElement.style.setProperty(
"--scroll-y",
`${window.scrollY}px`
);
});
In countless variations but there was always something that didn’t work very well (glitches).