ontouch prevented by clickHandled flag because some browsers fire both click/touch events, causing unwanted behavior
551115
function (e) {
		var originalEvent = e.originalEvent;
		var clientX;
		var clientY;
		if (originalEvent.touches && originalEvent.touches[0] && !this._clickHandled && !this._touchHandled && !this._disableMarkers) {
			clientX = originalEvent.touches[0].clientX;
			clientY = originalEvent.touches[0].clientY;
			this._disableNewMarkers();
			this._touchHandled = true;
			this._startPoint.call(this, clientX, clientY);
			this._endPoint.call(this, clientX, clientY, e);
			this._touchHandled = null;
		}
		this._clickHandled = null;
	}
1307819
function offEvent(gesture, handler){
      var gestures = gesture.split(' ');
      for(var t=0; t<gestures.length; t++) {
        this.element.removeEventListener(gestures[t], handler, false);
      }
      return this;
    }
1284554
function DragDropTouch() {
            this._lastClick = 0;
            // enforce singleton pattern
            if (DragDropTouch._instance) {
                throw 'DragDropTouch instance already created.';
            }
            // listen to touch events
            if ('ontouchstart' in document) {
                var d = document, ts = this._touchstart.bind(this), tm = this._touchmove.bind(this), te = this._touchend.bind(this);
                d.addEventListener('touchstart', ts);
                d.addEventListener('touchmove', tm);
                d.addEventListener('touchend', te);
                d.addEventListener('touchcancel', te);
            }
        }
415705
private void postTouchEvent(TouchState state, int eventType) {
        Window window = state.getWindow(false, null);
        View view = window == null ? null : window.getView();
        if (view != null) {
            switch (state.getPointCount()) {
                case 0:
                    postNoPoints(view);
                    break;
                case 1:
                    postPoint(window, view, eventType, state.getPoint(0));
                    break;
                default: {
                    int count = state.getPointCount();
                    int[] states = new int[count];
                    int[] ids = new int[count];
                    int[] xs = new int[count];
                    int[] ys = new int[count];
                    for (int i = 0; i < count; i++) {
                        states[i] = eventType;
                        TouchState.Point p = state.getPoint(i);
                        ids[i] = p.id;
                        xs[i] = p.x;
                        ys[i] = p.y;
                    }
                    postPoints(window, view, states, ids, xs, ys);
                }
            }
        }
    }
1276853
function SingleTouchInput() {
    this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
    this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
    this.started = false;

    Input.apply(this, arguments);
}
627211
public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        mIsCapturingGesture = true;
        mIsClickCandidate = true;
        mActionDownTime = event.getEventTime();
        mActionDownX = event.getX();
        mActionDownY = event.getY();
        break;
      case MotionEvent.ACTION_MOVE:
        if (Math.abs(event.getX() - mActionDownX) > mSingleTapSlopPx ||
            Math.abs(event.getY() - mActionDownY) > mSingleTapSlopPx) {
          mIsClickCandidate = false;
        }
        break;
      case MotionEvent.ACTION_CANCEL:
        mIsCapturingGesture = false;
        mIsClickCandidate = false;
        break;
      case MotionEvent.ACTION_UP:
        mIsCapturingGesture = false;
        if (Math.abs(event.getX() - mActionDownX) > mSingleTapSlopPx ||
            Math.abs(event.getY() - mActionDownY) > mSingleTapSlopPx) {
          mIsClickCandidate = false;
        }
        if (mIsClickCandidate) {
          if (event.getEventTime() - mActionDownTime <= ViewConfiguration.getLongPressTimeout()) {
            if (mClickListener != null) {
              mClickListener.onClick();
            }
          } else {
            // long click, not handled
          }
        }
        mIsClickCandidate = false;
        break;
    }
    return true;
  }
831253
function (obj, handler, id) {
		var last, touch,
		    doubleTap = false,
		    delay = 250;

		function onTouchStart(e) {
			var count;

			if (L.Browser.pointer) {
				count = L.DomEvent._pointersCount;
			} else {
				count = e.touches.length;
			}

			if (count > 1) { return; }

			var now = Date.now(),
			    delta = now - (last || now);

			touch = e.touches ? e.touches[0] : e;
			doubleTap = (delta > 0 && delta <= delay);
			last = now;
		}

		function onTouchEnd() {
			if (doubleTap && !touch.cancelBubble) {
				if (L.Browser.pointer) {
					// work around .type being readonly with MSPointer* events
					var newTouch = {},
					    prop, i;

					for (i in touch) {
						prop = touch[i];
						newTouch[i] = prop && prop.bind ? prop.bind(touch) : prop;
					}
					touch = newTouch;
				}
				touch.type = 'dblclick';
				handler(touch);
				last = null;
			}
		}

		var pre = '_leaflet_',
		    touchstart = this._touchstart,
		    touchend = this._touchend;

		obj[pre + touchstart + id] = onTouchStart;
		obj[pre + touchend + id] = onTouchEnd;
		obj[pre + 'dblclick' + id] = handler;

		obj.addEventListener(touchstart, onTouchStart, false);
		obj.addEventListener(touchend, onTouchEnd, false);

		// On some platforms (notably, chrome on win10 + touchscreen + mouse),
		// the browser doesn't fire touchend/pointerup events but does fire
		// native dblclicks. See #4127.
		if (!L.Browser.edge) {
			obj.addEventListener('dblclick', handler, false);
		}

		return this;
	}
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;
    }
