We will also be using the shorthand of v-on. To hook everything up we will use Vue events to listen for when the mouse enters and leaves, and update our state accordingly. Instead of creating a ton of unique events, there is only one - making it much faster! Let's hook things up The main difference being that mouseover bubbles like most other DOM events. The mouseover event works pretty much the same as mouseenter. Instead, we will use the mouseover event. What will we be using instead, you ask?!? This is because mouseenter fires a unique event to the entered element, as well as every single ancestor element. The reason is that there can be significant performance problems when using mouseenter on deep DOM trees. To keep track of when the mouse leaves, we'll use the mouseleave event.ĭetecting when the mouse enters can be done with the corresponding mouseenter event, but we won't be using that one. This can be figured out by keeping track of when the mouse enters the element, and when the mouse leaves the element. We want to know when the mouse is hovering over the element. So, which events do we need to listen to?
0 Comments
Leave a Reply. |