コード例 #1
0
ファイル: Scroller.java プロジェクト: troie/GwtMobile-UI
  @Override
  public void onSwipeVertical(SwipeEvent e) {
    long current = getTranslateY(getWidget().getElement());
    if ((current >= 0) // exceed top boundary
        || (-current + this.getElement().getClientHeight()
            >= this.getElement().getScrollHeight())) { // exceed bottom
      // boundary
      return;
    }

    double speed = e.getSpeed() * 2000;
    double dicstanceFactor = 0.5;
    double timeFactor = 2;
    long distance =
        (long) (speed / Math.abs(speed)) * Math.round(speed * speed * dicstanceFactor / 1000);
    long time = Math.round(speed * speed * timeFactor / 2000);
    current += distance;
    if (current > 0) { // exceed top boundary
      double timeAdj = 1 - (double) current / distance;
      time = (long) (time * timeAdj * timeAdj);
      current = 0;
    } else if (-current + this.getElement().getClientHeight()
        > this.getElement().getScrollHeight()) { // exceed bottom boundary
      long bottom = this.getElement().getClientHeight() - this.getElement().getScrollHeight();
      double timeAdj = 1 - (double) (current - bottom) / distance;
      time = (long) (time * timeAdj * timeAdj);
      current = bottom;
    }
    setTransitionDuration(getWidget().getElement(), time);
    setTranslateY(getWidget().getElement(), current);
  }
コード例 #2
0
ファイル: SlidePanel.java プロジェクト: roadlabs/GwtMobile
 @Override
 public void onSwipeHorizontal(SwipeEvent e) {
   if (e.getSpeed() < 0) { // swipe to next
     next();
   } else { // swipe to previous
     previous();
   }
 }