Disabling page scroll during page load and using Lenis smooth scroll
I want to disable scrolling during page load and also have Lenis smooth scroll on my website. I have the code below to prevent scrolling during page load. The problem is that if I scroll during the page load, after the page load ends, the page jumps to the extent of the scroll. Does anyone know how can I solve this problem?
4 Replies
Try overflow hidden by default and then as its loaded remove it
i think you're already done if you move the first line inside the document ready function outside of the function. so it will immediately set the disable-scroll class on the body (before ready).
or you set the class .disable-scroll on the body yourself (in the html)
i don't see the css of that though,
something like this should prevent it
Thank you very much, Mark! Your solution worked great! The only issue is that even after I reload the page, and the page load does not play in the same session, the delay in the scroll continues to be present. Is there any way I can turn off the scroll delay after the fist load?
don't know where the loading comes in, but you can try using sessionstorage.
ref: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage