Reputation: 1565
I'm trying to set hover feature on my website. But it is not working. It will be very much helpful if someone can help me out.
<div class="text-result" *ngIf="Display('all')">
<div *ngFor="let item of items$|async let i = index; trackBy: trackHero" class="result">
<div class="title" (mouseover)="overTitle()" (mouseleave)="overTitle()">
<a href="{{item.link}}">{{item.title}}</a>
</div>
<iframe [src]="myUrlList[i]"></iframe>
<div class="link">
<p>{{item.link}}</p>
</div>
<div class="description">
<p>{{item.description}}</p>
</div>
<div>
{{item.pubDate|date:'fullDate'}}
</div>
</div>
</div>
hoverBox: boolean = false;
// display content on hover
// --------------------------------
overTitle(){
if(this.hoverBox == true){
this.hoverBox = false;
}
else {
this.hoverBox = true;
}
}
trackHero(index, item){
console.log("item", item);
return item ? item.id : undefined;
}
// ---------------------------------
How it looks currently with the above code -
I want to have it in such a way when mouse cursor hovers over link, preview of page is shown. When I remove the cursor, preview of page should not be shown.
Upvotes: 1
Views: 8680
Reputation: 37403
use mouseenter
instead of mouseover
. see the difference here
Each time your mouse enters or leaves a child element, mouseover is triggered, but not mouseenter.
<div class="title" (mouseenter)="hoverBox = true;" (mouseleave)="hoverBox = false;">
Upvotes: 8