Scrolling past loading screen

I've implemented a loading screen while all the gifs in my website is loading but I've found that even while it is loading I am able to scroll past it since it is just covering one section. Is there anything I can do to disable scrolling while it is loading?
window.addEventListener('wheel', handleScroll);
window.addEventListener('wheel', handleScroll);
8 Replies
Chris Bolson
Chris Bolson3mo ago
You can probably do this by adding preventDefault to your window "scroll" event listener. However, how have you added the loaded screen? If you use position "fixed" it will remain in place over the contents even if the user scrolls.
justfrast
justfrast3mo ago
Thanks Chris, I will try to implement that and see how it goes. I'm still not sure where I'm going wrong here. I've tried position: fixed; but I am still able to scroll. Would you mind taking a look?
Chris Bolson
Chris Bolson3mo ago
I can now see from your code that you are scrolling horizontally. You need to define the left position of the loading element too. ie left: 0;
justfrast
justfrast3mo ago
I apologise for the sphagetti code. But I defined left position like you suggested and it still dosen't seem to work.
Chris Bolson
Chris Bolson3mo ago
sorry, you are right. I did have this working on a temporary fork that I created from your code but then I went and deleted it by mistake. let me see if I can get it working again....
justfrast
justfrast3mo ago
You're a legend, Chris
Chris Bolson
Chris Bolson3mo ago
hold on. I might not be able to work it out.... Try moving your loading element outside of the "main" tag - ie make it a direct child of the body.
justfrast
justfrast3mo ago
Told you, you're a legend I'll drop you a follow on twitter ❤️
Want results from more Discord servers?
Add your server