/*
Invoked when the user has finished a touch operation.
 /* eslint-disable no-unused-vars
196080
function gestureEnd(element, clientX, clientY) {

  // Examine velocity of last movement to see if user is flicking.
  const velocity = element[previousVelocityKey];
  const flickThresholdVelocity = 800; // speed in pixels/second

  let flickPositive;
  if (velocity >= flickThresholdVelocity) {
    // Flicked right/down at high speed.
    flickPositive = true;
  } else if (velocity <= -flickThresholdVelocity) {
    // Flicked left/up at high speed.
    flickPositive = false;
  } else {
    // Finished at low speed.
    const swipeFraction = getSwipeFraction(element, clientX, clientY);
    if (swipeFraction <= -0.5) {
      flickPositive = false;
    } else if (swipeFraction >= 0.5) {
      flickPositive = true;
    }
  }

  if (typeof flickPositive !== 'undefined') {
    const vertical = element.state.swipeAxis === 'vertical';
    const gesture = vertical ?
      (flickPositive ? symbols.swipeDown : symbols.swipeUp) :
      (flickPositive ? symbols.swipeRight : symbols.swipeLeft);
    // If component has method for indicated gesture, invoke it.
    if (gesture && element[gesture]) {
      element[gesture]();
    }
  }

  element.setState({ swipeFraction: null });
}
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
      };
    }
122539
function(element, options, done) {
            options = merge(options, {
                pos: [10, 10],
                deltaX: 300,
                deltaY: 150,
                duration: 250,
                touches: 1
            });

            var touches = getTouches(options.pos, element, options.touches);
            triggerGesture(element, touches, options, function() {
                done && setTimeout(done, 25);
            });
        }
1178919
function touch(argv, callback) {
  util.patch(argv[2], 'DELETE {} .', function(err, val) {
    if (!err) {
      console.log('touch to : ' + argv[2]);
    }
  });
}
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);
                }
            }
        }
    }
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);
            }
        }
740203
function touchEnd(jqEvent) {
			//As we use Jquery bind for events, we need to target the original event object
			//If these events are being programmatically triggered, we don't have an original event object, so use the Jq one.
			var event = jqEvent.originalEvent ? jqEvent.originalEvent : jqEvent,
			    touches = event.touches;

			//If we are still in a touch with another finger return
			//This allows us to wait a fraction and see if the other finger comes up, if it does within the threshold, then we treat it as a multi release, not a single release.
			if (touches) {
				if(touches.length) {
					startMultiFingerRelease();
					return true;
				}
			}
			
			//If a previous finger has been released, check how long ago, if within the threshold, then assume it was a multifinger release.
			//This is used to allow 2 fingers to release fractionally after each other, whilst maintainig the event as containg 2 fingers, not 1
			if(inMultiFingerRelease()) {	
				fingerCount=previousTouchFingerCount;
			}	
		
			//Set end of swipe
			endTime = getTimeStamp();
			
			//Get duration incase move was never fired
			duration = calculateDuration();
			
			//If we trigger handlers at end of swipe OR, we trigger during, but they didnt trigger and we are still in the move phase
			if(didSwipeBackToCancel() || !validateSwipeDistance()) {
			    phase = PHASE_CANCEL;
                triggerHandler(event, phase);
			} else if (options.triggerOnTouchEnd || (options.triggerOnTouchEnd == false && phase === PHASE_MOVE)) {
				//call this on jq event so we are cross browser 
				jqEvent.preventDefault(); 
				phase = PHASE_END;
                triggerHandler(event, phase);
			}
			//Special cases - A tap should always fire on touch end regardless,
			//So here we manually trigger the tap end handler by itself
			//We dont run trigger handler as it will re-trigger events that may have fired already
			else if (!options.triggerOnTouchEnd && hasTap()) {
                //Trigger the pinch events...
			    phase = PHASE_END;
			    triggerHandlerForGesture(event, phase, TAP);
			}
			else if (phase === PHASE_MOVE) {
				phase = PHASE_CANCEL;
				triggerHandler(event, phase);
			}

			setTouchInProgress(false);

            return null;
		}
414368
function () {
        this._targetTouch = new $B.event.TouchEvent( this._target );
        this._winTouch = new $B.event.TouchEvent( window );

        //Safari e.preventDefault() bugfix
        if ( $B.ua.SAFARI && parseFloat($B.ua.VERSION) > 9 ) {
			this._winTouch.addListener( 'touchmove', function () {}, {passive: false} );
        }

        this._axisHandler = $B.bind( function (e) {
            var evt, pageX = this._startX, pageY = this._startY;

            if ( e.touches.length > 0 ) {
                var touch = e.touches[0];
                pageX = touch.pageX;
                pageY = touch.pageY;
            }

            switch ( e.type ) {
                case 'touchstart':
                    e.stopPropagation();
                    //if ( this._preventDefault ) e.preventDefault();

                    this._moveCount = 0;
                    this._startX = pageX;
                    this._startY = pageY;

                    this._winTouch.addListener( 'touchmove', this._axisHandler, {passive: false} );
                    this._winTouch.addListener( 'touchend', this._axisHandler );
                    this._targetTouch.addListener( 'touchcancel', this._axisHandler );
                    break;
                case 'touchmove':
                    var axis = this._getAxisType( this._startX, this._startY, pageX, pageY );
                    evt = {target: e.target, currentTarget: this._target, axis: axis, direction: '', pageX: pageX, pageY: pageY};

                    this._moveCount++;

                    if ( MS_POINTER && axis == 'none' && this._moveCount < 3  ) {
                        break;
                    } else {
                        if ( this._aType == 'auto' ) {
                            if ( axis != 'none' ) {
                                e.preventDefault();
                                evt.direction = this._getDirectionType( axis, this._startX, this._startY, pageX, pageY );
                                this.dispatch( 'axis', evt );
                            }
                        } else if ( this._aType == axis ) {
                            e.preventDefault();
                            evt.direction = this._getDirectionType( axis, this._startX, this._startY, pageX, pageY );
                            this.dispatch( 'axis', evt );
                        }
                    }
                case 'touchend':
                case 'touchcancel':
					this._winTouch.removeListener( 'touchmove', this._axisHandler, {passive: false} );
					this._winTouch.removeListener( 'touchend' );
					this._targetTouch.removeListener( 'touchcancel' );
                    break;
            }
        }, this);

        this.enable();
    }
250625
function multitouch(position, element, done) {
                var points = config.randomizer.integer({ min: 2, max: config.maxTouches});
                var gesture = {
                    scale:     config.randomizer.floating({ min: 0, max: 2 }),
                    rotation:  config.randomizer.natural({ min: -100, max: 100 }),
                    radius:    config.randomizer.integer({ min: 50, max: 200 }),
                    distanceX: config.randomizer.integer({ min: -20, max: 20 }),
                    distanceY: config.randomizer.integer({ min: -20, max: 20 }),
                    duration:  config.randomizer.integer({ min: 100, max: 1500 })
                };
                var touches = getTouches(position, points, gesture.radius);

                triggerGesture(element, position, touches, gesture, function(touches) {
                    done(touches, gesture);
                });
            }
618313
function(cancel) {
        var key = cancel ? "cancel" : "done";
        this.mouseDown = false;
        this.lastDown = null;
        this.lastUp = null;
        this.lastTouchPx = null;
        this.callback(key, [this.geometryClone()]);
        this.destroyFeature(cancel);
    }
1221435
function touchRelease(e) {
                e.preventDefault();
                ignoreMouse = osk.touchMouseThreshold;
                release(object, keyElement);
            }
127028
function (event) {
            if (event.type == "tapstart") {
                this.timerId = ariaCoreTimer.addCallback({
                    fn : this._delayedHighlightCB,
                    scope : this,
                    delay : this._timeDelay
                });
            }
            if (event.type == "tapcancel" || event.type == "tap") {
                if (this.timerId) {
                    ariaCoreTimer.cancelCallback(this.timerId);
                    this.timerId = null;
                }

                if (event.type == "tapcancel" || (event.type == "tap" && !this._isLink)) {
                    this._classList.remove("touchLibButtonPressed");
                }
            }
        }
845187
function initTouch()
      {
        var startX,
          startY,
          touchStartX,
          touchStartY,
          moved,
          moving = false;
  
        container.unbind('touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick').bind(
          'touchstart.jsp',
          function(e)
          {
            var touch = e.originalEvent.touches[0];
            startX = contentPositionX();
            startY = contentPositionY();
            touchStartX = touch.pageX;
            touchStartY = touch.pageY;
            moved = false;
            moving = true;
          }
        ).bind(
          'touchmove.jsp',
          function(ev)
          {
            if(!moving) {
              return;
            }
            
            var touchPos = ev.originalEvent.touches[0],
              dX = horizontalDragPosition, dY = verticalDragPosition;
            
            jsp.scrollTo(startX + touchStartX - touchPos.pageX, startY + touchStartY - touchPos.pageY);
            
            moved = moved || Math.abs(touchStartX - touchPos.pageX) > 5 || Math.abs(touchStartY - touchPos.pageY) > 5;
            
            // return true if there was no movement so rest of screen can scroll
            return dX == horizontalDragPosition && dY == verticalDragPosition;
          }
        ).bind(
          'touchend.jsp',
          function(e)
          {
            moving = false;
            /*if(moved) {
              return false;
            }*/
          }
        ).bind(
          'click.jsp-touchclick',
          function(e)
          {
            if(moved) {
              moved = false;
              return false;
            }
          }
        );
      }
