I’d like to pause my whole page’s code until a scroll action (I used the scrollTo function) is finished or just for a set amount of time (this is a backup option but would work too).
Context: I have a button that scrolls the page to the bottom, however, since I have quite a lot of viewport enter/leave code, the page will lag out super hard, since it’s trying to execute a bunch of code in a very short amount of time. (ironically I have this code in place to optimize the page’s performance, which it does pretty well, except for in this case, which is why I’m here) So what I want to have happen is that all other code is temporarily paused until the scroll is finished (or for a set amount of time).
I’ve looked at the setTimeout function, but I don’t think it can do what I need it to, since it only “pauses” the code inside of its brackets, which isn’t going to work in my case.
Here’s what I essentially want to do:
if(button press){
scroll page to bottom
delay (until scroll is finished/for a set amount of time) - this will cause the code to get “hung up” here for a set amount of time, which means no other code is executed
}
Thanks in advance for any help.