基本上,我想利用角度(當前爲4)的web動畫api polyfill在元素上執行無限動畫。如何在Angular 2中執行無限動畫?
讓我們來看看一個基本的無棱角例如:
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>
如何翻譯成角?
這是我到目前爲止已經試過,但只能使用一次:
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?
])
]
有沒有辦法做到這一點與@角/動畫插件,而不是存儲ElementRef,做它作爲例子以上?或者我誤解了這個插件的用途?
在此先感謝。
難道這是有幫助嗎? https://stackoverflow.com/questions/42963315/angular-2-animate-element-generated-by-ngfor – M0CH1R0N