Handle chart touch event(gestures, clicks). Return true if gesture was handled and chart needs to be
invalidated.
555393
public boolean handleTouchEvent(MotionEvent event) {
        boolean needInvalidate = false;

        // TODO: detectors always return true, use class member needInvalidate instead local variable as workaround.
        // This flag should be computed inside gesture listeners methods to avoid invalidation.
        needInvalidate = gestureDetector.onTouchEvent(event);

        needInvalidate = scaleGestureDetector.onTouchEvent(event) || needInvalidate;

        if (isZoomEnabled && scaleGestureDetector.isInProgress()) {
            // Special case: if view is inside scroll container and user is scaling disable touch interception by
            // parent.
            disallowParentInterceptTouchEvent();
        }

        if (isValueTouchEnabled) {
            needInvalidate = computeTouch(event) || needInvalidate;
        }

        return needInvalidate;
    }
219440
public boolean onTouchEvent(final MotionEvent event) {
    switch (event.getActionMasked()) {
      case MotionEvent.ACTION_MOVE: {
        // update pointers
        updatePointersOnMove(event);
        // start a new gesture if not already started
        if (!mGestureInProgress && mPointerCount > 0 && shouldStartGesture()) {
          startGesture();
        }
        // notify listener
        if (mGestureInProgress && mListener != null) {
          mListener.onGestureUpdate(this);
        }
        break;
      }

      case MotionEvent.ACTION_DOWN:
      case MotionEvent.ACTION_POINTER_DOWN:
      case MotionEvent.ACTION_POINTER_UP:
      case MotionEvent.ACTION_UP: {
        // restart gesture whenever the number of pointers changes
        mNewPointerCount = getPressedPointerCount(event);
        stopGesture();
        updatePointersOnTap(event);
        if (mPointerCount > 0 && shouldStartGesture()) {
          startGesture();
        }
        break;
      }

      case MotionEvent.ACTION_CANCEL: {
        mNewPointerCount = 0;
        stopGesture();
        reset();
        break;
      }
    }
    return true;
  }
1177246
function (event) {

        event = normalizeEvent(this.dom, event);

        // Mark touch, which is useful in distinguish touch and
        // mouse event in upper applicatoin.
        event.zrByTouch = true;

        this.handler.processGesture(this, event, 'end');

        domHandlers.mouseup.call(this, event);

        // Do not trigger `mouseout` here, in spite of `mousemove`(`mouseover`) is
        // triggered in `touchstart`. This seems to be illogical, but by this mechanism,
        // we can conveniently implement "hover style" in both PC and touch device just
        // by listening to `mouseover` to add "hover style" and listening to `mouseout`
        // to remove "hover style" on an element, without any additional code for
        // compatibility. (`mouseout` will not be triggered in `touchend`, so "hover
        // style" will remain for user view)

        // click event should always be triggered no matter whether
        // there is gestrue event. System click can not be prevented.
        if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) {
            domHandlers.click.call(this, event);
        }

        setTouchTimer(this);
    }
75446
function(feature) {
        if (this.handlers.feature.touch && this.over) {
            this.outFeature(feature);
            this.handlers.drag.stopDown = true;
        }
    }
1300800
function (gesture, id) {
                if (this._idList[gesture]) {
                    var element = this._idList[gesture][id];
                    if (gesture == "drag" && element && element == this._activeDrag) {
                        // the element being dragged has been disposed,
                        // terminate the drag:
                        this._dragStartPosition = null;
                        disconnectMouseEvents(this);
                        this._candidateForDrag = null;
                        this._activeDrag = null;
                    }
                    delete this._idList[gesture][id];
                }
            }
421379
def on_button_press(self, event):
        
        if event.get_button()[1] not in self._buttons:
            return False  # Only handle events for registered buttons (left mouse clicks)

        if event.get_state()[1] & constants.RUBBERBAND_MODIFIER:
            return False  # Mouse clicks with pressed shift key are handled in another tool

        # Special case: moving the NameView
        # This is only allowed, if the hovered item is a NameView and the Ctrl-key is pressed and the only selected
        # item is the parental StateView. In this case, the selection and _item will no longer be looked at,
        # but only _move_name_v
        self._item = self.get_item()
        if isinstance(self._item, NameView):
            selected_items = self.view.selected_items
            if event.get_state()[1] & Gdk.ModifierType.CONTROL_MASK and len(selected_items) == 1 and next(iter(selected_items)) is \
                    self._item.parent:
                self._move_name_v = True
            else:
                self._item = self._item.parent

        if not self._move_name_v:
            self._old_selection = self.view.selected_items
            if self._item not in self.view.selected_items:
                # When items are to be moved, a button-press should not cause any deselection.
                # However, the selection is stored, in case no move operation is performed.
                self.view.handle_new_selection(self._item)

        if not self.view.is_focus():
            self.view.grab_focus()

        return True
1327096
function(evt) {
        evt.preventDefault();
        evt.stopPropagation();

        //Detect if finger moves too much for it to be considered a tap
        var {x1, y1, time} = tapStart;
        var x2 = evt.touches[0].pageX;
        var y2 = evt.touches[0].pageY;
        var dx = x2 - x1;
        var dy = y2 - y1;
        tapDiff = Math.sqrt(dx * dx + dy * dy);

        //Detect if it's moved too little in too short a time to be considered a pan
        if((new Date() - tapStart.timeStart < tapDuration) && tapDiff <= 2){
          return;
        }

        if (debug) { timedLog("panmove"); }
        if (!transform.x1 && !transform.y1) {
          return;
        }
        if (evt.touches && evt.touches.length > 1) {
          return handlers.handleTouchRepositioning(evt);
        }
        if (debug) { timedLog("panmove - continued"); }

        var x = evt.clientX || evt.touches[0].pageX,
          y = evt.clientY || evt.touches[0].pageY;

        transform.modified = true;
        positionable.handleTranslation(x - transform.x1 + mark.x, y - transform.y1 + mark.y);
      }
