summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorManolo Carrasco <manolo@vaadin.com>2015-09-16 00:50:50 +0200
committerVaadin Code Review <review@vaadin.com>2015-09-16 11:23:15 +0000
commit07a3c3c07ccff25c8afeb623b9fd3ffee6d02361 (patch)
tree0d7adc614e42395f7569d96ae53c6963635e6322 /client
parenta11bd16d7aa525b2ab561337e3b2ffb2ad77604b (diff)
downloadvaadin-framework-07a3c3c07ccff25c8afeb623b9fd3ffee6d02361.tar.gz
vaadin-framework-07a3c3c07ccff25c8afeb623b9fd3ffee6d02361.zip
Grid: allow zooming in touch devices.
- Since grid was not cancelling scrolling when multiple touches, zooming was not working, this patch fixes "zoom trap". - Prevent default when moving the scroll in touch devices to avoid parent scrolling Change-Id: I47856ef20bc835bb2b310b45f6d2749e950e8e7a
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/widgets/Escalator.java41
1 files changed, 23 insertions, 18 deletions
diff --git a/client/src/com/vaadin/client/widgets/Escalator.java b/client/src/com/vaadin/client/widgets/Escalator.java
index 43eeb7a0ce..881ac7d7ed 100644
--- a/client/src/com/vaadin/client/widgets/Escalator.java
+++ b/client/src/com/vaadin/client/widgets/Escalator.java
@@ -426,12 +426,8 @@ public class Escalator extends Widget implements RequiresResize,
position = scroll.getScrollPos();
// Compute offset, and adjust it with an easing curve so as movement is smoother.
offset = F_VEL * velocity * acceleration * easingInOutCos(velocity, MAX_VEL);
- // Check that offset does not over-scroll
- double minOff = -scroll.getScrollPos();
- double maxOff = scroll.getScrollSize() - scroll.getOffsetSize() + minOff;
- offset = Math.min(Math.max(offset, minOff), maxOff);
// Enable or disable inertia movement in this axis
- run = validSpeed(velocity) && minOff < 0 && maxOff > 0;
+ run = validSpeed(velocity);
if (run) {
event.getNativeEvent().preventDefault();
}
@@ -493,26 +489,35 @@ public class Escalator extends Widget implements RequiresResize,
xMov.startTouch(event);
yMov.startTouch(event);
touching = true;
+ } else {
+ touching = false;
+ animation.cancel();
+ acceleration = 1;
}
}
public void touchMove(final CustomTouchEvent event) {
- xMov.moveTouch(event);
- yMov.moveTouch(event);
- xMov.validate(yMov);
- yMov.validate(xMov);
- moveScrollFromEvent(escalator, xMov.delta, yMov.delta, event.getNativeEvent());
+ if (touching) {
+ xMov.moveTouch(event);
+ yMov.moveTouch(event);
+ xMov.validate(yMov);
+ yMov.validate(xMov);
+ event.getNativeEvent().preventDefault();
+ moveScrollFromEvent(escalator, xMov.delta, yMov.delta, event.getNativeEvent());
+ }
}
public void touchEnd(final CustomTouchEvent event) {
- xMov.endTouch(event);
- yMov.endTouch(event);
- xMov.validate(yMov);
- yMov.validate(xMov);
- // Adjust duration so as longer movements take more duration
- boolean vert = !xMov.run || yMov.run && Math.abs(yMov.offset) > Math.abs(xMov.offset);
- double delta = Math.abs((vert ? yMov : xMov).offset);
- animation.run((int)(3 * DURATION * easingOutExp(delta)));
+ if (touching) {
+ xMov.endTouch(event);
+ yMov.endTouch(event);
+ xMov.validate(yMov);
+ yMov.validate(xMov);
+ // Adjust duration so as longer movements take more duration
+ boolean vert = !xMov.run || yMov.run && Math.abs(yMov.offset) > Math.abs(xMov.offset);
+ double delta = Math.abs((vert ? yMov : xMov).offset);
+ animation.run((int)(3 * DURATION * easingOutExp(delta)));
+ }
}
private double easingInOutCos(double val, double max) {