From 97a75f1abcbd1c9001a7ff5b75713e3a913748cb Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 19 Oct 2016 22:50:22 +0300 Subject: Make Grid isWorkPending wait for scroll events to complete (#20417) Change-Id: I3cfdac539111ff2e88c7ff81e6d6b9a579160423 --- .../com/vaadin/client/widget/escalator/ScrollbarBundle.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/src/main/java/com/vaadin/client/widget/escalator/ScrollbarBundle.java b/client/src/main/java/com/vaadin/client/widget/escalator/ScrollbarBundle.java index c62c5f032f..2b615ebdb7 100644 --- a/client/src/main/java/com/vaadin/client/widget/escalator/ScrollbarBundle.java +++ b/client/src/main/java/com/vaadin/client/widget/escalator/ScrollbarBundle.java @@ -362,6 +362,7 @@ public abstract class ScrollbarBundle implements DeferredWorker { private HandlerRegistration scrollSizeTemporaryScrollHandler; private HandlerRegistration offsetSizeTemporaryScrollHandler; + private HandlerRegistration scrollInProgress; private ScrollbarBundle() { root.appendChild(scrollSizeElement); @@ -523,6 +524,16 @@ public abstract class ScrollbarBundle implements DeferredWorker { scrollPos = Math.max(0, Math.min(maxScrollPos, truncate(px))); if (!WidgetUtil.pixelValuesEqual(oldScrollPos, scrollPos)) { + if (scrollInProgress == null) { + // Only used for tracking that there is "workPending" + scrollInProgress = addScrollHandler(new ScrollHandler() { + @Override + public void onScroll(ScrollEvent event) { + scrollInProgress.removeHandler(); + scrollInProgress = null; + } + }); + } if (isInvisibleScrollbar) { invisibleScrollbarTemporaryResizer.show(); } @@ -911,6 +922,6 @@ public abstract class ScrollbarBundle implements DeferredWorker { // requestAnimationFrame - which is not automatically checked return scrollSizeTemporaryScrollHandler != null || offsetSizeTemporaryScrollHandler != null - || scrollEventFirer.isBeingFired; + || scrollInProgress != null || scrollEventFirer.isBeingFired; } } -- cgit v1.2.3