【发布时间】:2020-05-05 04:56:05
【问题描述】:
当页面使用不同的 url 参数路由到自身时,我试图触发动画。
例如,对于post/1 url,动画效果很好,但如果我路由到post/2 或post/3,动画就不起作用。
我使用Ionic Animation 编写动画,并在每次路由参数更改时调用该方法。有人可以帮忙吗?
这是我的代码的摘录
HTML
<ion-icon class="custom-icon" name="chevron-back-outline"></ion-icon>
TS
constructor(private animationController: AnimationController) {
this.route.params.subscribe((val) => {
this.animateIcon();
});
}
animateIcon() {
this.animationController
.create()
.addElement(document.querySelector('.custom-icon'))
.duration(1500)
.iterations(3)
.fromTo('transform', 'translateX(0px)', 'translateX(-80px)')
.fromTo('opacity', '1', '0')
.play();
}
【问题讨论】:
标签: angular ionic-framework ionic5