core/src/ons/gesture-detector.js
function doDetect(ev, eventType, element, handler) {
    var touchList = this.getTouchList(ev, eventType);
    var touchListLength = touchList.length;
    var triggerType = eventType;
    var triggerChange = touchList.trigger; // used by fakeMultitouch plugin
    var changedLength = touchListLength;

    // at each touchstart-like event we want also want to trigger a TOUCH event...
    if (eventType == EVENT_START) {
      triggerChange = EVENT_TOUCH;
      // ...the same for a touchend-like event
    } else if (eventType == EVENT_END) {
      triggerChange = EVENT_RELEASE;

      // keep track of how many touches have been removed
      changedLength = touchList.length - ((ev.changedTouches) ? ev.changedTouches.length : 1);
    }

    // after there are still touches on the screen,
    // we just want to trigger a MOVE event. so change the START or END to a MOVE
    // but only after detection has been started, the first time we actually want a START
    if (changedLength > 0 && this.started) {
      triggerType = EVENT_MOVE;
    }

    // detection has been started, we keep track of this, see above
    this.started = true;

    // generate some event data, some basic information
    var evData = this.collectEventData(element, triggerType, touchList, ev);

    // trigger the triggerType event before the change (TOUCH, RELEASE) events
    // but the END event should be at last
    if (eventType != EVENT_END) {
      handler.call(Detection, evData);
    }

    // trigger a change (TOUCH, RELEASE) event, this means the length of the touches changed
    if (triggerChange) {
      evData.changedLength = changedLength;
      evData.eventType = triggerChange;

      handler.call(Detection, evData);

      evData.eventType = triggerType;
      delete evData.changedLength;
    }

    // trigger the END event
    if (triggerType == EVENT_END) {
      handler.call(Detection, evData);

      // ...and we are done with the detection
      // so reset everything to start each detection totally fresh
      this.started = false;
    }

    return triggerType;
  }
function doDetect(ev, eventType, element, handler) {
    var touchList = this.getTouchList(ev, eventType);
    var touchListLength = touchList.length;
    var triggerType = eventType;
    var triggerChange = touchList.trigger; // used by fakeMultitouch plugin
    var changedLength = touchListLength;

    // at each touchstart-like event we want also want to trigger a TOUCH event...
    if (eventType == EVENT_START) {
      triggerChange = EVENT_TOUCH;
      // ...the same for a touchend-like event
    } else if (eventType == EVENT_END) {
      triggerChange = EVENT_RELEASE;

      // keep track of how many touches have been removed
      changedLength = touchList.length - ((ev.changedTouches) ? ev.changedTouches.length : 1);
    }

    // after there are still touches on the screen,
    // we just want to trigger a MOVE event. so change the START or END to a MOVE
    // but only after detection has been started, the first time we actually want a START
    if (changedLength > 0 && this.started) {
      triggerType = EVENT_MOVE;
    }

    // detection has been started, we keep track of this, see above
    this.started = true;

    // generate some event data, some basic information
    var evData = this.collectEventData(element, triggerType, touchList, ev);

    // trigger the triggerType event before the change (TOUCH, RELEASE) events
    // but the END event should be at last
    if (eventType != EVENT_END) {
      handler.call(Detection, evData);
    }

    // trigger a change (TOUCH, RELEASE) event, this means the length of the touches changed
    if (triggerChange) {
      evData.changedLength = changedLength;
      evData.eventType = triggerChange;

      handler.call(Detection, evData);

      evData.eventType = triggerType;
      delete evData.changedLength;
    }

    // trigger the END event
    if (triggerType == EVENT_END) {
      handler.call(Detection, evData);

      // ...and we are done with the detection
      // so reset everything to start each detection totally fresh
      this.started = false;
    }

    return triggerType;
  }
function doDetect ( ev , eventType , element , handler ) { var touchList = this . getTouchList ( ev , eventType ) ; var touchListLength = touchList . length ; var triggerType = eventType ; var triggerChange = touchList . trigger ; // used by fakeMultitouch plugin var changedLength = touchListLength ; // at each touchstart-like event we want also want to trigger a TOUCH event... if ( eventType == EVENT_START ) { triggerChange = EVENT_TOUCH ; // ...the same for a touchend-like event } else if ( eventType == EVENT_END ) { triggerChange = EVENT_RELEASE ; // keep track of how many touches have been removed changedLength = touchList . length - ( ( ev . changedTouches ) ? ev . changedTouches . length : 1 ) ; } // after there are still touches on the screen, // we just want to trigger a MOVE event. so change the START or END to a MOVE // but only after detection has been started, the first time we actually want a START if ( changedLength > 0 && this . started ) { triggerType = EVENT_MOVE ; } // detection has been started, we keep track of this, see above this . started = true ; // generate some event data, some basic information var evData = this . collectEventData ( element , triggerType , touchList , ev ) ; // trigger the triggerType event before the change (TOUCH, RELEASE) events // but the END event should be at last if ( eventType != EVENT_END ) { handler . call ( Detection , evData ) ; } // trigger a change (TOUCH, RELEASE) event, this means the length of the touches changed if ( triggerChange ) { evData . changedLength = changedLength ; evData . eventType = triggerChange ; handler . call ( Detection , evData ) ; evData . eventType = triggerType ; delete evData . changedLength ; } // trigger the END event if ( triggerType == EVENT_END ) { handler . call ( Detection , evData ) ; // ...and we are done with the detection // so reset everything to start each detection totally fresh this . started = false ; } return triggerType ; }
the core detection method
this finds out what GestureDetector-touch-events to trigger
@param {Object} ev
@param {String} eventType matches `EVENT_START|MOVE|END`
@param {HTMLElement} element
@param {Function} handler
@return {String} triggerType matches `EVENT_START|MOVE|END`
the core detection method this finds out what GestureDetector - touch - events to trigger