Detect if element has stopped momentum scrolling?

前端 未结 3 1365
有刺的猬
有刺的猬 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:25

    You could also add a function that recursivly calls itself until the scrolling has stopped within the element and then call futher function from there.

    isScrolling() {
      var scrollStart = .scrollTop;
      setTimeout(function() {
        var scrollPos = .scrollTop;
        if (scrollStart !== scrollPos) {
          this.isScrolling()
        } else {
          // Scrolling has stopped
        }
      }, 100)
    }
    

提交回复
热议问题