1

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 - enter image description here

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.

1 Answer 1

8

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;">
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.