使用了animate.css,实现了一个左右切换的小动效。
使用方法
- 下载
$ npm install animate.css --save
- 运用
直接在标签中增加对应的class,实现动效。在之前的版本中,是使用animated和其他的动效类名实现效果。新版中,对应的类名都增加了animate前缀。
//旧版
<h1 class="animated bounce">
An animated element
</h1>
//新版
<h1 class="animate__animated animate__bounce">
An animated element
</h1>
通过按钮点击时,增加对应的class。监听animationend事件,在动画结束后清除对应标签的class来实现动效的持续显示。
效果图如下:

主要使用了fadeInRight,fadeInLeft两个效果,进行动画组合显示。