How to do infinite scrolling with javascript only without jquery

前端 未结 6 1023
日久生厌
日久生厌 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条回答
  •  猫巷女王i
    2021-02-01 11:02

    For achieving that behaviour you don't need JQuery or a JQuery plugin. You just need Pure Css OR Css + Javascript, it depends on the % you want to support

    but... DON'T use onScroll: you can do all that just with Vanilla Javascript and the IntersectionObserver API.

    All you need to do is place elements and listen for when they become available in the screen. You can accomplish that with a few javascript & html lines and it's much more performant than listening for scroll events in the browsers

    I recently put together an article check it here about this

提交回复
热议问题