From ed96018198db94991b828124ff73a86a250160cb Mon Sep 17 00:00:00 2001 From: Henrik Paul Date: Mon, 28 Apr 2014 10:48:56 +0300 Subject: [PATCH] Fixes Grid flick scroll (#13334) Change-Id: I92bafcafee27c2401b8e85261d2ac14b76894ede --- .../com/vaadin/client/ui/grid/Escalator.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/client/src/com/vaadin/client/ui/grid/Escalator.java b/client/src/com/vaadin/client/ui/grid/Escalator.java index 5d310d4d1a..8d8d8ed016 100644 --- a/client/src/com/vaadin/client/ui/grid/Escalator.java +++ b/client/src/com/vaadin/client/ui/grid/Escalator.java @@ -313,7 +313,15 @@ public class Escalator extends Widget { private CustomTouchEvent latestTouchMoveEvent; private AnimationCallback mover = new AnimationCallback() { @Override - public void execute(double timestamp) { + public void execute(double doNotUseThisTimestamp) { + /* + * We can't use the timestamp parameter here, since it is + * not in any predetermined format; TouchEnd does not + * provide a compatible timestamp, and we need to be able to + * get a comparable timestamp to determine whether to + * trigger a flick scroll or not. + */ + if (touches != 1) { return; } @@ -324,6 +332,11 @@ public class Escalator extends Widget { deltaY = y - lastY; lastX = x; lastY = y; + + /* + * Instead of using the provided arbitrary timestamp, let's + * use a known-format and reproducible timestamp. + */ lastTime = Duration.currentTimeMillis(); // snap the scroll to the major axes, at first. @@ -519,12 +532,20 @@ public class Escalator extends Widget { } @Override - public void execute(final double timestamp) { + public void execute(final double doNotUseThisTimestamp) { + /* + * We cannot use the timestamp provided to this method since it is + * of a format that cannot be determined at will. Therefore, we need + * a timestamp format that we can handle, so our calculations are + * correct. + */ + if (millisLeft <= 0 || cancelled) { scroller.currentFlickScroller = null; return; } + final double timestamp = Duration.currentTimeMillis(); if (prevTime == 0) { prevTime = timestamp; AnimationScheduler.get().requestAnimationFrame(this); -- 2.39.5