Currently, scrolling to the far right or bottom of the ScrollPanel requires the user to access the scrollHeight property of the DOM element directly as followings:
setScrollPosition(DOM.getElementPropertyInt(getElement(), "scrollHeight"));
Fix:
Added the following convenience methods to abstract the DOM portion of the code:
scrollToTop()
scrollToBottom()
scrollToLeft()
scrollToRight()
Testing:
Manually verified the new methods scroll to the correct locations in all browsers.
Found by: jlabanca
Fixed by: jlabanca
Review by: jgw
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1765 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/ScrollPanel.java b/user/src/com/google/gwt/user/client/ui/ScrollPanel.java
index 1cc47c9..3d23903 100644
--- a/user/src/com/google/gwt/user/client/ui/ScrollPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/ScrollPanel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -101,6 +101,35 @@
}
/**
+ * Scroll to the bottom of this panel.
+ */
+ public void scrollToBottom() {
+ setScrollPosition(DOM.getElementPropertyInt(getElement(), "scrollHeight"));
+ }
+
+ /**
+ * Scroll to the far left of this panel.
+ */
+ public void scrollToLeft() {
+ setHorizontalScrollPosition(0);
+ }
+
+ /**
+ * Scroll to the far right of this panel.
+ */
+ public void scrollToRight() {
+ setHorizontalScrollPosition(DOM.getElementPropertyInt(getElement(),
+ "scrollWidth"));
+ }
+
+ /**
+ * Scroll to the top of this panel.
+ */
+ public void scrollToTop() {
+ setScrollPosition(0);
+ }
+
+ /**
* Sets whether this panel always shows its scroll bars, or only when
* necessary.
*