355507
function fireTouchEvents(eventName, originalEvent) {
    // All touch events, including "touchend".
    var events = [];
    var gestures = [];

    // For each finger with a target, create a touch event.
    fingers.forEach(function(finger) {
      if (!finger.target) return;

      // Convert "ontouch*" properties and attributes to listeners.
      var onEventName = 'on' + eventName;

      if (onEventName in finger.target) {
        console.warn('Converting `' + onEventName + '` property to event listener.', finger.target);
        finger.target.addEventListener(eventName, finger.target[onEventName], false);
        delete finger.target[onEventName];
      }

      if (finger.target.hasAttribute(onEventName)) {
        console.warn('Converting `' + onEventName + '` attribute to event listener.', finger.target);
        var handler = new Function('event', finger.target.getAttribute(onEventName));
        finger.target.addEventListener(eventName, handler, false);
        finger.target.removeAttribute(onEventName);
      }

      // Set up a new event with the coordinates of the finger.
      var touch = createMouseEvent(eventName, originalEvent, finger);

      events.push(touch);
    });

    // Figure out scale and rotation.
    if (events.length > 1) {
      var x = events[0].pageX - events[1].pageX;
      var y = events[0].pageY - events[1].pageY;

      var distance = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
      var angle = Math.atan2(x, y) * (180 / Math.PI);

      var gestureName = 'gesturechange';

      if (eventName === 'touchstart') {
        gestureName = 'gesturestart';
        startDistance = distance;
        startAngle = angle;
      }

      if (eventName === 'touchend') gestureName = 'gestureend';

      events.forEach(function(event) {
        var gesture = createMouseEvent(gestureName, event, event._finger);
        gestures.push(gesture);
      });

      events.concat(gestures).forEach(function(event) {
        event.scale = distance / startDistance;
        event.rotation = startAngle - angle;
      });
    }

    // Loop through the events array and fill in each touch array.
    events.forEach(function(touch) {
      touch.touches = events.filter(function(e) {
        return ~e.type.indexOf('touch') && e.type !== 'touchend';
      });

      touch.changedTouches = events.filter(function(e) {
        return ~e.type.indexOf('touch') && e._finger.target === touch._finger.target;
      });

      touch.targetTouches = touch.changedTouches.filter(function(e) {
        return ~e.type.indexOf('touch') && e.type !== 'touchend';
      });
    });

    // Then fire the events.
    events.concat(gestures).forEach(function(event, i) {
      event.identifier = i;
      event._finger.target.dispatchEvent(event);
    });
  }
610930
function onMouse(touchType) {
  return function(ev) {
    // prevent mouse events

    if (ev.which !== 1) {
      return;
    }

    // The EventTarget on which the touch point started when it was first placed on the surface,
    // even if the touch point has since moved outside the interactive area of that element.
    // also, when the target doesnt exist anymore, we update it
    if (ev.type === 'mousedown' || !eventTarget || eventTarget && !eventTarget.dispatchEvent) {
      eventTarget = ev.target;
    }

    triggerTouch(touchType, ev);

    // reset
    if (ev.type === 'mouseup') {
      eventTarget = null;
    }
  };
}
37912
function touchcancelHandler(event) {

  if (Object.keys(gestures).length == 2) {
    var elements = []
    for (var p in gestures) {
      elements.push(gestures[p].element)
    }
    fireEvent(getCommonAncestor(elements[0], elements[1]), 'dualtouchend', {
      touches: slice.call(event.touches),
      touchEvent: event
    })
  }

  for (var i = 0; i < event.changedTouches.length; i++) {
    var touch = event.changedTouches[i]
    var id = touch.identifier
    var gesture = gestures[id]

    if (!gesture) {
      continue
    }

    if (gesture.pressingHandler) {
      clearTimeout(gesture.pressingHandler)
      gesture.pressingHandler = null
    }

    if (gesture.status === 'panning') {
      fireEvent(gesture.element, 'panend', {
        touch: touch,
        touches: event.touches,
        changedTouches: event.changedTouches,
        touchEvent: event
      })
    }
    if (gesture.status === 'pressing') {
      fireEvent(gesture.element, 'pressend', {
        touch: touch,
        touchEvent: event
      })
    }
    delete gestures[id]
  }

  if (Object.keys(gestures).length === 0) {
    docEl.removeEventListener('touchmove', touchmoveHandler, false)
    docEl.removeEventListener('touchend', touchendHandler, false)
    docEl.removeEventListener('touchcancel', touchcancelHandler, false)
  }
}
284419
function phantomTouchMove(e) {
    if (e.synthetic) return;

    e.preventDefault();
    e.stopPropagation();

    moveFingers(e);

    if (mouseIsDown) {
      fireTouchEvents('touchmove', e);
    }
  }
