How can I monitor scroll position while scrolling in Safari on iOS?

前端 未结 6 1127
梦毁少年i
梦毁少年i 2021-02-05 03:58

I currently use $(window).bind(\'scroll\', foo); to monitor $(window).scrollTop() and do stuff to create a parallax effect.

In all desktop brow

6条回答
  •  一整个雨季
    2021-02-05 04:33

    When I saw your question, I was planning to do a polyfill for this (if such does not exist?). Unfortunately I've had very little time.

    The idea is to have a setInterval, which is initiated ontouchstart, and it checks whether document.body.scrollTop has changed since last time, eg. for every 20 milliseconds. And if it is, then we manually dispatch the scroll event. Otherwise we clearInterval since apparently there's no more scrolling happening.

    This it would be in brief. If you got more time (than I do), then feel free to try with those guidelines.

    Edit: Now, reading further, the same idea is seems to be suggested on the other answer. Are you certain that intervals are stopped whilst scrolling on iPad?

提交回复
热议问题