简体   繁体   English

隐藏元素时未触发 HostListener mouseLeave 和 pointerLeave

[英]HostListener mouseLeave and pointerLeave not triggered when element is hidden

I'm sitting with a problem where I use the following 2 hostlisteners to call a close function on a element.我遇到了一个问题,我使用以下 2 个主机监听器在一个元素上调用关闭 function。

@HostListener(
        'pointerleave',
    )
@HostListener(
    'mouseleave',
)

The problem is, the icon it mouseleaves or pointerleaves, is a icon that is shown on hover of another element and hidden when no longer hovering, fixed with css.问题是,它mouseleaves或pointerleaves的图标,是在另一个元素的hover上显示的图标,不再悬停时隐藏,用css修复。

My assumption is that if you leave the element fast enough, the display:none is set which will make the hostlisteners not called anymore, so the close function is no longer called.我的假设是,如果您离开元素的速度足够快,则 display:none 已设置,这将使主机侦听器不再被调用,因此不再调用 close function。

Anyone has a fix for this?有人对此有解决办法吗?

Turned out to have pointer-events:none;原来有pointer-events:none; on the css somewhere which breaks this!在 css 某处打破了这个!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM