Recently, I created a modal that hides the scroll bar on the body to allow users to only scroll through the modal content.
The problem arises when I apply overflow-y:hidden
- the body scrolls to the top, but I actually want to preserve the page's position.
<body>
Long content
</body>
scrollY
is at 1000
<body style="overflow-y:hidden">
Long content
</body>
scrollY
goes to 0
I've considered saving the current scrollY
position and scrolling back once overflow-y
is removed. However, this solution doesn't give me the desired effect.
Does anyone have any other suggestions or a better solution?