Parse events generate by gesture library.
gestureOpenSlice and gestureCloseSlice are two common
functions to store the begin time and end time for all
events in gesture library
196975
function(title, ts, opt_args) {
      var thread = this.importer.getOrCreatePseudoThread('gesture').thread;
      thread.sliceGroup.beginSlice(
          'touchpad_gesture', title, ts, opt_args);
    }
1299391
function(sType, oEvent) {

			if (!bHandleEvent) {
				return;
			}

			// we need mapping of the different event types to get the correct target
			var oMappedEvent = oEvent.type == "touchend" ? oEvent.changedTouches[0] : oEvent.touches[0];

			// create the synthetic event
			var newEvent = oDocument.createEvent('MouseEvent'); // trying to create an actual TouchEvent will create an error
			newEvent.initMouseEvent(sType, true, true, window, oEvent.detail,
				oMappedEvent.screenX, oMappedEvent.screenY, oMappedEvent.clientX, oMappedEvent.clientY,
				oEvent.ctrlKey, oEvent.shiftKey, oEvent.altKey, oEvent.metaKey,
				oEvent.button, oEvent.relatedTarget);

			newEvent.isSynthetic = true;

			// Timeout needed. Do not interrupt the native event handling.
			window.setTimeout(function() {
				oTarget.dispatchEvent(newEvent);
			}, 0);
		}
807924
function (oEvent) {

			// both xml and html view write this ui5 internal property for the serializer
			if (oEvent.fFunction && oEvent.fFunction._sapui_handlerName) {
				var sHandlerName = oEvent.fFunction._sapui_handlerName;

				// double check that the function is on the controller
				var oController = oView.getController();
				if (oController[sHandlerName] || sap.ui.getCore().getConfiguration().getControllerCodeDeactivated()) {
					return sHandlerName;
				}
			}
			// TODO: ITERARTE OVER HANDLERS AND CHECK THE EVENT FUNCTION
			// NOTE: JQUERY GUID WON'T WORK AS THE GUID WILL BE SAVED AT THE CLOSURED FUNCTION AS WELL
			// WHEN THE FUNCTION IS REUSED FOR SEVERAL HANDLERS WE WILL LOSE THE INFORMATION
			/*for (var sHandler in oController) {
				if (oController[sHandler] === oEvent.fFunction) {
					return sHandler;
				}
			}*/
		}
319277
function normalizeEvent(event) {
       var pointer; // PointerEvent or standard Mouse event

       if (me.device.TouchEvent && event.changedTouches) {
         // iOS/Android Touch event
         for (var i = 0, l = event.changedTouches.length; i < l; i++) {
           var touchEvent = event.changedTouches[i];
           pointer = T_POINTERS.pop();
           pointer.setEvent(event, touchEvent.pageX, touchEvent.pageY, touchEvent.clientX, touchEvent.clientY, touchEvent.identifier);
           normalizedEvents.push(pointer);
         }
       } else {
         // Mouse or PointerEvent
         pointer = T_POINTERS.pop();
         pointer.setEvent(event, event.pageX, event.pageY, event.clientX, event.clientY, event.pointerId);
         normalizedEvents.push(pointer);
       } // if event.isPrimary is defined and false, return


       if (event.isPrimary === false) {
         return normalizedEvents;
       } // else use the first entry to simulate mouse event


       normalizedEvents[0].isPrimary = true;
       Object.assign(api.pointer, normalizedEvents[0]);
       return normalizedEvents;
     }
