Scroll event firing too many times. I only want it to fire a maximum of, say, once per second

后端 未结 8 794
再見小時候
再見小時候 2020-11-27 12:24

I have a page with \"infinite scroll\". It calculates the difference between the end of the page and the current page and loads more content if this difference is small enou

8条回答
  •  生来不讨喜
    2020-11-27 13:01

    Check out the Underscore.js library's "throttle" method.

    http://underscorejs.org/#throttle

    The example it gives is exactly what you're asking about - limiting how often you have to handle scroll events.

提交回复
热议问题