lundi 21 janvier 2019

Weird performace about mouseleave event in web browser

when I click a dom element quikly , its mouseleave event will be triggered sometimes not everytime. I am sure I do not make the mouse leave the element.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    .outer{
      width: 500px;
      height: 500px;
      background: #f00;
    }
  </style>
</head>
<body>
<div class="outer">
</div>
<script>
  const outer = document.querySelector('.outer');

  outer.addEventListener('mouseleave',function () {
    console.log('mouseleave')
  })
</script>
</body>
</html>

I expect trigger the mouseleave event only when the mouse leave the element.




Aucun commentaire:

Enregistrer un commentaire