com.google.gwt.dom.client.Touch.getClientY()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(142)

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

Touch.getClientY介绍

[英]Gets the touch y-position within the browser window's client area.
[中]获取浏览器窗口客户端区域内的触摸y位置。

代码示例

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Gets the touch y-position relative to a given element.
 *
 * @param target the element whose coordinate system is to be used
 * @return the relative y-position
 */
public final int getRelativeY(Element target) {
 return getClientY() - target.getAbsoluteTop() + target.getScrollTop()
   + target.getOwnerDocument().getScrollTop();
}

代码示例来源:origin: geogebra/geogebra

private int getY(TouchEvent<?> event) {
  Touch touch = getRelevantTouch(event);
  return touch == null ? 0
      : (touch.getClientY() - widget.getAbsoluteTop());
}

代码示例来源: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: com.googlecode.gwtquery/gwtquery

protected int getClientY(Event e) {
  if (touchSupported) {
   return e.getTouches().get(0).getClientY();
  } else {
   return e.getClientY();
  }
 }
}

代码示例来源:origin: net.wetheinter/gwt-user

/**
 * Gets the touch y-position relative to a given element.
 *
 * @param target the element whose coordinate system is to be used
 * @return the relative y-position
 */
public final int getRelativeY(Element target) {
 return getClientY() - target.getAbsoluteTop() + target.getScrollTop()
   + target.getOwnerDocument().getScrollTop();
}

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

/**
 * Gets the touch y-position relative to a given element.
 *
 * @param target the element whose coordinate system is to be used
 * @return the relative y-position
 */
public final int getRelativeY(Element target) {
 return getClientY() - target.getAbsoluteTop() + target.getScrollTop()
   + target.getOwnerDocument().getScrollTop();
}

代码示例来源:origin: com.vaadin.addon/vaadin-touchkit-agpl

@Override
  public void onTouchMove(TouchMoveEvent event) {
    if (capturing) {
      scrollTo(event.getTouches().get(0).getClientY());
      event.stopPropagation();
      event.preventDefault();
    }
  }
}, TouchMoveEvent.getType());

代码示例来源:origin: com.vaadin.addon/vaadin-touchkit-agpl

@Override
  public void onTouchStart(TouchStartEvent event) {
    startDrag(event.getTouches().get(0).getClientY());
    event.stopPropagation();
    event.preventDefault();
  }
});

代码示例来源: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: sriharshachilakapati/SilenceEngine

private void postTouchEvents(JsArray<Touch> touches, boolean isDown)
{
  int i, j;
  // Browsers report only the available touches in a list. So update all the touches in the list accurately.
  // We ignore the touches past finger 9 (only ten fingers are read).
  for (i = 0, j = com.shc.silenceengine.input.Touch.FINGER_0;
     i < touches.length() && j <= com.shc.silenceengine.input.Touch.FINGER_9; i++, j++)
  {
    Touch touch = touches.get(i);
    postTouchEvent(j, isDown, touch.getClientX(), touch.getClientY());
  }
  // For all the remain fingers, set the finger down state to false. Otherwise they are reported as down
  // continuously. This will fix that issue.
  while (j <= com.shc.silenceengine.input.Touch.FINGER_9)
    postTouchEvent(j++, false, 0, 0);
}

代码示例来源:origin: geogebra/geogebra

@Override
  public void onTouchEnd(TouchEndEvent event) {
    if (handler.preventDefault) {
      event.preventDefault();
    }
    if (handler.stopPropagation) {
      event.stopPropagation();
    }
    Touch removedTouch = event.getChangedTouches().get(0);
    handler.onClickEnd(removedTouch.getClientX(),
        removedTouch.getClientY(),
        PointerEventType.TOUCH);
    CancelEventTimer.touchEventOccured();
  }
}, TouchEndEvent.getType());

代码示例来源:origin: geogebra/geogebra

@Override
  public void onTouchStart(TouchStartEvent event) {
    if (handler.preventDefault) {
      event.preventDefault();
    }
    if (handler.stopPropagation) {
      event.stopPropagation();
    }
    handler.onClickStart(event.getTouches().get(0).getClientX(),
        event.getTouches().get(0).getClientY(),
        PointerEventType.TOUCH);
    CancelEventTimer.touchEventOccured();
  }
}, TouchStartEvent.getType());

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

touchStartY = touch.getClientY();

代码示例来源:origin: org.geomajas/geomajas-gwt-client-impl

/**
 * Method used to calculate exact middle point between multiple touches of a touch events.
 * 
 * @param event a touch event
 * @return middle point
 */
private Coordinate getMidPoint(TouchEvent<?> event) {
  Coordinate[] coords = new Coordinate[event.getTouches().length()];
  for (int i = 0; i < event.getTargetTouches().length(); i++) {
    coords[i] = new Coordinate(event.getTouches().get(i).getClientX(), event.getTouches().get(i).getClientY());
  }
  double x = 0;
  double y = 0;
  for (Coordinate coord : coords) {
    x += coord.getX();
    y += coord.getY();
  }
  x /= coords.length;
  y /= coords.length;
  return new Coordinate(x, y);
}

代码示例来源:origin: org.geomajas/geomajas-gwt-client-impl

@Override
public Coordinate getLocation(HumanInputEvent<?> event, RenderSpace renderSpace) {
  switch (renderSpace) {
    case WORLD:
      Coordinate screen = getLocation(event, RenderSpace.SCREEN);
      return mapPresenter.getViewPort().transform(screen, RenderSpace.SCREEN, RenderSpace.WORLD);
    case SCREEN:
    default:
      if (event instanceof MouseEvent<?>) {
        Element element = mapPresenter.asWidget().getElement();
        double offsetX = ((MouseEvent<?>) event).getRelativeX(element);
        double offsetY = ((MouseEvent<?>) event).getRelativeY(element);
        return new Coordinate(offsetX, offsetY);
      } else if (event instanceof TouchEvent<?>) {
        Touch touch = ((TouchEvent<?>) event).getTouches().get(0);
        return new Coordinate(touch.getClientX(), touch.getClientY());
      }
      return new Coordinate(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY());
  }
}

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

touchStartY = touch.getClientY();

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

touchStartY = touch.getClientY();

相关文章