]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix scroll position handling in Window Webkit hack (#12736)
authorArtur Signell <artur@vaadin.com>
Wed, 6 Nov 2013 13:11:34 +0000 (15:11 +0200)
committerArtur Signell <artur@vaadin.com>
Wed, 6 Nov 2013 13:27:19 +0000 (15:27 +0200)
Change-Id: If4d17c34b2d20ad983f21b892d3ab4c68f511780

client/src/com/vaadin/client/ui/VWindow.java

index 396169eb8c1a950d067b401f84f953550b30daed..73b57c7e5b7ada77c81ccf683a85c3338b4f5120 100644 (file)
@@ -360,6 +360,12 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
                 public void execute() {
                     final com.google.gwt.dom.client.Element scrollable = contents
                             .getFirstChildElement();
+
+                    // Adjusting the width or height may change the scroll
+                    // position, so store the current position
+                    int horizontalScrollPosition = scrollable.getScrollLeft();
+                    int verticalScrollPosition = scrollable.getScrollTop();
+
                     final String oldWidth = scrollable.getStyle().getWidth();
                     final String oldHeight = scrollable.getStyle().getHeight();
 
@@ -371,6 +377,10 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
                     scrollable.getOffsetHeight();
                     scrollable.getStyle().setProperty("height", oldHeight);
 
+                    // Restore the scroll position
+                    scrollable.setScrollLeft(horizontalScrollPosition);
+                    scrollable.setScrollTop(verticalScrollPosition);
+
                     updateContentsSize();
                     positionOrSizeUpdated();
                 }