From: Matti Tahvonen Date: Thu, 2 Aug 2007 05:38:03 +0000 (+0000) Subject: added scroll position indicator when scrolling to area with unrendered rows X-Git-Tag: 6.7.0.beta1~6147 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e3b1c83bbe4e337b53eb2b0a8e7015c096811169;p=vaadin-framework.git added scroll position indicator when scrolling to area with unrendered rows svn changeset:1931/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java index 7a55fc9972..a28255cc66 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java @@ -87,6 +87,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll private HashMap actionMap = new HashMap(); private String[] visibleColOrder; private boolean initialContentReceived = false; + private Element scrollPositionElement; public IScrollTable() { // TODO move headerContainer and column selector into TableHead @@ -181,6 +182,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll sizeInit(); } } + hideScrollPositionAnnotation(); } private void updateVisibleColumns(UIDL uidl) { @@ -474,6 +476,14 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll preLimit = 0; int lastRendered = tBody.getLastRendered(); int firstRendered = tBody.getFirstRendered(); + + // tell scroll position to user if currently "visible" rows are not rendered + if( (lastRendered < firstRowInViewPort + pageLength) || + (firstRowInViewPort < firstRendered)) { + announceScrollPosition(); + } + + if( postLimit <= lastRendered && preLimit >= firstRendered ) { client.updateVariable(this.paintableId, "firstvisible", firstRowInViewPort, false); return; // scrolled withing "non-react area" @@ -507,6 +517,35 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll } + private void announceScrollPosition() { + client.console.log(""+firstRowInViewPort); + if(scrollPositionElement == null) { + scrollPositionElement = DOM.createDiv(); + DOM.setAttribute(scrollPositionElement, "className", "i-table-scrollposition"); + DOM.appendChild(getElement(), scrollPositionElement); + } + DOM.setStyleAttribute(scrollPositionElement, "left", + ( + DOM.getAbsoluteLeft(getElement()) + + DOM.getIntAttribute(getElement(), "offsetWidth")/2 + - 75 + ) + "px"); + DOM.setStyleAttribute(scrollPositionElement, "top", + ( + DOM.getAbsoluteTop(getElement()) + + DOM.getIntAttribute(getElement(), "offsetHeight")/2 + - 20 + ) + "px"); + DOM.setInnerHTML(scrollPositionElement, + firstRowInViewPort + " - " + (firstRowInViewPort + pageLength) + "..."); + DOM.setStyleAttribute(scrollPositionElement, "display", "block"); + } + + private void hideScrollPositionAnnotation() { + if(scrollPositionElement != null) + DOM.setStyleAttribute(scrollPositionElement, "display", "none"); + } + private class RowRequestHandler extends Timer { private int reqFirstRow = 0; diff --git a/src/com/itmill/toolkit/terminal/gwt/public/component-themes/table/css/table.css b/src/com/itmill/toolkit/terminal/gwt/public/component-themes/table/css/table.css index 18e547b1e2..3f98208424 100644 --- a/src/com/itmill/toolkit/terminal/gwt/public/component-themes/table/css/table.css +++ b/src/com/itmill/toolkit/terminal/gwt/public/component-themes/table/css/table.css @@ -144,9 +144,15 @@ opacity: 0.5; filter: alpha(opacity=50); } - - - + +.i-table-scrollposition { + display: none; + position: absolute; + width: 150px; + padding: 4px; + border: 1px solid black; + background: yellow; +} /* IE specific styles */ * html .i-table-header-wrap {