PDA

View Full Version : Touch events causing slow vertical scrolling on ios mobile



johnn7Devlpr
Jun 11th, 2013, 05:15 PM
Hey All,

My question: Is there a way to preserve native ios mobile scrolling when binding touchevent handlers to a page wrapper?

I have written a little script that slides out next/previous panels when swiping left/right - on a pdp page (similar to what all recipes does on mobile) . Basically just have a script(hammer.js) that binds touchmove to the full width wrapper on the page and listens for a dragright or dragleft touch event. Got everything working fairly smoothly, however am now noticing that the native scrolling on ios mobile has become laggy- (lost its scroll momentum/velocity) and seems to wait until touchend to actually innitiated the vertical scroll. This is not a very good experince as the page is quite long with content. I'm tried everything I could find to fix but it seems that simply binding a touchmove event to the wrapper (even without any sort of handling) causes this same slow vertical scrolling of the page. IS there a way to preserve the native scroll functionality whilst still listening for swiperight/left touch events? Thanks for any help.

Logic Ali
Jun 11th, 2013, 05:31 PM
I would say limit the execution frequency of the touchmove handler.
Have the handler set a flag that is reset by say a 200 ms timeout. If the flag is set, the handler doesn't execute the rest of its code (including the statements that set the flag and timeout).