Search in sources :

Example 1 with TouchPoint

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;
}
Also used : TouchEventImpl(org.kie.workbench.common.stunner.core.client.shape.view.event.TouchEventImpl) TouchPoint(com.ait.lienzo.client.core.event.TouchPoint) TouchPoint(com.ait.lienzo.client.core.event.TouchPoint)

Example 2 with TouchPoint

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));
    }
}
Also used : Element(com.google.gwt.dom.client.Element) ArrayList(java.util.ArrayList) NFastArrayList(com.ait.tooling.nativetools.client.collection.NFastArrayList) TouchPoint(com.ait.lienzo.client.core.event.TouchPoint) Touch(com.google.gwt.dom.client.Touch) TouchPoint(com.ait.lienzo.client.core.event.TouchPoint)

Aggregations

TouchPoint (com.ait.lienzo.client.core.event.TouchPoint)2 NFastArrayList (com.ait.tooling.nativetools.client.collection.NFastArrayList)1 Element (com.google.gwt.dom.client.Element)1 Touch (com.google.gwt.dom.client.Touch)1 ArrayList (java.util.ArrayList)1 TouchEventImpl (org.kie.workbench.common.stunner.core.client.shape.view.event.TouchEventImpl)1