[英]Polymer: Stop children from toggling mouseenter/out events
I have a Polymer component that has listeners to on-mouseenter
and on-mouseout
.我有一个 Polymer 组件,它具有on-mouseenter
和on-mouseout
侦听器。
listeners: {
mouseenter: 'mouseEnter',
mouseout: 'mouseOut',
}
and:和:
mouseEnter: function (e) {
console.log('\n\nENTER');
this.$.deleteBtn.style.display = 'block';
},
mouseOut: function (e) {
console.log('\n\nOUT');
this.$.deleteBtn.style.display = 'none';
}
Inside that are multiple other elements.里面有多个其他元素。
The issue is, that the events trigger for all child elements and not only the parent container.问题是,事件触发所有子元素,而不仅仅是父容器。 Especially the mouseout
seems to trigger multiple times.尤其是mouseout
似乎多次触发。 I only want them to be triggered when the host is entered or exited, not for all individual children.我只希望在进入或退出主机时触发它们,而不是针对所有单独的孩子。 Otherwise causes all kinds of unexpected behaviour.否则会导致各种意外行为。
This could be solved, if I didnt use the Polymer listeners, but as I would like to be consistent and have the proper scope, this is not really an option.如果我不使用 Polymer 侦听器,这可以解决,但由于我希望保持一致并具有适当的范围,因此这不是一个真正的选择。 What am I missing?我错过了什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.