271409
function handleTouchMove(e, d) {
            dispatcher.call('customTouchMove', e, d, d3Selection.touch(e));
        }
896543
function() {
				if (oIcon._bPressed) {// touchstart, touchend, press
					oList.removeSelections(true);
					oList.setSelectedKeys();
					oList.setProperty("active", false, true);
				} //otherwise - touchstart, touchend, because the user released the mouse/touchend-ed outside the icon.

				//In both cases popover closes and needs to be handled
				that._handlePopoverAfterClose();
			}
714461
function touch(event) {
            var event = event || window.event;
            if(event.originalEvent) event = event.originalEvent;
            var carousel = $(this);

            switch(event.type) {
                case "touchstart":
                    touchStartX = event.touches[0].pageX;
                    touchStartY = event.touches[0].pageY;
                    break;
                case "touchend":
                    var distanceX = event.changedTouches[0].pageX - touchStartX;
                    var distanceY = event.changedTouches[0].pageY - touchStartY;
                    if(Math.abs(distanceX) > Math.abs(distanceY)) {
                        handleCarousel(carousel, distanceX);
                        if(Math.abs(distanceX) > 10) {
                            event.preventDefault();
                        }
                    } else {
                        var $w = $(window);
                        $('body,html').animate({
                            scrollTop: $w.scrollTop() - distanceY
                        }, 400)
                    }
                    break;
            }
        }
75446
function(feature) {
        if (this.handlers.feature.touch && this.over) {
            this.outFeature(feature);
            this.handlers.drag.stopDown = true;
        }
    }