Basically, I want to make use of the web-animations-api polyfill in angular (4 currently) to perform infinite animations on elements.
Let's see a basic non-angular example:
var ball = document.getElementById('ball');
ball.animate([
{ transform: 'scale(0.5)' },
{ transform: 'scale(1)' }
], {
duration: 1000,
iterations: Infinity,
direction: 'alternate',
easing: 'ease-in-out'
});
.container {
position: relative;
width: 100%;
height: 200px;
}
.ball {
position: absolute;
width: 80px;
height: 80px;
border-radius: 50%;
border: 2px solid #E57373;
background: #F06292;
box-shadow: 0px 0px 15px #F06292;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/web-animations/2.2.5/web-animations.min.js"></script>
<div class="container">
<div class="ball" id="ball"><div>
</div>
How do I translate that into Angular?
This is what I've tried so far but only works once:
animations: [
trigger('scale', [
transition('* <=> *', animate('1s ease-in-out', keyframes([
style({ transform: 'scale(0.5)' }),
style({ transform: 'scale(1)' })
]))) // How do I specify the iterations, or the direction?
])
]
Is there a way to do that with the @angular/animation plugin instead of storing a ElementRef and doing it as the example above? or maybe I misunderstood what this plugin is intended for?
Thanks in advance.