SwipeView icon indicating copy to clipboard operation
SwipeView copied to clipboard

Don't flip direction to zero when mouse/touch is stationary.

Open simonratner opened this issue 13 years ago • 4 comments

Mousemove/touchmove events keep on firing (once per second or so) even if the pointer position is not changing. This resulted in the direction being reset to zero if one holds the mouse/finger stationary for a while. Since __checkPosition only has a two-way branch, a zero direction always fell into the second branch, resulting in sporadic broken behaviour for backwards (right, positive direction) swipes while forward (left, negative direction) swipes worked perfectly.

Specifically:

  1. Swipe backwards (right) past the snap threshold and release immediately, page changes and everything is fine.
  2. Swipe backwards (right), hold the mouse steady for a few seconds, then release. Page snaps back to its previous position (in fact, it is being advanced in the wrong direction!), page index is incremented in the wrong direction, and is now out of sync with the displayed page. Future swipes keep the page index off by one.

This is the minimal fix, it would probably make sense to also add a branch in __checkPosition to do the right thing when directionX == 0, since that could still happen when snapThreshold == 0.

simonratner avatar Mar 24 '12 00:03 simonratner

Sorry, this isn't a complete fix. I'll send a proper fix in a bit.

simonratner avatar Mar 25 '12 09:03 simonratner

would you integrate this into the latest version so your name appears between the collaborators? Thanks and sorry for not merging this earlier... I really haven't seen this pull request before, sorry again!

cubiq avatar Aug 25 '12 16:08 cubiq

Doesn't look like f1e1904 ever got merged.

stephanfowler avatar Sep 29 '12 22:09 stephanfowler

@cubic Here's the patch by @simonratner applied to the latest repo: #39

kpuputti avatar Oct 17 '12 14:10 kpuputti