Skip to content

Instantly share code, notes, and snippets.

@tai2
Created July 26, 2017 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tai2/94fff6b5d417933c5a3de0900246e1f6 to your computer and use it in GitHub Desktop.
Save tai2/94fff6b5d417933c5a3de0900246e1f6 to your computer and use it in GitHub Desktop.
mouseleave is not fired while dragging
<html>
<head>
<style>
.parent {
width: 300px;
height: 300px;
background: black;
padding: 100px;
}
.draggable {
width: 300px;
height: 300px;
background: blue;
}
</style>
</head>
<body>
<div id="parent" class="parent">
<div class="draggable" draggable="true">Draggable Item</div>
</div>
<script>
document.getElementById('parent').addEventListener('mouseenter', (ev) => {
console.log('mouseenter');
ev.target.style.background = 'red';
});
document.getElementById('parent').addEventListener('mouseleave', (ev) => {
console.log('mouseleave');
ev.target.style.background = 'black';
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment