admin管理员组

文章数量:1326461

I've been searching around to find out what events are triggered when you scroll on an iPad on webpages.

There is this source: .html

Which indicates the following are fired:

ontouchstart="touchStart(event);"

ontouchmove="touchMove(event);"

ontouchend="touchEnd(event);"

ontouchcancel="touchCancel(event);"

The problem is how to deal with the momentum scrolling when a user flicks to scroll. I think the onsroll event only fires when the scrolling has finished.

Does anyone know if any events are fired when the momentum scrolling is occuring so you can do checks as the page is scrolling under this 'momentum'?

cheers

I've been searching around to find out what events are triggered when you scroll on an iPad on webpages.

There is this source: https://developer.apple./library/safari/#documentation/appleapplications/reference/SafariWebContent/HandlingEvents/HandlingEvents.html

Which indicates the following are fired:

ontouchstart="touchStart(event);"

ontouchmove="touchMove(event);"

ontouchend="touchEnd(event);"

ontouchcancel="touchCancel(event);"

The problem is how to deal with the momentum scrolling when a user flicks to scroll. I think the onsroll event only fires when the scrolling has finished.

Does anyone know if any events are fired when the momentum scrolling is occuring so you can do checks as the page is scrolling under this 'momentum'?

cheers

Share Improve this question asked Jan 24, 2013 at 12:19 SamSam 2,4372 gold badges23 silver badges26 bronze badges 3
  • 3 Have you checked if the scroll event on the window fires during momentum scrolling? Example: $(window).scroll(function(){ console.log('scrolling') }); – Klaas Leussink Commented Jan 24, 2013 at 13:01
  • It's currently not possible to open a dev console on an iPad. However, from my limited experience, it does not fire when the window is momentum scrolling. – d_rail Commented Oct 22, 2015 at 21:11
  • You can use Safari Web Inspector to debug Safari on iOS. This capability has been around for a while. – bvpb Commented Nov 1, 2017 at 1:12
Add a ment  | 

2 Answers 2

Reset to default 2

The problem is that on an iPad the scroll does not continuously fires. It only fires once when you stop scrolling. As far as I know you cannot solve this.

On the desktop this is not the case. Here during scrolling the browser continuously fires the scroll event.

I noticed this behaviour when I was working on a parallax scrolling website. On iOS everything stuttered because the scroll event was only firing once.

However it is possible to simulate as described here: javascript scroll event for iPhone/iPad?

Use this code

document.addEventListener('touchmove', function(e) {console.log('touch move', $(window).scrollTop())}, true);

it fires even during touches.

本文标签: javascriptiPad scrollingwhat events fire during scrollingStack Overflow