javascript - How does JS dynamically load images determine whether the image is on the screen?
世界只因有你
世界只因有你 2017-05-19 10:20:40
0
2
462

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?

世界只因有你
世界只因有你

reply all(2)
阿神

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

小葫芦

Calculate the distance from the image to the head of the page, and then detect the scrolling distance of the scroll bar

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!