Safari Mac上的Mouseleave事件在错误的条件下触发
根据
当指针退出元素及其所有后代时,
穆斯莱尔(Mouseleave)被解雇。但是,在Safari上,鼠标进入元素并将其内部移动后,就会发射此事件。我创建了一个小提琴
document.getElementById('out').addEventListener('mouseleave', () => console.log('left'));
.outer {
width: 100px;
height: 100px;
background-color: green;
}
.inner {
width: 50px;
height: 50px;
background-color: red;
}
<div class="outer" id="out">
<div class="inner">
</div>
</div>
https://jsfiddle.net/hs5ea7cq/
document.getElementById('out').addEventListener('mouseleave', () => console.log('left'));
在Chrome上,在Chrome上,Mac上的Firefox在Mac上的工作原理。但是,野生动物园即使不应该发出慕斯。
我能做些什么可以在野生动物园中与Chrome或Firefox相同的行为?
编辑:
我创建了一个GIF,显示问题:
according to
https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseleave_event
mouseleave is fired when the pointer has exited the element and all of its descendants.
However, on Safari this event is fired as soon the mouse enters the element and is moved inside of it. I created a fiddle
document.getElementById('out').addEventListener('mouseleave', () => console.log('left'));
.outer {
width: 100px;
height: 100px;
background-color: green;
}
.inner {
width: 50px;
height: 50px;
background-color: red;
}
<div class="outer" id="out">
<div class="inner">
</div>
</div>
https://jsfiddle.net/hs5ea7cq/
document.getElementById('out').addEventListener('mouseleave', () => console.log('left'));
On Chrome, FireFox on Mac it works as it should. However, Safari emits mouseleave even so it should not.
Is there anything I can do to get the same behavior in Safari as in Chrome or FireFox?
EDIT:
I created a GIF which shows the issue:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它似乎与tigervnc使用有关。切换到Ultravnc解决了问题。
It seems to be related to TigerVNC usage. Switching to UltraVNC resolved the issue.