diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2018-03-20 14:13:27 +0200 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2018-03-20 14:13:27 +0200 |
commit | 31eba3b64bdeab39d5fcf666535a1441e2ff6b1b (patch) | |
tree | d331e6d731a929e5e63cef0185c503b82884cc65 /client | |
parent | 9cf87e1423b1c4e0358112615433bbbf2bc47da3 (diff) | |
download | vaadin-framework-31eba3b64bdeab39d5fcf666535a1441e2ff6b1b.tar.gz vaadin-framework-31eba3b64bdeab39d5fcf666535a1441e2ff6b1b.zip |
Scroll the parent if Grid has already scrolled to the end (#10700)
Fixes #9477
Diffstat (limited to 'client')
-rw-r--r-- | client/src/main/java/com/vaadin/client/widgets/Escalator.java | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/client/src/main/java/com/vaadin/client/widgets/Escalator.java b/client/src/main/java/com/vaadin/client/widgets/Escalator.java index da488e1153..f2b553007b 100644 --- a/client/src/main/java/com/vaadin/client/widgets/Escalator.java +++ b/client/src/main/java/com/vaadin/client/widgets/Escalator.java @@ -568,7 +568,6 @@ public class Escalator extends Widget yMov.moveTouch(event); xMov.validate(yMov); yMov.validate(xMov); - event.getNativeEvent().preventDefault(); moveScrollFromEvent(escalator, xMov.delta, yMov.delta, event.getNativeEvent()); } @@ -620,21 +619,36 @@ public class Escalator extends Widget final double deltaX, final double deltaY, final NativeEvent event) { + boolean scrollPosXChanged = false; + boolean scrollPosYChanged = false; + if (!Double.isNaN(deltaX)) { + double oldScrollPosX = escalator.horizontalScrollbar + .getScrollPos(); escalator.horizontalScrollbar.setScrollPosByDelta(deltaX); + if (oldScrollPosX != escalator.horizontalScrollbar + .getScrollPos()) { + scrollPosXChanged = true; + } } if (!Double.isNaN(deltaY)) { + double oldScrollPosY = escalator.verticalScrollbar + .getScrollPos(); escalator.verticalScrollbar.setScrollPosByDelta(deltaY); + if (oldScrollPosY != escalator.verticalScrollbar + .getScrollPos()) { + scrollPosYChanged = true; + } } /* - * TODO: only prevent if not scrolled to end/bottom. Or no? UX team - * needs to decide. + * Only prevent if internal scrolling happened. If there's no more + * room to scroll internally, allow the event to pass further. */ - final boolean warrantedYScroll = deltaY != 0 + final boolean warrantedYScroll = deltaY != 0 && scrollPosYChanged && escalator.verticalScrollbar.showsScrollHandle(); - final boolean warrantedXScroll = deltaX != 0 + final boolean warrantedXScroll = deltaX != 0 && scrollPosXChanged && escalator.horizontalScrollbar.showsScrollHandle(); if (warrantedYScroll || warrantedXScroll) { event.preventDefault(); |