javascript - js function code, about scrolling loading data
伊谢尔伦
伊谢尔伦 2017-07-05 10:45:13
0
3
759


Can you explain the meaning of this code in detail?
Scroll initialization is true

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(3)
大家讲道理

The function you gave should be a method in a module, and it needs to be viewed together with other attributes or methods in this module.
Just look at this method. This method should exist as a callback function for an event (probably a scroll event). When this event is triggered, this method is executed. There are two situations
(1) this.scroll is true and enters the specific logic

totalheight与body...作比较 实际上是页面已显式高度,和页面内容实际高度做比较
简单点说就是滚动条是否快到底部了,如果满足条件进入下面的逻辑,做这么几件事
    已显式页面+1,this.scroll置为false,进行判断,已显示页面是否小于5,如果是加载下面的页面

(2) this.scroll is false and the above logic is not executed
// This code lacks the logic to set this.scroll back to true. I think it is in getAjaxData. The advantage of doing this is that when loading new When the page is scrolling, the listening event is temporarily invalid and will not cause the same request to be issued repeatedly

刘奇

Just scroll to the bottom and there is still 200 distance, start loading the data once, wait for the data rendering to complete, and resume. Recycle

仅有的幸福

I guess you want to ask why this initial flag is set?
It should be to prevent multiple ajax requests for one scroll.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template