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());
     }
   }
 }
Exemple #2
0
 /** Kindly borrowed from PlayN. * */
 protected static float getRelativeY(NativeEvent e, Element target) {
   return e.getClientY()
       - target.getAbsoluteTop()
       + target.getScrollTop()
       + target.getOwnerDocument().getScrollTop();
 }