]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix Grid jerky resize in vertical split panel (#18370)
authorTeemu Suo-Anttila <teemusa@vaadin.com>
Mon, 29 Jun 2015 08:08:20 +0000 (11:08 +0300)
committerTeemu Suo-Anttila <teemusa@vaadin.com>
Wed, 8 Jul 2015 07:59:45 +0000 (10:59 +0300)
This patch makes SplitPanels overflow hidden when there is a full
height/width widget in the container.

Change-Id: I0e4e49f373bf9a4735ccfb828e2813932f31d0c1

client/src/com/vaadin/client/ui/VAbstractSplitPanel.java
client/src/com/vaadin/client/ui/VSplitPanelHorizontal.java
client/src/com/vaadin/client/ui/VSplitPanelVertical.java

index 5565daf19b38261d2c1f664797f8dd85ce637d7e..e849ee79f37e6daef3535df992c4d64d42491d2c 100644 (file)
@@ -49,7 +49,7 @@ import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler;
 import com.vaadin.client.ui.VAbstractSplitPanel.SplitterMoveHandler.SplitterMoveEvent;
 import com.vaadin.shared.ui.Orientation;
 
-public class VAbstractSplitPanel extends ComplexPanel {
+public abstract class VAbstractSplitPanel extends ComplexPanel {
 
     private boolean enabled = false;
 
@@ -571,6 +571,7 @@ public class VAbstractSplitPanel extends ComplexPanel {
             }
             break;
         case Event.ONCLICK:
+            stopResize();
             resizing = false;
             break;
         }
@@ -590,6 +591,7 @@ public class VAbstractSplitPanel extends ComplexPanel {
         }
         final Element trg = event.getEventTarget().cast();
         if (trg == splitter || trg == DOM.getChild(splitter, 0)) {
+            startResize();
             resizing = true;
             DOM.setCapture(getElement());
             origX = DOM.getElementPropertyInt(splitter, "offsetLeft");
@@ -601,6 +603,40 @@ public class VAbstractSplitPanel extends ComplexPanel {
         }
     }
 
+    /**
+     * Called when starting drag resize
+     * 
+     * @since
+     */
+    abstract protected void startResize();
+
+    /**
+     * Called when stopping drag resize
+     * 
+     * @since
+     */
+    abstract protected void stopResize();
+
+    /**
+     * Gets the first container
+     * 
+     * @since
+     * @return the firstContainer
+     */
+    protected Element getFirstContainer() {
+        return firstContainer;
+    }
+
+    /**
+     * Gets the second container
+     * 
+     * @since
+     * @return the secondContainer
+     */
+    protected Element getSecondContainer() {
+        return secondContainer;
+    }
+
     public void onMouseMove(Event event) {
         switch (orientation) {
         case HORIZONTAL:
@@ -685,6 +721,7 @@ public class VAbstractSplitPanel extends ComplexPanel {
     public void onMouseUp(Event event) {
         DOM.releaseCapture(getElement());
         hideDraggingCurtain();
+        stopResize();
         resizing = false;
         if (!WidgetUtil.isTouchEvent(event)) {
             onMouseMove(event);
index c6919d456bff7d01553ef03c0a34ff3cc8a19e61..5d918153b3931b4c8beb9cd19c3e7b2fc9108b33 100644 (file)
@@ -16,6 +16,8 @@
 
 package com.vaadin.client.ui;
 
+import com.google.gwt.dom.client.Style.Overflow;
+import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.shared.ui.Orientation;
 
 public class VSplitPanelHorizontal extends VAbstractSplitPanel {
@@ -23,4 +25,25 @@ public class VSplitPanelHorizontal extends VAbstractSplitPanel {
     public VSplitPanelHorizontal() {
         super(Orientation.HORIZONTAL);
     }
+
+    @Override
+    protected void startResize() {
+        if (isWidgetFullWidth(getFirstWidget())) {
+            getFirstContainer().getStyle().setOverflow(Overflow.HIDDEN);
+        }
+
+        if (isWidgetFullWidth(getSecondWidget())) {
+            getSecondContainer().getStyle().setOverflow(Overflow.HIDDEN);
+        }
+    }
+
+    @Override
+    protected void stopResize() {
+        getFirstContainer().getStyle().clearOverflow();
+        getSecondContainer().getStyle().clearOverflow();
+    }
+
+    private boolean isWidgetFullWidth(Widget w) {
+        return w.getElement().getStyle().getWidth().equals("100%");
+    }
 }
index b008e5d3f08b11d33c9c7c4ed97c2ac5fd607b79..376b18e171a8463819ea5144d70c3aa67e8f46f8 100644 (file)
@@ -16,6 +16,8 @@
 
 package com.vaadin.client.ui;
 
+import com.google.gwt.dom.client.Style.Overflow;
+import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.shared.ui.Orientation;
 
 public class VSplitPanelVertical extends VAbstractSplitPanel {
@@ -23,4 +25,25 @@ public class VSplitPanelVertical extends VAbstractSplitPanel {
     public VSplitPanelVertical() {
         super(Orientation.VERTICAL);
     }
+
+    @Override
+    protected void startResize() {
+        if (isWidgetFullHeight(getFirstWidget())) {
+            getFirstContainer().getStyle().setOverflow(Overflow.HIDDEN);
+        }
+
+        if (isWidgetFullHeight(getSecondWidget())) {
+            getSecondContainer().getStyle().setOverflow(Overflow.HIDDEN);
+        }
+    }
+
+    @Override
+    protected void stopResize() {
+        getFirstContainer().getStyle().clearOverflow();
+        getSecondContainer().getStyle().clearOverflow();
+    }
+
+    private boolean isWidgetFullHeight(Widget w) {
+        return w.getElement().getStyle().getHeight().equals("100%");
+    }
 }