com.google.gwt.user.client.Event.getChangedTouches()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中com.google.gwt.user.client.Event.getChangedTouches()方法的一些代码示例,展示了Event.getChangedTouches()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Event.getChangedTouches()方法的具体详情如下:
包路径:com.google.gwt.user.client.Event
类名称:Event
方法名:getChangedTouches

Event.getChangedTouches介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

@Override
public void onBrowserEvent(Event event) {
  switch (event.getTypeInt()) {
  case Event.ONTOUCHSTART:
    startPoint = new Point(event.getChangedTouches().get(0).getClientX(), event.getChangedTouches().get(0).getClientY());
    break;
  case Event.ONTOUCHMOVE:
    endPoint = new Point(event.getChangedTouches().get(0).getClientX(), event.getChangedTouches().get(0).getClientY());
    double dx = startPoint.getX() - endPoint.getX();
    double dy = startPoint.getY() - endPoint.getY();
    if (Math.abs(dx) > SWIPE_X_MIN) {
      if (Math.abs(dy) < SWIPE_Y_MAX) {
        // Decided it really is a horizontal swipe
        event.preventDefault();
        if (dx < 0) {
          Window.alert("swiped right");
        } else {
          Window.alert("swiped left");
        }
      }
    }
    break;
  }       
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-vaadin-common-widgets

private boolean isSignificantMove(Event event) {
  if (touchStart == null) {
    // no touch start
    return false;
  }
  /*
   * TODO calculate based on real distance instead of separate
   * axis checks
   */
  Touch touch = event.getChangedTouches().get(0);
  if (Math.abs(touch.getClientX()
      - touchStartX) > TouchScrollDelegate.SIGNIFICANT_MOVE_THRESHOLD) {
    return true;
  }
  if (Math.abs(touch.getClientY()
      - touchStartY) > TouchScrollDelegate.SIGNIFICANT_MOVE_THRESHOLD) {
    return true;
  }
  return false;
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-vaadin-common-widgets

/**
   * Calculates how many pixels away the user's finger has traveled. This
   * reduces the chance of small non-intentional movements from canceling
   * the long press detection.
   *
   * @param event
   *            the Event for which to check the move distance
   * @return true if this is considered an intentional move by the user
   */
  protected boolean isSignificantMove(Event event) {
    if (touchStart == null) {
      // no touch start
      return false;
    }
    // Calculate the distance between touch start and the current touch
    // position
    Touch touch = event.getChangedTouches().get(0);
    int deltaX = touch.getClientX() - touchStartX;
    int deltaY = touch.getClientY() - touchStartY;
    int delta = deltaX * deltaX + deltaY * deltaY;
    // Compare to the square of the significant move threshold to remove
    // the need for a square root
    if (delta > TouchScrollDelegate.SIGNIFICANT_MOVE_THRESHOLD
        * TouchScrollDelegate.SIGNIFICANT_MOVE_THRESHOLD) {
      return true;
    }
    return false;
  }
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-vaadin-common-widgets

Touch touch = event.getChangedTouches().get(0);
touchStartX = touch.getClientX();
touchStartY = touch.getClientY();

代码示例来源:origin: info.magnolia.ui/magnolia-ui-vaadin-common-widgets

touchStart = event;
isDragging = false;
Touch touch = event.getChangedTouches().get(0);

代码示例来源:origin: info.magnolia.ui/magnolia-ui-vaadin-common-widgets

case Event.ONTOUCHSTART:
  touchStart = event;
  Touch touch = event.getChangedTouches().get(0);

相关文章