mouseleave/mouseout and mouseover/mouseenter called multiple times when using ngFor
See original GitHub issueI’m submitting a … (check one with “x”)
[x ] bug report
Current behavior
I’m using ngFor to generate “li” elements with “mouseout” and “mouseenter” events.
<li *ngFor="let star of stars; let i = index;"
[ngClass]="star"
(mouseout)="mouseLeaveStarEvent($event)"
(mouseenter)="mouseOverStarEvent(i, $event)"
(click)="toggle(i, $event)"
attr.aria-label="{{i+1}} star">
<div class="ms-Icon ms-Icon--star" [ngClass]="star"></div>
</li>
When I keep moving my mouse pointer inside one “li” element, the mouseout and mouseenter handlers get fired multiple times.
Plunkr: https://plnkr.co/edit/D65CFnO7YIU1ile3lxaV?p=preview
Expected behavior
If I keep moving my mouse pointer inside one “li” element, I expect that mouseenter only gets called once the first time i enter that element, and mouseout to be called once when I leave that element.
The workaround right now is to NOT use ngFor by list all “li” elements manually.
- Angular version: 2.0.0
- Browser: Chrome
- Language: Typescript
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Angular USES *ngFor for mouseenter and mouseleave ...
I want to show only one change in li when I swipe multiple times, but I want to show more than two changes...
Read more >Angular Basics: How To Use the Angular Mouseenter Event
The mouseenter event is triggered when we hover over an element. This behavior is the same as the mouseover event. However, the mouseover...
Read more >Moving the mouse: mouseover/out, mouseenter/leave
The mouseover event occurs when a mouse pointer comes over an element, and mouseout – when it leaves. These events are special, because...
Read more >mouseenter angular - Code Examples & Solutions For This ...
To avoid blinking problem use following code. 2. its not mouseover and mouseout instead of that use mouseenter and mouseleave. 3.
Read more >Element: mouseleave event - Web APIs | MDN
This means that mouseleave is fired when the pointer has exited the element and all of its descendants, whereas mouseout is fired when...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

any chance
starsarray is a new array on each CD cycle ?@vicb It was indeed a new array on each cycle, but changing that didn’t help.
@ejaury I think the root of the problem is that
mouseleavedoes one thing, andmouseenterdoes another, and they pretty much conflict. An easy solution to your problem would be to setmouseleaveup on the<ul>element, like so.In any case, this sounds like a support request, rather than a bug, so let me redirect you to an appropriate channel, should you need any further assistance. If you still believe this to be a bug, please, let us know.