touchmove事件会检测屏幕上的每张幻灯片,但是当我使用两根手指并进行捏合手势时,它只会触发一次。因此,当我尝试缩放某些内容时,它只会缩放每个手势,而不是连续。这是正常行为吗? 它是Angular 4,这是代码:
<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>
功能:
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);
}