3

The touchmove event detects every slide along the screen, but when I use two fingers and do pinch gesture it fires only once. So when I try to zoom something, It only zooms at each gesture, not continuous. Is this the normal behaviour? It is Angular 4, here is the code:

  <pdf-viewer (touchstart)="zoomStart($event)"  (touchmove)="zoomMove($event)"  (touchend)="zoomEnd($event)"  [zoom]="zoom" [src]="pdfSrc" id="pdfObj"  [render-text]="false" style="display: block;margin-top:5px" [fit-to-page]="true" [original-size]="false"></pdf-viewer>

Functions:

  zoomStart(e) {
    if (e.touches.length === 2) {
      console.log(event);
      event.preventDefault();
      this.scaling = true;
      this.pinchStart(e);
    }
  }
  zoomEnd(e) {
    console.log('END');
    this.scaling = false;
  }
  zoomMove(e) {
    console.log(event);
    if (this.scaling && e.touches.length === 2) {
      console.log('TWO');
      event.preventDefault();
      var dist = Math.hypot(
        e.touches[0].screenX - e.touches[1].screenX,
        e.touches[0].screenY - e.touches[1].screenY);

      if (dist >= this.fingerDistance)
        this.zoom += 0.5;
      else {
        if (this.zoom <= 1)
          return;
        this.zoom -= 0.5;
      }

    }
  }
  pinchStart(e) {
    this.fingerDistance = Math.hypot(
      e.touches[0].screenX - e.touches[1].screenX,
      e.touches[0].screenY - e.touches[1].screenY);
  }
skyboyer
  • 22,209
  • 7
  • 57
  • 64
AlvaroCryptogram
  • 398
  • 3
  • 16

0 Answers0