我需要防止在画布内进行单次触摸。但是对于 IOS 应用程序,双/多点触控应该没有问题
请找到我的触摸事件的 JS 代码
onTouchStart: function(e, win, eventInfo) {
if(!this.config.panning) return;
if(this.config.panning == 'avoid nodes' && (this.dom? this.isLabel(e, win) : eventInfo.getNode())) return;
this.pressed = true;
this.pos = eventInfo.getPos();
var canvas = this.canvas,
ox = canvas.translateOffsetX,
oy = canvas.translateOffsetY,
sx = canvas.scaleOffsetX,
sy = canvas.scaleOffsetY;
this.pos.x *= sx;
this.pos.x += ox;
this.pos.y *= sy;
this.pos.y += oy;
},
onTouchMove: function(e, win, eventInfo) {
if(!this.config.panning) return;
if(!this.pressed) return;
if(this.config.panning == 'avoid nodes' && (this.dom? this.isLabel(e, win) : eventInfo.getNode())) return;
var thispos = this.pos,
currentPos = eventInfo.getPos(),
canvas = this.canvas,
ox = canvas.translateOffsetX,
oy = canvas.translateOffsetY,
sx = canvas.scaleOffsetX,
sy = canvas.scaleOffsetY;
currentPos.x *= sx;
currentPos.y *= sy;
currentPos.x += ox;
currentPos.y += oy;
var x = currentPos.x - thispos.x,
y = currentPos.y - thispos.y;
this.pos = currentPos;
this.canvas.translate(x * 1/sx, y * 1/sy);
},
onTouchEnd: function(e, win, eventInfo) {
if(!this.config.panning) return;
this.pressed = false;
},
onTouchCancel: function(e, win, eventInfo) {
if(!this.config.panning) return;
this.pressed = false;
}
从上面的代码中,单点触控和多点触控都已执行,但我只想在我的画布内为 IOS 应用程序执行单点触控。请指教!