angular - 如何使用角度动画在点击时为图像设置动画
问题描述
该动画在页面加载时有效,但我需要在单击按钮时为该图像设置动画
<div [@fadeInDownOnEnter]="'true'">
<img src="https://www.seoclerk.com/pics/556744-1wYpi51504622425.jpg" alt="animatepic">
</div>
<button (click)="animate()">Animate it</button>
在 component.ts 文件中
import { fadeInDownOnEnterAnimation } from 'angular-animations';
@Component({
animations: [
fadeInDownOnEnterAnimation()
]
})
//method
animate(){
//what should I do here
}
解决方案
在您的组件中,
animationWithState = false;
animate(){
this.animationState=true;
this.animationWithState = !this.animationWithState;
}, 1);
和
<div [@fadeInDownOnEnter]="'true'">
这应该像
<div [@fadeInDownOnEnter]="animationState">
推荐阅读
- javascript - 如何在不触发 React 重新渲染的情况下更改元素的样式?
- symfony - 如何使用 OpenAPI 和 API 平台正确描述请求正文?
- mysql - Json 到 mariadb 的存储大小增加了三倍
- sas - SAS:获取按组验证条件的第一个值
- jquery - MODAL 的点击事件
- java - 在 Dart 中解密 Java AES 编码的字符串
- python-pptx - Python 代码在我启动 Anaconda Navigator 但不在 env 中时运行
- c++ - 在 Visual Studio 2015 中为 R 编写 C++ 代码,链接器错误
- python - Python 为 Windows 生成 SOABI/扩展后缀 (pep 3149)
- amazon-web-services - 在 ECS 服务中存储 AWS 凭证的位置