From: Marc Englund Date: Fri, 28 Dec 2007 15:30:27 +0000 (+0000) Subject: save scroll pos before removing content, restore afterwards (#1222) X-Git-Tag: 6.7.0.beta1~5183 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c7f66bb3fde4d9aff9921fec29128d66f19923e0;p=vaadin-framework.git save scroll pos before removing content, restore afterwards (#1222) svn changeset:3336/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java index b90153a563..4ae766c366 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java @@ -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", ""); } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java index 847980e1d6..3dfb87e935 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java @@ -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(""); }