summaryrefslogtreecommitdiffstats
path: root/client/src/main/java
diff options
context:
space:
mode:
authorTatu Lund <tatu@vaadin.com>2020-02-27 13:02:16 +0200
committerGitHub <noreply@github.com>2020-02-27 13:02:16 +0200
commit3df3420f9e3952f8a32e3d9ccbf9120eda29b75e (patch)
tree28ff63d652904a8383011b0d4e96e037968890a1 /client/src/main/java
parent684c23af96e06dcd0c735f47b0f7e5ae1c555fdd (diff)
downloadvaadin-framework-3df3420f9e3952f8a32e3d9ccbf9120eda29b75e.tar.gz
vaadin-framework-3df3420f9e3952f8a32e3d9ccbf9120eda29b75e.zip
Rewrote debouncing of onResize (#11899)
* Rewrote debouncing of onResize Fixes https://github.com/vaadin/framework/issues/11892 * Fixing typo in variable name
Diffstat (limited to 'client/src/main/java')
-rwxr-xr-xclient/src/main/java/com/vaadin/client/widgets/Grid.java48
1 files changed, 33 insertions, 15 deletions
diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java
index cd7399fba4..302ccb71b0 100755
--- a/client/src/main/java/com/vaadin/client/widgets/Grid.java
+++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java
@@ -4366,6 +4366,9 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
private boolean refreshBodyRequested = false;
+ private boolean resizeRequested = false;
+ private boolean resizeRefreshScheduled = false;
+
private DragAndDropHandler.DragAndDropCallback headerCellDndCallback = new DragAndDropCallback() {
private final AutoScrollerCallback autoScrollerCallback = new AutoScrollerCallback() {
@@ -9264,23 +9267,38 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
/*
* Delay calculation to be deferred so Escalator can do it's magic.
*/
- Scheduler.get().scheduleFinally(() -> {
- if (escalator
- .getInnerWidth() != autoColumnWidthsRecalculator.lastCalculatedInnerWidth) {
- recalculateColumnWidths();
- }
+ resizeRequested = true;
+ if (!resizeRefreshScheduled) {
+ resizeRefreshScheduled = true;
+ Scheduler.get().scheduleFixedDelay(() -> {
+ if (!resizeRequested) {
+ doRefreshOnResize();
+ resizeRefreshScheduled = false;
+ return false;
+ } else {
+ resizeRequested = false;
+ return true;
+ }
+ }, 50);
+ }
+ }
+
+ private void doRefreshOnResize() {
+ if (escalator
+ .getInnerWidth() != autoColumnWidthsRecalculator.lastCalculatedInnerWidth) {
+ recalculateColumnWidths();
+ }
- // Vertical resizing could make editor positioning invalid so it
- // needs to be recalculated on resize
- if (isEditorActive()) {
- editor.updateVerticalScrollPosition();
- }
+ // Vertical resizing could make editor positioning invalid so it
+ // needs to be recalculated on resize
+ if (isEditorActive()) {
+ editor.updateVerticalScrollPosition();
+ }
- // if there is a resize, we need to refresh the body to avoid an
- // off-by-one error which occurs when the user scrolls all the
- // way to the bottom.
- refreshBody();
- });
+ // if there is a resize, we need to refresh the body to avoid an
+ // off-by-one error which occurs when the user scrolls all the
+ // way to the bottom.
+ refreshBody();
}
private double getEscalatorInnerHeight() {