629899
def flick_between(query_from, query_to, options={})
      ensure_query_class_or_nil(query_from)
      ensure_query_class_or_nil(query_to)

      gesture_options = options.dup

      gesture_options[:timeout] ||= Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT

      _flick_between(query_from, query_to, gesture_options)
    end
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)
}
1294491
function triggerGesture(elements, startTouches, options, done) {
        var interval = 10,
            loops = Math.ceil(options.duration / interval),
            loop = 1;

        elements = ensureAnArray(elements);

        options = merge(options, {
            pos: [10, 10],
            duration: 250,
            touches: 1,
            deltaX: 0,
            deltaY: 0,
            radius: 100,
            scale: 1,
            rotation: 0,
            easing: 'swing'
        });

        function gestureLoop() {
            // calculate the radius
            // this is for scaling and multiple touches
            var radius = options.radius;
            if (options.scale !== 1) {
                radius = options.radius - (options.radius * (1 - options.scale) * (1 / loops * loop));
            }

            // calculate new position/rotation
            var easing = Simulator.easings[options.easing](1 / loops * loop),
                posX = options.pos[0] + (options.deltaX / loops * loop) * easing,
                posY = options.pos[1] + (options.deltaY / loops * loop) * easing,
                rotation = options.rotation / loops * loop,
                touches = getTouches([posX, posY], elements, startTouches.length, radius, rotation),
                isFirst = (loop == 1),
                isLast = (loop == loops);

            for (var t = touches.length - 1; t >= 0; t--) {
                if (isFirst) {
                    trigger(touches, touches[t].target, 'start');
                } else if (isLast) {
                    trigger(touches, touches[t].target, 'end');

                    // Remove processed touch
                    touches.pop()

                    if (touches.length === 0) {
                        return done();
                    }
                } else {
                    trigger(touches, touches[t].target, 'move');
                }
            }

            setTimeout(gestureLoop, interval);
            loop++;
        }
        gestureLoop();
    }
1184750
function onEvent(event) {
    if (event.eventType == nuimotion.Events.GESTURE) {
        console.log("Gesture: " + event.gestureType + " Hand: " + event.hand + " State: " + event.step);
    } else {
        console.log("Event: " + event.eventType);
    }
}
329387
function(evt)
		{
			var state = null;
			
			// Workaround for touch events which started on some DOM node
			// on top of the container, in which case the cells under the
			// mouse for the move and up events are not detected.
			if (mxClient.IS_TOUCH)
			{
				var x = mxEvent.getClientX(evt);
				var y = mxEvent.getClientY(evt);
				
				// Dispatches the drop event to the graph which
				// consumes and executes the source function
				var pt = mxUtils.convertPoint(container, x, y);
				state = graph.view.getState(graph.getCellAt(pt.x, pt.y));
			}
			
			return state;
		}
818228
function begin_gesture(e) {
        var touch = e.touches[0];
        gesture_in_progress = true;
        gesture_start_x = touch.clientX;
        gesture_start_y = touch.clientY;
    }
88339
function startDetect(inst, eventData) {
    // already busy with a GestureDetector.gesture detection on an element
    if (this.current) {
      return;
    }

    this.stopped = false;

    // holds current session
    this.current = {
      inst: inst, // reference to GestureDetectorInstance we're working for
      startEvent: Utils.extend({}, eventData), // start eventData for distances, timing etc
      lastEvent: false, // last eventData
      lastCalcEvent: false, // last eventData for calculations.
      futureCalcEvent: false, // last eventData for calculations.
      lastCalcData: {}, // last lastCalcData
      name: '' // current gesture we're in/detected, can be 'tap', 'hold' etc
    };

    this.detect(eventData);
  }
954836
def findClosestMatchingGesture(strokes, gestureList, maxDifference=None):
    
    if len(gestureList) == 0:
        return None

    #gestureList = [list(frozenset(tuple(gesture))) for gesture in gestureList] # make a unique list
    gestureList = frozenset([tuple(gesture) for gesture in gestureList])
    distances = {}
    for g in gestureList:
        levDist = levenshteinDistance(strokes, g)
        if maxDifference is None or levDist <= maxDifference:
            distances.setdefault(levDist, [])
            distances[levDist].append(g)

    if not distances:
        return None # No matching gestures are within the tolerance of maxDifference.

    return tuple(distances[min(distances.keys())])
1361156
function getTouchList(ev, eventType) {
    // get the fake pointerEvent touchlist
    if (GestureDetector.HAS_POINTEREVENTS) {
      return PointerEvent.getTouchList();
    }

    // get the touchlist
    if (ev.touches) {
      if (eventType == EVENT_MOVE) {
        return ev.touches;
      }

      var identifiers = [];
      var concat = [].concat(Utils.toArray(ev.touches), Utils.toArray(ev.changedTouches));
      var touchList = [];

      Utils.each(concat, function(touch) {
        if (Utils.inArray(identifiers, touch.identifier) === -1) {
          touchList.push(touch);
        }
        identifiers.push(touch.identifier);
      });

      return touchList;
    }

    // make fake touchList from mouse position
    ev.identifier = 1;
    return [ev];
  }
