您可以在开始动画之前设置变换属性。此外,您可以使用WebComponent修改和重置来自事件的值:<animatable/>
start
finish
<animatable-component delay="1000" duration="800" animation="slideInUp" easing="ease-in-out">
<h1>Hello World</h1>
</animatable-component>
const animatableElement = document.querySelector('animatable-component')
animatableElement.addEventListener("start", function(event) {
console.log('ANIMATION START', event);
var startTransform = 'translateY(0px)'
event.detail.style.transform = startTransform;
event.detail.style.webkitTransform = startTransform;
});
animatableElement.addEventListener("finish", function(event) {
console.log('ANIMATION FINISH', event);
var endTransform = 'translateY(300px)'
event.detail.style.transform = endTransform;
event.detail.style.webkitTransform = endTransform;
});
更多细节在这里