aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2007-12-28 15:30:27 +0000
committerMarc Englund <marc.englund@itmill.com>2007-12-28 15:30:27 +0000
commitc7f66bb3fde4d9aff9921fec29128d66f19923e0 (patch)
tree6c70f5b416762e71fa994c95a34278bb80a01955
parentf762a82549f2fd7fdab08444f4fc93f6ddfea564 (diff)
downloadvaadin-framework-c7f66bb3fde4d9aff9921fec29128d66f19923e0.tar.gz
vaadin-framework-c7f66bb3fde4d9aff9921fec29128d66f19923e0.zip
save scroll pos before removing content, restore afterwards (#1222)
svn changeset:3336/svn branch:trunk
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java9
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java7
2 files changed, 16 insertions, 0 deletions
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("");
}