B2G/gecko/accessible/src/jsat/TouchAdapter.jsm
/**
   * Compile a gesture from an individual touch point. This is used by the
   * TouchAdapter to compound multiple single gestures in to higher level
   * gestures.
   */
Compile a gesture from an individual touch point. This is used by the
TouchAdapter to compound multiple single gestures in to higher level
gestures.
Compile a gesture from an individual touch point . This is used by the TouchAdapter to compound multiple single gestures in to higher level gestures .
function TouchPoint_compile(aTime) {
    let directDistance = this.directDistanceTraveled;
    let duration = aTime - this.startTime;
    if ((this.distanceTraveled / this.dpi) < TouchAdapter.TAP_MAX_RADIUS) { 
      if (duration < TouchAdapter.DWELL_THRESHOLD) {
        this.finish();
        return {type: 'tap', x: this.startX, y: this.startY};
      } else if (!this.done && duration == TouchAdapter.DWELL_THRESHOLD) {
        return {type: 'dwell', x: this.startX, y: this.startY};
      }
    }
    if (duration <= TouchAdapter.SWIPE_MAX_DURATION && 
        (directDistance / this.dpi) >= TouchAdapter.SWIPE_MIN_DISTANCE && 
        (directDistance * 1.2) >= this.distanceTraveled) { 
      let swipeGesture = {x1: this.startX, y1: this.startY,
                          x2: this.x, y2: this.y};
      let deltaX = this.x - this.startX;
      let deltaY = this.y - this.startY;
      if (Math.abs(deltaX) > Math.abs(deltaY)) {
        if (deltaX > 0)
          swipeGesture.type = 'swiperight';
        else
          swipeGesture.type = 'swipeleft';
      } else if (Math.abs(deltaX) < Math.abs(deltaY)) {
        if (deltaY > 0)
          swipeGesture.type = 'swipedown';
        else
          swipeGesture.type = 'swipeup';
      } else {
          return null;
      }
      this.finish();
      return swipeGesture;
    }
    if (!this.done &&
        duration > TouchAdapter.SWIPE_MAX_DURATION &&
        (this.distanceTraveled / this.dpi) > TouchAdapter.TAP_MAX_RADIUS) {
      return {type: 'explore', x: this.x, y: this.y};
    }
    return null;
  }
function TouchPoint_compile ( aTime ) { let directDistance = this . directDistanceTraveled ; let duration = aTime - this . startTime ; if ( ( this . distanceTraveled / this . dpi ) < TouchAdapter . TAP_MAX_RADIUS ) { if ( duration < TouchAdapter . DWELL_THRESHOLD ) { this . finish ( ) ; return { type : 'tap' , x : this . startX , y : this . startY } ; } else if ( ! this . done && duration == TouchAdapter . DWELL_THRESHOLD ) { return { type : 'dwell' , x : this . startX , y : this . startY } ; } } if ( duration <= TouchAdapter . SWIPE_MAX_DURATION && ( directDistance / this . dpi ) >= TouchAdapter . SWIPE_MIN_DISTANCE && ( directDistance * 1.2 ) >= this . distanceTraveled ) { let swipeGesture = { x1 : this . startX , y1 : this . startY , x2 : this . x , y2 : this . y } ; let deltaX = this . x - this . startX ; let deltaY = this . y - this . startY ; if ( Math . abs ( deltaX ) > Math . abs ( deltaY ) ) { if ( deltaX > 0 ) swipeGesture . type = 'swiperight' ; else swipeGesture . type = 'swipeleft' ; } else if ( Math . abs ( deltaX ) < Math . abs ( deltaY ) ) { if ( deltaY > 0 ) swipeGesture . type = 'swipedown' ; else swipeGesture . type = 'swipeup' ; } else { return null ; } this . finish ( ) ; return swipeGesture ; } if ( ! this . done && duration > TouchAdapter . SWIPE_MAX_DURATION && ( this . distanceTraveled / this . dpi ) > TouchAdapter . TAP_MAX_RADIUS ) { return { type : 'explore' , x : this . x , y : this . y } ; } return null ; }
Compile a gesture from an individual touch point.
Compile a gesture from an individual touch point .
// To be considered a tap/dwell... // Didn't travel // Mark it as done so we don't use this touch for another gesture. // To be considered a swipe... // Quick enough // Traveled far // Direct enough // Horizontal swipe. // Vertical swipe. // A perfect 45 degree swipe?? Not in our book. // To be considered an explore...