]> source.dussan.org Git - vaadin-framework.git/commitdiff
Recovering scroll position after regression problems. (#12727)
authorFelype Santiago Ferreira <felype@vaadin.com>
Wed, 23 Oct 2013 08:23:02 +0000 (11:23 +0300)
committerFelype Santiago Ferreira <felype@vaadin.com>
Wed, 23 Oct 2013 08:59:41 +0000 (11:59 +0300)
The fix for "Panels get unnecessary scroll bars in WebKit when content is 100% wide (#12727)" introduced side effects to #6731. This fix solves the problem.

Change-Id: I15ca926c0ee4cad49e9eea0c578c9cc73c850588

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

index 1a87362fea6bcbd8b7d989622dabfe261d4de8a0..15c3883b11dd925a52b2a3ce61f398f5abb1a0a0 100644 (file)
@@ -218,7 +218,7 @@ public class VPanel extends SimplePanel implements ShortcutActionHandlerOwner,
          * Don't touch it unless you know what you're doing! Fixes ticket
          * #12727.
          * 
-         * This solution comes from ticket #11994: Windows get unnecessary
+         * This solution comes from the ticket #11994: Windows get unnecessary
          * scroll bars in WebKit when content is 100% wide.
          */
         if (BrowserInfo.get().isWebkit()) {
@@ -227,6 +227,10 @@ public class VPanel extends SimplePanel implements ShortcutActionHandlerOwner,
                 public void execute() {
                     final com.google.gwt.dom.client.Element scrollable = contentNode
                             .getFirstChildElement();
+
+                    int contentNodeScrollTop = contentNode.getScrollTop();
+                    int contentNodeScrollLeft = contentNode.getScrollLeft();
+
                     final String oldWidth = scrollable.getStyle().getWidth();
                     final String oldHeight = scrollable.getStyle().getHeight();
 
@@ -237,9 +241,12 @@ public class VPanel extends SimplePanel implements ShortcutActionHandlerOwner,
                     scrollable.getStyle().setHeight(110, Unit.PCT);
                     scrollable.getOffsetHeight();
                     scrollable.getStyle().setProperty("height", oldHeight);
+
+                    // Recovering scroll position:
+                    contentNode.setScrollTop(contentNodeScrollTop);
+                    contentNode.setScrollLeft(contentNodeScrollLeft);
                 }
             });
         }
-
     }
 }