]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix for #5385 and #4642
authorJohn Alhroos <john.ahlroos@itmill.com>
Tue, 10 Aug 2010 09:26:49 +0000 (09:26 +0000)
committerJohn Alhroos <john.ahlroos@itmill.com>
Tue, 10 Aug 2010 09:26:49 +0000 (09:26 +0000)
svn changeset:14443/svn branch:6.4

src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java

index 996d88d378a8f6b1591c62863c913dade5800292..37b3999e9b02e58bc20587739b1613ad312cd173 100644 (file)
@@ -4885,9 +4885,44 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
      *            The row to ensure is visible
      */
     private void ensureRowIsVisible(VScrollTableRow row) {
-        row.getElement().scrollIntoView();
+        scrollIntoViewVertically(row.getElement());
     }
 
+    /**
+     * Scrolls an element into view vertically only. Modified version of
+     * Element.scrollIntoView.
+     * 
+     * @param elem
+     *            The element to scroll into view
+     */
+    private native void scrollIntoViewVertically(Element elem)
+    /*-{
+        var top = elem.offsetTop;
+        var height = elem.offsetHeight;
+    
+        if (elem.parentNode != elem.offsetParent) {         
+          top -= elem.parentNode.offsetTop;
+        }
+    
+        var cur = elem.parentNode;
+        while (cur && (cur.nodeType == 1)) {         
+          if (top < cur.scrollTop) {
+            cur.scrollTop = top;
+          }
+          if (top + height > cur.scrollTop + cur.clientHeight) {
+            cur.scrollTop = (top + height) - cur.clientHeight;
+          }
+    
+          var offsetTop = cur.offsetTop;
+          if (cur.parentNode != cur.offsetParent) {        
+            offsetTop -= cur.parentNode.offsetTop;
+          }
+           
+          top += offsetTop - cur.scrollTop;
+          cur = cur.parentNode;
+        }
+     }-*/;
+
     /**
      * Handles the keyboard events handled by the table
      *