Are you listening to some floating nav? You should first determine in what state you want to trigger this listener, such as a change in browser window size or something else, and then write your code in the corresponding event, such as resize, etc.
Either a timer or add an event listener. It depends on your needs. In short, it's impossible to just write a method and let it execute multiple times by itself, right?
Are you listening to some floating nav? You should first determine in what state you want to trigger this listener, such as a change in browser window size or something else, and then write your code in the corresponding event, such as resize, etc.
You should monitor scrolling, bind the scroll event to the element you want to monitor, and check the changes in real time
Add to the corresponding event to monitor
You need to add the corresponding scroll listening event to the floating object, and then do the judgment and processing in the method
Either add timer setInterval/setTimeout or add event function to achieve real-time monitoring
Either a timer or add an event listener. It depends on your needs. In short, it's impossible to just write a method and let it execute multiple times by itself, right?