I have a scrollable feed on my site for user posted content. There is a button that triggers a popup/overlay that should pause the scrolling. I found a way to pause on a pc browser, but I am unable to pause the scrolling on my iPhone causing a weird visual glitch that shows the content behind the popup/overlay still scrolling as if it were the content ontop.
I have tried changing position to fixed, but this will not save the location of the user before they clicked the popup/overlay button. Instead it will return the user to the top of the page. I want to freeze the user however far down the screen they were so when they close the popup they will be able to scroll again.
<script>
function NewPostPopup() {
const noscroll = document.getElementById("newpostpopup").classList.toggle("active");
if (noscroll) {
document.body.style.overflow = "hidden";
}
else {
document.body.style.overflow = "auto";
}
}
</script>