且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检测滚动结束/结束

更新时间:2022-04-20 21:20:33

这个可能很有用。

// Setup isScrolling variable
var isScrolling;

// Listen for scroll events
window.addEventListener('scroll', function ( event ) {

    // Clear our timeout throughout the scroll
    window.clearTimeout( isScrolling );

    // Set a timeout to run after scrolling ends
    isScrolling = setTimeout(function() {

        // Run the callback
        console.log( 'Scrolling has stopped.' );

    }, 66);

}, false);