I need to make a repeatable animation when hover a link.
I've made a route link component which contains that animation:
import { Component, Input, OnInit, trigger, state, style, transition, animate } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'routelink',
template: `<a [@hoverState]="isHover" (mouseenter)="mouseEnter()" (mouseleave)="mouseLeave()" routerLink="{{routerLink}}" routerLinkActive="active">{{title}}</a>`,
styleUrls: [ 'routelink.component.css' ],
animations : [
trigger('hoverState', [
state('false', style({
transform: 'scale(1)'
})),
state('true', style({
transform: 'scale(1.5)'
})),
transition('false <=> true', animate('1000ms ease-in-out'))
])
]
})
export class RouteLinkComponent {
@Input()
title : String;
@Input()
routerLink : String;
isHover : String;
ngOnInit(): void {
this.isHover = "false";
}
mouseEnter() {
this.isHover = "true";
}
mouseLeave() {
this.isHover = "false";
}
}
After hovering the link - it scales as expected but stops when it reaches maximum size. As you can see I used ease-in-out
in that animation.
What am I missing here ?
UPDATE:
I've created a plunker for this question: https://plnkr.co/edit/e7sN2Aoz2sr68CrWxtgo?p=preview