일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- es6
- css:position
- node
- dotenv
- addEventListener
- react
- innerHTML
- beforeinput
- keyup
- textContent
- for loop
- ES5
- Empty
- Review
- node.js
- Temporal dead zone
- nodeValue
- HTML
- js
- javascript
- keyboardEvent
- Event
- innerText
- yet
- CSS
- UI
- modal
- Dom
- a11y
- TypingEffect
- Today
- Total
the murmurous sea
DOM Events: mouseover/out & mouseenter/leave 본문
Events mouseover/mouseout, relatedTarget
:These events are special, because they have property relatedTarget
If we don’t examine event.target inside the handlers, then it may seem that the mouse pointer left #parent element, and then immediately came back over it. But that’s not the case! The pointer is still over the parent, it just moved deeper into the child element. |
mouseover event
: occurs when a mouse pointer comes over an element.
: The mouseover event on a descendant bubbles up. So, if #parent has mouseover handler, it triggers.
event.target
: is the element where the mouse came over.
event.relatedTarget
: When a mouse leaves one element for another, one of them becomes target, and the other one – relatedTarget.
: is the element from which the mouse came (relatedTarget → target).
mouseout
: occurs when a mouse pointer leaves after mouseover event.
: triggers when the pointer moves from an element to its descendant(parent el to child)
The reverse of mouseover:
event.target
: is the element that the mouse left.
event.relatedTarget
: is the new under-the-pointer element, that mouse left for (target → relatedTarget).
The relatedTarget property can be null. |
mousemove
: triggers when the mouse moves.
: Fast mouse move may skip intermediate elements.
- The browser checks the mouse position from time to time. And if it notices changes then triggers the events.
- If the visitor is moving the mouse very fast then some DOM-elements may be skipped.
If mouseover triggered, there must be mouseout |
Events mouseenter and mouseleave
: trigger when the mouse pointer enters/leaves the element.
: differences from mouseover/mouseout is;
1. Transitions inside the element, to/from descendants, are not counted.
: only generated events are the ones related to moving the pointer in and out of the top element.
Nothing happens when the pointer goes to the child and back. Transitions between descendants are ignored.
2. Events mouseenter/mouseleave do not bubble.
: so can’t use event delegation.
mouseenter
: triggers when the pointer enters an element.
: The exact location of the pointer inside the element or its descendants doesn’t matter.
mouseleave
: triggers when the pointer leaves an element
https://javascript.info/mousemove-mouseover-mouseout-mouseenter-mouseleave
Event List MDN doc
'#dev > 개념정리' 카테고리의 다른 글
Nodejs: path.parse (0) | 2020.09.18 |
---|---|
Nodejs: require vs import (0) | 2020.09.18 |
DOMContentLoaded vs. load (0) | 2020.07.06 |
Reasons for setTimeout()/setInterval() delays longer than specified (0) | 2020.07.01 |
setTimeout vs. setInterval (0) | 2020.06.30 |