use of com.ait.lienzo.client.core.event.TouchPoint in project kie-wb-common by kiegroup.
the class ViewEventHandlerManager method buildTouchEvent.
private TouchEventImpl buildTouchEvent(final AbstractNodeTouchEvent event) {
final TouchPoint touchPoint = null != event.getTouches() && !event.getTouches().isEmpty() ? (TouchPoint) event.getTouches().get(0) : null;
if (null != touchPoint) {
final int tx = touchPoint.getX();
final int ty = touchPoint.getY();
return new TouchEventImpl(event.getX(), event.getY(), tx, ty);
}
return null;
}
use of com.ait.lienzo.client.core.event.TouchPoint in project lienzo-core by ahome-it.
the class LienzoHandlerManager method getTouches.
private final List<TouchPoint> getTouches(final TouchEvent<?> event) {
final JsArray<Touch> jsarray = event.getTouches();
final Element element = event.getRelativeElement();
if ((null != jsarray) && (jsarray.length() > 0)) {
final int size = jsarray.length();
final ArrayList<TouchPoint> touches = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
final Touch touch = jsarray.get(i);
touches.add(new TouchPoint(touch.getRelativeX(element), touch.getRelativeY(element)));
}
return touches;
} else {
final int x = (event.getNativeEvent().getClientX() - element.getAbsoluteLeft()) + element.getScrollLeft() + element.getOwnerDocument().getScrollLeft();
final int y = (event.getNativeEvent().getClientY() - element.getAbsoluteTop()) + element.getScrollTop() + element.getOwnerDocument().getScrollTop();
return Arrays.asList(new TouchPoint(x, y));
}
}
Aggregations