]> source.dussan.org Git - vaadin-framework.git/commitdiff
save scroll pos before removing content, restore afterwards (#1222)
authorMarc Englund <marc.englund@itmill.com>
Fri, 28 Dec 2007 15:30:27 +0000 (15:30 +0000)
committerMarc Englund <marc.englund@itmill.com>
Fri, 28 Dec 2007 15:30:27 +0000 (15:30 +0000)
svn changeset:3336/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java

index b90153a563af319a169c42c4bd0bb4b1681f4aab..4ae766c366290be87c3a7d96d4af9a81ea8795e8 100644 (file)
@@ -200,6 +200,10 @@ public class IPanel extends SimplePanel implements Paintable,
             final boolean hasChildren = getWidget() != null;
             Element contentEl = null;
             String origPositioning = null;
+            // save scroll position
+            int scrollTop = DOM.getElementPropertyInt(contentNode, "scrollTop");
+            int scrollLeft = DOM.getElementPropertyInt(contentNode,
+                    "scrollLeft");
             if (hasChildren) {
                 // Remove children temporary form normal flow to detect proper
                 // size
@@ -207,6 +211,7 @@ public class IPanel extends SimplePanel implements Paintable,
                 origPositioning = DOM.getStyleAttribute(contentEl, "position");
                 DOM.setStyleAttribute(contentEl, "position", "absolute");
             }
+
             // Set defaults
             DOM.setStyleAttribute(contentNode, "overflow", "hidden");
             DOM.setStyleAttribute(contentNode, "height", "");
@@ -239,6 +244,10 @@ public class IPanel extends SimplePanel implements Paintable,
                         "positioning:" + origPositioning);
                 DOM.setStyleAttribute(contentEl, "position", origPositioning);
             }
+            // restore scroll position
+            DOM.setElementPropertyInt(contentNode, "scrollTop", scrollTop);
+            DOM.setElementPropertyInt(contentNode, "scrollLeft", scrollLeft);
+
         } else {
             DOM.setStyleAttribute(contentNode, "height", "");
         }
index 847980e1d6224effa1183f8a11bee45eedf19a54..3dfb87e93587ed8a2376c4126f754e6e340822ba 100644 (file)
@@ -175,6 +175,10 @@ public class ITabsheet extends ITabsheetBase implements
 
     public void iLayout() {
         if (height != null && height != "") {
+            // save scroll position
+            int scrollTop = DOM.getElementPropertyInt(contentNode, "scrollTop");
+            int scrollLeft = DOM.getElementPropertyInt(contentNode,
+                    "scrollLeft");
             // Take content out of flow for a while
             final String originalPositioning = DOM.getStyleAttribute(tp
                     .getElement(), "position");
@@ -202,6 +206,9 @@ public class ITabsheet extends ITabsheetBase implements
             DOM.setStyleAttribute(tp.getElement(), "position",
                     originalPositioning);
             DOM.setStyleAttribute(contentNode, "overflow", "auto");
+            // restore scroll position
+            DOM.setElementPropertyInt(contentNode, "scrollTop", scrollTop);
+            DOM.setElementPropertyInt(contentNode, "scrollLeft", scrollLeft);
         } else {
             tp.setHeight("");
         }