onTouch_(event) {
    if (!this.pinchStartEvent_)
      return;

    let lastEvent = /** @type {!TouchEvent} */ (this.lastEvent_);

    // Check if the pinch ends with the current event.
    if (event.touches.length < 2 ||
        lastEvent.touches.length !== event.touches.length) {
      let startScaleRatio =
          GestureDetector.pinchScaleRatio_(lastEvent, this.pinchStartEvent_);
      let center = GestureDetector.center_(lastEvent);
      let endEvent = {
        type: 'pinchend',
        startScaleRatio: startScaleRatio,
        center: center
      };
      this.pinchStartEvent_ = null;
      this.lastEvent_ = null;
      this.notify_(endEvent);
      return;
    }

    // We must preventDefault two finger touchmoves. By doing so native
    // pinch-zoom does not interfere with our way of handling the event.
    event.preventDefault();

    let scaleRatio = GestureDetector.pinchScaleRatio_(event, lastEvent);
    let startScaleRatio =
        GestureDetector.pinchScaleRatio_(event, this.pinchStartEvent_);
    let center = GestureDetector.center_(event);
    this.notify_({
      type: 'pinchupdate',
      scaleRatio: scaleRatio,
      direction: scaleRatio > 1.0 ? 'in' : 'out',
      startScaleRatio: startScaleRatio,
      center: center
    });

    this.lastEvent_ = event;
  }
/**
   * The callback for touch move, end, and cancel events on the element.
   *
   * @param {!TouchEvent} event Touch event on the element.
   * @private
   */
The callback for touch move, end, and cancel events on the element.
@param {!TouchEvent} event Touch event on the element.
@private
The callback for touch move end and cancel events on the element . @param { !TouchEvent } event Touch event on the element . @private
onTouch_(event) {
    if (!this.pinchStartEvent_)
      return;
    let lastEvent =  (this.lastEvent_);
    if (event.touches.length < 2 ||
        lastEvent.touches.length !== event.touches.length) {
      let startScaleRatio =
          GestureDetector.pinchScaleRatio_(lastEvent, this.pinchStartEvent_);
      let center = GestureDetector.center_(lastEvent);
      let endEvent = {
        type: 'pinchend',
        startScaleRatio: startScaleRatio,
        center: center
      };
      this.pinchStartEvent_ = null;
      this.lastEvent_ = null;
      this.notify_(endEvent);
      return;
    }
    event.preventDefault();
    let scaleRatio = GestureDetector.pinchScaleRatio_(event, lastEvent);
    let startScaleRatio =
        GestureDetector.pinchScaleRatio_(event, this.pinchStartEvent_);
    let center = GestureDetector.center_(event);
    this.notify_({
      type: 'pinchupdate',
      scaleRatio: scaleRatio,
      direction: scaleRatio > 1.0 ? 'in' : 'out',
      startScaleRatio: startScaleRatio,
      center: center
    });
    this.lastEvent_ = event;
  }
onTouch_ ( event ) { if ( ! this . pinchStartEvent_ ) return ; let lastEvent = ( this . lastEvent_ ) ; if ( event . touches . length < 2 || lastEvent . touches . length !== event . touches . length ) { let startScaleRatio = GestureDetector . pinchScaleRatio_ ( lastEvent , this . pinchStartEvent_ ) ; let center = GestureDetector . center_ ( lastEvent ) ; let endEvent = { type : 'pinchend' , startScaleRatio : startScaleRatio , center : center } ; this . pinchStartEvent_ = null ; this . lastEvent_ = null ; this . notify_ ( endEvent ) ; return ; } event . preventDefault ( ) ; let scaleRatio = GestureDetector . pinchScaleRatio_ ( event , lastEvent ) ; let startScaleRatio = GestureDetector . pinchScaleRatio_ ( event , this . pinchStartEvent_ ) ; let center = GestureDetector . center_ ( event ) ; this . notify_ ( { type : 'pinchupdate' , scaleRatio : scaleRatio , direction : scaleRatio > 1.0 ? 'in' : 'out' , startScaleRatio : startScaleRatio , center : center } ) ; this . lastEvent_ = event ; }
The callback for touch move, end, and cancel events on the element.
The callback for touch move end and cancel events on the element .
/** @type {!TouchEvent} */ // Check if the pinch ends with the current event. // We must preventDefault two finger touchmoves. By doing so native // pinch-zoom does not interfere with our way of handling the event.