44249
function(sortedInputEvents) {
      var protoIRs = [];
      var currentPIR = undefined;
      var sawFirstUpdate = false;
      var modelBounds = this.model.bounds;
      forEventTypesIn(sortedInputEvents, PINCH_TYPE_NAMES, function(event) {
        switch (event.typeName) {
          case INPUT_TYPE.PINCH_BEGIN:
            if (currentPIR &&
                currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS)) {
              currentPIR.pushEvent(event);
              break;
            }
            currentPIR = new ProtoIR(ProtoIR.RESPONSE_TYPE, PINCH_IR_NAME);
            currentPIR.pushEvent(event);
            protoIRs.push(currentPIR);
            sawFirstUpdate = false;
            break;

          case INPUT_TYPE.PINCH_UPDATE:
            // Like ScrollUpdates, the Begin and the first Update constitute a
            // Response, then the rest of the Updates constitute an Animation
            // that begins when the Response ends. If the user pauses in the
            // middle of an extended pinch gesture, then multiple Animations
            // will be created.
            if (!currentPIR ||
                ((currentPIR.irType === ProtoIR.RESPONSE_TYPE) &&
                 sawFirstUpdate) ||
                !currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS)) {
              currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, PINCH_IR_NAME);
              currentPIR.pushEvent(event);
              protoIRs.push(currentPIR);
            } else {
              currentPIR.pushEvent(event);
              sawFirstUpdate = true;
            }
            break;

          case INPUT_TYPE.PINCH_END:
            if (currentPIR) {
              currentPIR.pushEvent(event);
            } else {
              var pir = new ProtoIR(ProtoIR.IGNORED_TYPE);
              pir.pushEvent(event);
              protoIRs.push(pir);
            }
            currentPIR = undefined;
            break;
        }
      });
      return protoIRs;
    }
1056167
function(evt) {
        if (debug) { timedLog("endmark"); }
        if(evt.touches && evt.touches.length > 0) {
          if (handlers.endSecondFinger(evt)) {
            return;
          }
        }
        if (debug) { timedLog("endmark - continued"); }
        mark = copy(positionable.state);
        var modified = transform.modified;
        transform = resetTransform();

        // Only fire a tap if it's under the threshold
        if (tapDiff < MAX_TAP_THRESHOLD && (new Date() - tapStart.timeStart <= tapDuration) && positionable.onTap) {
          positionable.setState({touchactive: false}, function() {
            if(positionable.onTap){
              positionable.onTap();
            }
          });
          return;
        }
        // Reset
        tapDiff = 0;
        positionable.setState({ touchactive: false }, function() {
          if (positionable.onTouchEnd) {
            positionable.onTouchEnd(modified);
          }
        });
      }
946807
function(element, type, handler) {
        var touches = this._msTouches;

        var cb = function(e) {

            var alreadyInArray = false;
            for (var i=0, ii=touches.length; i<ii; ++i) {
                if (touches[i].pointerId == e.pointerId) {
                    alreadyInArray = true;
                    break;
                }
            }
            if (!alreadyInArray) {
                touches.push(e);
            }

            e.touches = touches.slice();
            handler(e);
        };

        OpenLayers.Event.observe(element, 'MSPointerDown', cb);

        // Need to also listen for end events to keep the _msTouches list
        // accurate
        var internalCb = function(e) {
            for (var i=0, ii=touches.length; i<ii; ++i) {
                if (touches[i].pointerId == e.pointerId) {
                    touches.splice(i, 1);
                    break;
                }
            }
        };
        OpenLayers.Event.observe(element, 'MSPointerUp', internalCb);
    }
804383
function getEventPosition(event) {
    let _event = event
    if (event.touches) {
        [_event] = event.touches
    }
    return [
        _event.pageX - window.pageXOffset,
        _event.pageY - window.pageYOffset
    ]
}