Scroll down with the mouse and load the image when the target area appears on the screen. So how to determine whether the target area appears on the screen?
阿神2017-05-19 10:22:40
Use the getBoundingClientRect()
method of the image to return the left, top, right and bottom relative to the viewport
to determine whether it is within the viewport.
Refer to getBoundingClientRect
高洛峰2017-05-19 10:22:40
Calculate the distance from the image to the head of the page, and then detect the scrolling distance of the scroll bar