As the title states, I now have a row of horizontally typed li's that can slide freely horizontally. When a certain li is within the current visible area, some of its styles will be changed. How should I write such an effect?
Hope all the experts can help answer this question. . . . . . .
Reference: http://runjs.cn/code/yq5arlrf
Why do you have to change the style in the visible area? Wouldn’t it be very troublesome to do so? It's better to add styles to everything. Anyway, what kind of style does it matter in non-areas? !
The upper purple rectangle pointed by mark 1 is the distance the content list has slid
The red area pointed by mark 2 is the visible area
The yellow point pointed by mark 3 is the distance between the object you want to operate and the top of the content list
When When 1+2-50=3, it means that the yellow point has entered the visible area 50px
The above is the idea. The following is the code in my project. This idea can achieve lazy loading
Mine is vertical, and horizontally you can use their left value as a basis for judgment. I hope it can give the questioner some ideas
Judge by the visible attribute of the element