How to trigger the event when the page is scrolled to the designated location?

how to do this: the user scrolls down the page window, triggers an event when div is about to enter the view. Each div location of ps: is different, so you need to trigger flexibly.


get the position of the div you want to operate relative to the top, listen for scrolling events, and iterate through each div, you want to operate to see if the conditions are met
of course you can use the latest API, IntersectionObserver to do this

.
Menu