379734
function(e) {
		
		var touch = e.touches[0]
		
		// Make sure click doesn't fire
		touchClientX = touch.clientX
		touchClientY = touch.clientY
		timestamp = Date.now()
	}
451539
function touchHandler (event) {
  let opt = this._opt
  opt.preventDefault && event.preventDefault()
  opt.stopPropagation && event.stopPropagation()

  // 如果 touchstart 没有被触发(可能被子元素的 touchstart 回调触发了 stopPropagation)，
  // 那么后续的手势将取消计算
  if (event.type !== 'touchstart' && !dataProcessor.startTime) {
    return
  }

  let data = dataProcessor.process(event, opt.preventX, opt.preventY)
  this._recognize(data)
  this.trigger(event.type, event, data)
}
776473
function gestureContinue(element, clientX, clientY) {

  // Calculate and save the velocity since the last event. If this is the last
  // movement of the gesture, this velocity will be used to determine whether
  // the user is trying to flick.
  const deltaX = clientX - element[previousXKey];
  const deltaY = clientY - element[previousYKey];
  const now = Date.now();
  const deltaTime = now - element[previousTimeKey];
  const velocity = deltaX / deltaTime * 1000;

  element[previousXKey] = clientX;
  element[previousYKey] = clientY;
  element[previousTimeKey] = now;
  element[previousVelocityKey] = velocity;

  const verticalSwipe = Math.abs(deltaY) > Math.abs(deltaX);
  const vertical = element.state.swipeAxis === 'vertical';
  const swipeAlongAxis = vertical === verticalSwipe;

  if (!swipeAlongAxis) {
    // Move was mostly along the other axis.
    return false;
  }

  // Move was mostly along desired axis.

  if (vertical && isAnyAncestorScrolled(element[symbols.swipeTarget])) {
    // Don't interfere with scrolling.
    return false;
  }

  const swipeFraction = getSwipeFraction(element, clientX, clientY);

  if (swipeFraction < 0 && !element.state.enableNegativeSwipe ||
      swipeFraction > 0 && !element.state.enablePositiveSwipe) {
    // Swipe was in a direction that's not explicitly enabled.
    return false;
  }

  element.setState({ swipeFraction });
  
  // Indicate that the event was handled. It'd be nicer if we didn't have
  // to do this so that, e.g., a user could be swiping left and right
  // while simultaneously scrolling up and down. (Native touch apps can do
  // that.) However, Mobile Safari wants to handle swipe events near the
  // page and interpret them as navigations. To avoid having a horiziontal
  // swipe misintepreted as a navigation, we indicate that we've handled
  // the event, and prevent default behavior.
  return true;
}
818228
function begin_gesture(e) {
        var touch = e.touches[0];
        gesture_in_progress = true;
        gesture_start_x = touch.clientX;
        gesture_start_y = touch.clientY;
    }
1146301
public boolean dispatchTouchEvent(final MotionEvent event) {
    checkNotNull(event, "event == null");
    boolean isEventConsumed = false;

    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN: // user started touching the screen
        onActionDown(event);
        break;
      case MotionEvent.ACTION_UP:   // user stopped touching the screen
        isEventConsumed = onActionUp(event);
        break;
      case MotionEvent.ACTION_MOVE: // user is moving finger on the screen
        onActionMove(event);
        break;
      default:
        break;
    }

    return isEventConsumed;
  }
824885
function (event) {
      var xPos, yPos, rect;
      rect = this.canvas.getBoundingClientRect();
      if (event.originalEvent)
          event = event.originalEvent;

      // Touch event
      if (event.type.indexOf('touch') !== -1) { // event.constructor === TouchEvent
        xPos = event.touches[0].clientX - rect.left;
        yPos = event.touches[0].clientY - rect.top;
      }
      // Mouse event
      else {
        xPos = event.clientX - rect.left;
        yPos = event.clientY - rect.top;
      }
      return {
        x: xPos,
        y: yPos
      };
    }
843023
function cleanTouchActions(actions) {
    // none
    if (inStr(actions, TOUCH_ACTION_NONE)) {
        return TOUCH_ACTION_NONE;
    }

    var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
    var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);

    // if both pan-x and pan-y are set (different recognizers
    // for different directions, e.g. horizontal pan but vertical swipe?)
    // we need none (as otherwise with pan-x pan-y combined none of these
    // recognizers will work, since the browser would handle all panning
    if (hasPanX && hasPanY) {
        return TOUCH_ACTION_NONE;
    }

    // pan-x OR pan-y
    if (hasPanX || hasPanY) {
        return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
    }

    // manipulation
    if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
        return TOUCH_ACTION_MANIPULATION;
    }

    return TOUCH_ACTION_AUTO;
}
156451
def process_event(self, event):
        
        # Convert into absolute coordinates if needed.
        new_event = event
        if self._absolute:
            new_event.y -= self._canvas.start_line

        # Process event if needed.
        if self.is_mouse_over(new_event) and event.buttons != 0:
            self._set_pos((new_event.y - self._y) / (self._height - 1))
            return True
        return False
1166547
function(event) {
		return (
				(this._touchIsTouchEvent(event) && !this._touchSwiped(event.target))
			||	(!this._touchIsTouchEvent(event) && !this._touchIsEmulatedEvent(event))
		);
	}
165376
function onEvent(gesture, handler) {
    var gestures = gesture.split(' ');
    Hammer.utils.each(gestures, function(gesture) {
      this.element.addEventListener(gesture, handler, false);
    }, this);
    return this;
  }