cubiq/SwipeView — pull request #18 by simonratner (2012-03-24 00:12:03+00:00)
Title: Don't flip direction to zero when mouse/touch is stationary.

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.