swiper动画通过事件主动触发。

竹叶网 2018-05-31 08:20:04
在swiper4.x版本。主动触发动画。

html:
<div class="swiper-slide">
<img id="bagsAni" swiper-animate-effect="bounceIn" swiper-animate-duration="2s" swiper-animate-delay="0.3s" src="../img/gift.png"/>
</div>
js:
var mySwiper = new Swiper ('.swiper-container', {
on:{
init: function(){
swiperAnimateCache(this); //隐藏动画元素
swiperAnimate(this); //初始化完成开始动画
},
slideChangeTransitionEnd: function(){
swiperAnimate(this); //每个slide切换结束时也运行当前slide动画
}
}
})


$(".reduce").on("touchstart",function(){
$("#bagsAni").addClass("ani bounceIn animated");//添加swiper需要的
var timer = null;
clearTimeout(timer);
timer = setTimeout(function(){//清除类
$("#bagsAni").removeClass("ani bounceIn animated");
},1000);//动画执行的时间长度
});
...全文
1282 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

39,118

社区成员

发帖
与我相关
我的任务
社区描述
HTML5是构建Web内容的一种语言描述方式。HTML5是互联网的下一代标准,是构建以及呈现互联网内容的一种语言方式.被认为是互联网的核心技术之一。
社区管理员
  • HTML5社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