在移动设备上平移然后快速捏合有时会失败,反之亦然(s8)。如何解决?

时间:2018-08-23 08:54:48

标签: hammer.js

this.hammer = new Hammer.Manager(this.canvasElement);
const pinch = new Hammer.Pinch();
const pan = new Hammer.Pan({
  threshold: 5,
});
this.hammer.add([pinch, pan]);
let initialZoom = 1;
this.hammer.on('pinchstart', (event) => {
  initialZoom = mainCamera.zoom;
});
this.hammer.on('pinchmove', (event) => {
  this.backgroundZonePointerDown = false;
  mainCamera.zoom = initialZoom * event.scale;
});
this.hammer.on('pinchend', (event) => {
  initialZoom = 1;
});
this.hammer.on('panmove', (event) => {
  this.backgroundZonePointerDown = false;
  this.pan = {x: event.deltaX * window.devicePixelRatio, y: event.deltaY * window.devicePixelRatio};
});
this.hammer.on('panend', () => {
  this.backgroundZonePointerDown = false;
  this.pan = undefined;
  this.previousPan = undefined;
});

有时我平移然后快速捏住,它无法识别平移。有时我会快速摇两次,但失败了。使用d3缩放效果完美。

0 个答案:

没有答案