98472
function dragHandler(event) {
            dragging.released = event.type === 'mouseup' || event.type === 'touchend';
            dragging.path     = within(
                (dragging.touch ? event.originalEvent[dragging.released ? 'changedTouches' : 'touches'][0] : event)[o.horizontal ? 'pageX' : 'pageY'] - dragging.initLoc,
                dragging.pathMin, dragging.pathMax
            );

            // Initialization
            if (!dragging.init && (Math.abs(dragging.path) > (dragging.touch ? 50 : 10) || dragging.source === 'handle')) {
                dragging.init = 1;
                if (dragging.source === 'slidee') {
                    ignoreNextClick = 1;
                }

                // Pause ongoing cycle
                self.pause(1);

                // Disable click actions on source element, as they are unwelcome when dragging
                dragging.$source.on('click', function disableAction(event) {
                    stopDefault(event, 1);
                    if (dragging.source === 'slidee') {
                        ignoreNextClick = 0;
                    }
                    dragging.$source.off('click', disableAction);
                });

                // Trigger moveStart event
                trigger('moveStart');
            }

            // Proceed when initialized
            if (dragging.init) {
                stopDefault(event);

                // Adjust path with a swing on mouse release
                if (dragging.released && dragging.source === 'slidee' && o.speed > 33) {
                    dragging.path += dragging.path * 200 / (+new Date() - dragging.start);
                }

                slideTo(dragging.source === 'slidee' ? Math.round(dragging.initPos - dragging.path) : handleToSlidee(dragging.initPos + dragging.path));
            }

            // Cleanup and trigger :moveEnd event on release
            if (dragging.released) {
                $doc.off(dragging.touch ? dragTouchEvents : dragMouseEvents, dragHandler);
                (dragging.source === 'slidee' ? $slidee : $handle).removeClass(o.draggedClass);

                // Account for item snapping position adjustment.
                if (pos.cur === pos.dest) {
                    trigger('moveEnd');
                }
            }
        }
849638
function phantomTouchEnd(e) {
    if (e.synthetic) return;

    mouseIsDown = false;

    e.preventDefault();
    e.stopPropagation();

    fireTouchEvents('touchend', e);

    fingers.forEach(function(finger) {
      if (!finger.target) return;

      // Mobile Safari moves all the mouse event to fire after the touchend event.
      finger.target.dispatchEvent(createMouseEvent('mouseover', e, finger));
      finger.target.dispatchEvent(createMouseEvent('mousemove', e, finger));
      finger.target.dispatchEvent(createMouseEvent('mousedown', e, finger));

      // TODO: These two only fire if content didn't change. How can we tell?
      finger.target.dispatchEvent(createMouseEvent('mouseup', e, finger));
      finger.target.dispatchEvent(createMouseEvent('click', e, finger));
    });
  }
26773
public void handleTouchEvent(MotionEvent ev){
        if(ev.getAction() == MotionEvent.ACTION_MOVE){
            // A finger is dragging about
            if(mTexHeight != 0 && mTexWidth != 0){
                mSummedTouchPosition[0] += (2 * (ev.getX() - mLastTouchPosition[0])) / mTexWidth;
                mSummedTouchPosition[1] += (2 * (ev.getY() - mLastTouchPosition[1])) / -mTexHeight;
                mLastTouchPosition[0] = ev.getX();
                mLastTouchPosition[1] = ev.getY();
            }
        }else if(ev.getAction() == MotionEvent.ACTION_DOWN){
            // The primary finger has landed
            mLastTouchPosition[0] = ev.getX();
            mLastTouchPosition[1] = ev.getY();
        }
    }
242621
function() {
        if (!this.touch) {
            this.touch = true;
            var events = [
                "mousedown", "mouseup", "mousemove", "click", "dblclick",
                "mouseout"
            ];
            for (var i=0, len=events.length; i<len; i++) {
                if (this[events[i]]) {
                    this.unregister(events[i], this[events[i]]); 
                }
            } 
        }
    }
567196
function onClick(event) {
      if (Date.now() - lastPreventedTime > PREVENT_DURATION) {
        return; // Too old.
      }

      var touches = event.touches && event.touches.length ? event.touches : [event];
      var x = touches[0].clientX;
      var y = touches[0].clientY;


      // Look for an allowable region containing this click.
      // If we find one, that means it was created by touchstart and not removed by
      // preventGhostClick, so we don't bust it.
      if (checkAllowableRegions(touchCoordinates, x, y)) {
        return;
      }

      // If we didn't find an allowable region, bust the click.
      event.stopPropagation();
      event.preventDefault();

      // Blur focused form elements
      if(event.target) {
        event.target.blur();
      }
    }