From e696b177d18dc477f30b81a9ac0fdab5b3e70b97 Mon Sep 17 00:00:00 2001 From: John Alhroos Date: Tue, 10 Aug 2010 09:26:49 +0000 Subject: [PATCH] Fix for #5385 and #4642 svn changeset:14443/svn branch:6.4 --- .../terminal/gwt/client/ui/VScrollTable.java | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index 996d88d378..37b3999e9b 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -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 * -- 2.39.5