[英]How do i disable a mouseout event after click with Kineticjs
我想在单击某个形状后禁用mouseout事件,并在用户单击另一个形状时将其恢复。 可能吗 ?
我的形状在这里被命名为“ parechoc”
parechoc.on('click', function() {
this.opacity(1);
layer.draw();
disable_mouseout = function (){
parechoc.off('mouseout')
}
});
parechoc.on('mouseout', function() {
this.opacity(0);
layer.draw();
});
警告:遵循未经测试的代码!
// a variable to save the last clicked shape
var myLastClickedShape;
// a function to turn on the previously 'off' node
// and turn off the currently clicked node
function onClickableClick(node){
// turn on mouseout stuff for the previously clicked node
if(myLastClickedShape){
myLastClickedShape.on('mouseout',function(){
// do mouseout stuff
});
}
// turn off mouseout for the currently clicked node
if(node){
this.off('mouseout');
}
myLastClickedShape=node;
}
// call the toggle function as required
parechoc.on('click', function() {
onClickableClick(this);
this.opacity(1);
layer.draw();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.