Fixes #2328 and #3823: added scrollTop tracking to swipe event #4478
Conversation
…g touch scrolls with swipes.
could it be that this is not in the master branch? I can't seem to find that code when I compile the master... edit: never mind. I just cloned your repository. |
@SamDecrock - Yes, that is correct. It is an open pull request that needs to be reviewed and tested. After that, if we decide to apply the suggested changes, it will be merged into master branch. |
So I didn't really understand where I'm supose to add the code above... |
@BorisDutkin - Your question is more something for the forum (https://forum.jquery.com/jquery-mobile) |
Is there any timeline on getting this fix approved and incorporated into master? |
@@ -170,7 +172,8 @@ $.event.special.swipe = { | |||
if ( start && stop ) { | |||
if ( stop.time - start.time < $.event.special.swipe.durationThreshold && | |||
Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.horizontalDistanceThreshold && | |||
Math.abs( start.coords[ 1 ] - stop.coords[ 1 ] ) < $.event.special.swipe.verticalDistanceThreshold ) { | |||
( Math.abs( start.coords[ 1 ] - stop.coords[ 1 ] ) + Math.abs( start.offset - stop.offset )) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't you just doubling the change in the Y position by adding the coordinate difference to the scrollTop difference? Maybe I'm missing something here about the values that are reported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm that it works with his patch and that it's NOT working without. Scrolling up (or down) diagonally makes jQuery mobile believe that there was as slide.
That's because, when you scroll up, the origin of the coordinate system scrolls up too so there is actually no vertical movement going on...
Therefore you have to add the scrollTop() difference to the vertical movement. scrollTop() not being part of the same coordinate system as the data.pageY.
We can also confirm the following fix is also working for us and it no longer swipes in case of diagonal scroll. |
Another issue that came up with this patch is that |
Not sure you get this message since you are no longer an active Github user, but thanks for your work on this! Like @johnbender mentioned the change you suggested has downsides so we are looking for another solution, so I am closing this PR. Also note that the problem only seems to occur on iOS, not on Android. See #2328 (comment) Thanks! |
... to avoid having it triggered by touch-drag scrolls.
Passed unit tests, and I tested swipe, swipeleft and swiperight on iPad and iPhone.