引擎版本2.0.5
node.on("touchstart", function( event ){ event.stopPropagationImmediate() }, this, true);
这个阶段stopPropagation是无效的是么?还是可以继续传递
引擎版本2.0.5
node.on("touchstart", function( event ){ event.stopPropagationImmediate() }, this, true);
这个阶段stopPropagation是无效的是么?还是可以继续传递
立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。
我可能遇到一个比较神奇的现象(在我目前看来),我整理整理demo
const BlockEvents = [
'touchstart', 'touchmove', 'touchend', 'touchcancel',
'mousedown', 'mousemove', 'mouseup',
'mouseenter', 'mouseleave', 'mousewheel'
];
cc.Class({
extends: cc.Component,
properties: {
A: cc.Node,
B: cc.Node
},
onLoad: function () {
// canvas 监听事件
for (var i = 0; i < BlockEvents.length; i++) {
this.node.on(BlockEvents[i], function (event) {
event.stopPropagationImmediate()
}, this, true);
}
// A监听事件
this.A.on("touchstart", function () {
console.log("touchstart A");
}, this);
this.A.on("touchend", function () {
console.log("touchend A");
}, this);
// B监听事件
this.B.on("touchstart", function () {
console.log("touchstart B");
}, this);
this.B.on("touchend", function () {
console.log("touchend B");
}, this);
},
});
脚本绑在canvas上
点击A,A没有响应事件,感觉好像是对的
点击B,B没有相应事件,但是A响应事件了
这个是BUG还是什么,我应该怎么理解触摸的传递机制?
我试试看看什么情况。
使用这个接口吧,stopPropagation
stopPropagationImmediate 这个接口并没有继承 stopPropagation,我反馈一下。
好1234
手机上,在scrollview里的stopPropagationImmediate不起作用
提供个demo,我看下你的逻辑。