Example usage for com.google.gwt.dom.client Touch getTarget

List of usage examples for com.google.gwt.dom.client Touch getTarget

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Touch getTarget.

Prototype

public final EventTarget getTarget() 

Source Link

Document

Gets the target element for the current touch.

Usage

From source file:com.fullmetalgalaxy.client.widget.WgtScroll.java

License:Open Source License

@Override
public void onTouchStart(TouchStartEvent p_event) {
    Touch touch = getTouch(p_event.getChangedTouches(), -1);
    if (touch != null) {
        m_currentTouchEventId = touch.getIdentifier();
        onDown(Element.as(touch.getTarget()), touch.getClientX(), touch.getClientY());
    }/*from  w ww  .  j  a  v  a  2  s . c om*/
}

From source file:com.fullmetalgalaxy.client.widget.WgtScroll.java

License:Open Source License

@Override
public void onTouchMove(TouchMoveEvent p_event) {
    Touch touch = getTouch(p_event.getChangedTouches(), m_currentTouchEventId);
    if (touch != null) {
        if (p_event.getTouches().length() < 2) {
            // A single finger touch shouldn't be propagated upwards.
            // This prevents iOS 'bounce-scroll' to happen
            p_event.preventDefault();//ww  w . ja  va  2s . c  o m
        }
        onMove(Element.as(touch.getTarget()), touch.getClientX(), touch.getClientY());
    }
}

From source file:com.fullmetalgalaxy.client.widget.WgtScroll.java

License:Open Source License

@Override
public void onTouchEnd(TouchEndEvent p_event) {
    Touch touch = getTouch(p_event.getChangedTouches(), m_currentTouchEventId);
    if (touch != null) {
        m_currentTouchEventId = -1;//from  w  w  w .  j  a va  2  s.  co  m
        onUp(Element.as(touch.getTarget()));
    }
}

From source file:com.fullmetalgalaxy.client.widget.WgtScroll.java

License:Open Source License

@Override
public void onTouchCancel(TouchCancelEvent p_event) {
    Touch touch = getTouch(p_event.getChangedTouches(), m_currentTouchEventId);
    if (touch != null) {
        m_currentTouchEventId = -1;/*from  w  w w .j  ava 2s  .  co m*/
        onOut(Element.as(touch.getTarget()));
    }
}

From source file:com.vaadin.client.ui.TouchScrollDelegate.java

License:Apache License

/**
 * Detects if a touch happens on a predefined element and the element has
 * something to scroll./*  w w w .ja  v a2  s.co  m*/
 * 
 * @param touch
 * @return
 */
private boolean detectScrolledElement(Touch touch) {
    Element target = touch.getTarget().cast();
    for (Element el : scrollableElements) {
        if (el.isOrHasChild(target) && el.getScrollHeight() > el.getClientHeight()) {
            scrolledElement = el;
            layers = getElements(scrolledElement);
            return true;

        }
    }
    return false;
}

From source file:com.vaadin.terminal.gwt.client.ui.TouchScrollDelegate.java

License:Open Source License

/**
 * Detects if a touch happens on a predefined element and the element has
 * something to scroll.//w w  w .j  a  va 2  s.  co m
 * 
 * @param touch
 * @return
 */
private boolean detectScrolledElement(Touch touch) {
    Element target = touch.getTarget().cast();
    for (Element el : scrollableElements) {
        if (el.isOrHasChild(target) && el.getScrollHeight() > el.getClientHeight()) {
            scrolledElement = el;
            NodeList<Node> childNodes = scrolledElement.getChildNodes();
            layers = new ArrayList<Element>();
            for (int i = 0; i < childNodes.getLength(); i++) {
                Node item = childNodes.getItem(i);
                if (item.getNodeType() == Node.ELEMENT_NODE) {
                    layers.add((Element) item);
                }
            }
            return true;

        }
    }
    return false;
}