How to do infinite scrolling with javascript only without jquery

前端 未结 6 1022
日久生厌
日久生厌 2021-02-01 10:13

I wish to implement infinite scrolling with javascript and without jquery.

I am new to javascript.

After searching all over the net, I have this code.

         


        
6条回答
  •  一个人的身影
    2021-02-01 11:06

    What about replacing this line of code:

    if (getDocHeight() == getScrollXY()[1] + window.innerHeight)
    

    with the following:

    if (getDocHeight() - 20 <= getScrollXY()[1] + window.innerHeight) 
    

    Where 20 is the number how much pxs from bottom you want the trigger to execute.

    Fiddle

提交回复
热议问题