Detect if element has stopped momentum scrolling?

前端 未结 3 1366
有刺的猬
有刺的猬 2021-01-12 04:05

Is it possibile to detect if an element has stopped scrolling in Mobile Safari via Javascript?

I have an element that has momentum scrolling by using -webkit-o

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-12 04:27

    In my case this worked perfectly:

    var timer;
    $(scrollWrapper).on('scroll',function(e){
        if(timer){
            clearTimeout(timer);
        }
        timer = setTimeout(function(){
           $(this).trigger('scrollFinished');
        }, 55)
    })
    
    
    
     $(scrollWrapper).on('scrollFinished',function(){
             // will be called when momentum scroll is finished
       })
    

    Publish 'scrollfinished' event when scroll has stopped.

提交回复
热议问题