aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorHenrik Paul <henrik@vaadin.com>2014-03-17 16:50:28 +0200
committerLeif Åstrand <leif@vaadin.com>2014-03-17 19:25:43 +0000
commit796063f898ef34bbbe457164976ae96c802c1bc7 (patch)
treea661344884be7757f6a0db46a4f7c96ed4eff7bb /client
parenta7604cfaa21e0c5d8a075d2d563a61038d96f295 (diff)
downloadvaadin-framework-796063f898ef34bbbe457164976ae96c802c1bc7.tar.gz
vaadin-framework-796063f898ef34bbbe457164976ae96c802c1bc7.zip
Fixes Escalator flick scroll regression (#13334)
Change-Id: Icc263c10ec1fb0542f544ddbc2bb705e8968aa40
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ui/grid/Escalator.java32
1 files changed, 22 insertions, 10 deletions
diff --git a/client/src/com/vaadin/client/ui/grid/Escalator.java b/client/src/com/vaadin/client/ui/grid/Escalator.java
index e02ca52e6b..6112d6b139 100644
--- a/client/src/com/vaadin/client/ui/grid/Escalator.java
+++ b/client/src/com/vaadin/client/ui/grid/Escalator.java
@@ -322,7 +322,7 @@ public class Escalator extends Widget {
deltaY = y - lastY;
lastX = x;
lastY = y;
- lastTime = timestamp;
+ lastTime = Duration.currentTimeMillis();
// snap the scroll to the major axes, at first.
if (snappedScrollEnabled) {
@@ -416,7 +416,6 @@ public class Escalator extends Widget {
animationHandle = AnimationScheduler.get()
.requestAnimationFrame(mover, escalator.bodyElem);
event.getNativeEvent().preventDefault();
- mover.execute(Duration.currentTimeMillis());
}
public void touchEnd(@SuppressWarnings("unused")
@@ -472,6 +471,8 @@ public class Escalator extends Widget {
private double yFric;
private boolean cancelled = false;
+ private int lastLeft;
+ private int lastTop;
/**
* Creates a new animation callback to handle touch-scrolling flick with
@@ -491,7 +492,9 @@ public class Escalator extends Widget {
MAX_SPEED), -MAX_SPEED);
velY = Math.max(Math.min(deltaY / (currentTimeMillis - lastTime),
MAX_SPEED), -MAX_SPEED);
- prevTime = lastTime;
+
+ lastLeft = horizontalScrollbar.getScrollPos();
+ lastTop = verticalScrollbar.getScrollPos();
/*
* If we're scrolling mainly in one of the four major directions,
@@ -520,25 +523,34 @@ public class Escalator extends Widget {
return;
}
- final int lastLeft = tBodyScrollLeft;
- final int lastTop = tBodyScrollTop;
+ if (prevTime == 0) {
+ prevTime = timestamp;
+ AnimationScheduler.get().requestAnimationFrame(this);
+ return;
+ }
+
+ int currentLeft = horizontalScrollbar.getScrollPos();
+ int currentTop = verticalScrollbar.getScrollPos();
final double timeDiff = timestamp - prevTime;
- setScrollLeft((int) (tBodyScrollLeft - velX * timeDiff));
+ double left = currentLeft - velX * timeDiff;
+ setScrollLeft((int) left);
velX -= xFric * timeDiff;
- setScrollTop(tBodyScrollTop - velY * timeDiff);
+ double top = currentTop - velY * timeDiff;
+ setScrollTop(top);
velY -= yFric * timeDiff;
- cancelBecauseOfEdgeOrCornerMaybe(lastLeft, lastTop);
+ cancelBecauseOfEdgeOrCornerMaybe();
prevTime = timestamp;
millisLeft -= timeDiff;
+ lastLeft = currentLeft;
+ lastTop = currentTop;
AnimationScheduler.get().requestAnimationFrame(this);
}
- private void cancelBecauseOfEdgeOrCornerMaybe(final int lastLeft,
- final int lastTop) {
+ private void cancelBecauseOfEdgeOrCornerMaybe() {
if (lastLeft == horizontalScrollbar.getScrollPos()
&& lastTop == verticalScrollbar.getScrollPos()) {
cancel();