问题描述
我正在按照https://konvajs.org/docs/sandbox/Gestures.html上给出的教程,在我的应用程序中包括旋转手势。但是在我的应用程序中,我还附加了“ tap”事件侦听器,因此,每当我尝试使用手势旋转形状时,都会同时发出“ tap”事件,并在一次敲击形状时发出“ tap”事件两次。 有什么方法可以防止在通过两根手指旋转手势进行旋转的同时发生“敲击”事件的现象吗? 有什么办法可以在konvajs中使用stopImmediatePropagation()?
group.on('tap',function(ev) {
console.log("tap event")
});
group.on('rotatestart',function(ev) {
oldRotation = ev.evt.gesture.rotation;
startScale = rect.scaleX();
group.stopDrag();
group.draggable(false);
text.text('rotating...');
});
group.on('rotate',function(ev) {
var delta = oldRotation - ev.evt.gesture.rotation;
group.rotate(-delta);
oldRotation = ev.evt.gesture.rotation;
group.scaleX(startScale * ev.evt.gesture.scale);
group.scaleY(startScale * ev.evt.gesture.scale);
layer.batchDraw();
});
group.on('rotateend rotatecancel',function(ev) {
text.text(defaultText);
group.draggable(true);
layer.batchDraw();
});
https://jsfiddle.net/pudio/z68nc5p3/2/
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)