I have a div I want to hover, as soon as it's hovered I want to show a text that moves with the cursor but solely on the y-axis. You can find the effect I'm talking about on this website hovering an image.
My code so far:
<div class="scroll-container align-self-center">
<div class="cart-container" *ngFor="let cart of carts; let i = index" routerLink="project/{{cart.title}}">
<div class="cart-item cursor-hover position-relative d-flex justify-content-center" [ngStyle]="{'background-image': 'url(' + cart.image + ')'}" [class.cart-item-even]="i % 2 !== 0"
(mouseenter)="cartHovered(i)" (mouseleave)="cartLeft()">
<h1 class="hover-title" [style.display]="i === hoveredCart ? 'block' : 'none'">{{cart.title}}</h1>
</div>
</div>
</div>
TypeScript:
cartHovered(i) {
this.backgroundColor = this.carts[i].backgroundColor;
this.hoveredCart = i;
}
cartLeft()
this.hoveredCart = -1;
}
How can I achieve this effect using Angular when hovering .cart-item
?