Permalink
Browse files

Correct slideshow jerkiness and failures for Android 4.0

  • Loading branch information...
1 parent 720e72c commit e89072ab6f4d5a10cee47db196a561f3ddd37348 Roman Rudenko committed Aug 14, 2012
Showing with 15 additions and 2 deletions.
  1. +15 −2 vendor/slide.js
View
@@ -139,11 +139,24 @@
dx = xy.x - cXY.x;
dy = xy.y - cXY.y;
+ /* Android 3.x and 4.0 (but not 4.1) sends only one touchmove event to the browser.
+ * If that touchmove is NOT cancelled, browser stops sending subsequent move events.
+ * It is hard to explain why this happens... perhaps they see cancelling as sign of
+ * "I will handle it" and non-cancelling as "just use native scrolling behavior", and
+ * would like to speed up scrolling by not having to run event processing for every
+ * user finger twitch. http://code.google.com/p/android/issues/detail?id=19827
+ * To us, the consequence is that we can't wait with cancelling the event. We must
+ * make a decision on whether to lock scrolling to slideshow or let all document
+ * be affected upon FIRST touchmove. If we fail to take over control of touchmove
+ * event with e.preventDefault(), we will not receive any more touchmoves.
+ */
+ if (abs(dx) > abs(dy)) {
+ e.preventDefault();
+ }
+
if (dragThresholdMet || abs(dx) > abs(dy) && (abs(dx) > opts.minDragDelta)) {
dragThresholdMet = true;
- e.preventDefault();
-
// Slow movement when out of bounds.
if ((index == 0 && dx < 0) || ((index == length - 1) && dx > 0)) dx *= 0.4;

0 comments on commit e89072a

Please sign in to comment.