Safari Mac上的Mouseleave事件在错误的条件下触发

发布于 2025-01-27 15:11:10 字数 1488 浏览 4 评论 0原文

根据

https:> https://developer.mozilla.org/en--en---/en----/en---g en--en--- us/doc/web/api/element/mouseleave_event

当指针退出元素及其所有后代时,

穆斯莱尔(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,显示问题:

https://i.sstatic.net/h8j0f.jpg

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:

https://i.sstatic.net/H8j0F.jpg

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十年九夏 2025-02-03 15:11:10

它似乎与tigervnc使用有关。切换到Ultravnc解决了问题。

It seems to be related to TigerVNC usage. Switching to UltraVNC resolved the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文