Exemplo n.º 1
0
 private void doScrollToElement(double progress) {
   Double delta;
   if (progress > 0) {
     int scrollPosition = scrollToElement.getAbsoluteTop();
     if (parentElement.getScrollTop() <= scrollPosition) {
       delta =
           parentElement.getScrollTop()
               + (scrollPosition - parentElement.getScrollTop()) * progress;
       parentElement.setScrollTop(delta.intValue());
     } else {
       delta =
           parentElement.getScrollTop()
               - (parentElement.getScrollTop() - scrollPosition) * progress;
       parentElement.setScrollTop(delta.intValue());
     }
   }
 }
Exemplo n.º 2
0
  protected void scrollToSelectedRow() {
    if (iCourses.getSelectedRow() < 0) return;

    Element scroll = iCoursesPanel.getElement();

    com.google.gwt.dom.client.Element item =
        iCourses.getTable().getRowFormatter().getElement(iCourses.getSelectedRow());
    if (item == null) return;

    int realOffset = 0;
    while (item != null && !item.equals(scroll)) {
      realOffset += item.getOffsetTop();
      item = item.getOffsetParent();
    }

    scroll.setScrollTop(realOffset - scroll.getOffsetHeight() / 2);
  }