WOW.js – 有趣的页面滚动效果

作者:月光光 2018年05月08日 19:43helloweba.net 标签:JavaScript  HTML5  CSS3 

页面在向下滚动的时候,你想让页面元素产生细小的动画效果,从而引起浏览者注意力,那么你可以试试 WOW.js。WOW.js支持多种动画效果,让你的页面滚动效果更加有趣。

WOW.js 依赖 animate.css,所以它支持 animate.css 多达 60 多种的动画效果,能满足您的各种需求。

WOW.js 使用了 querySelectorAll 方法,IE 低版本会报错,支持IE10+。为了达到更好的兼容,最好加一个浏览器及版本判断。

使用方法

1、引入文件

<link rel="stylesheet" href="css/animate.min.css">

2、HTML

<div class="wow slideInLeft"></div>
<div class="wow slideInRight"></div>

可以加入 data-wow-duration(动画持续时间)和 data-wow-delay(动画延迟时间)属性,如:

<div class="wow slideInLeft" data-wow-duration="2s" data-wow-delay="5s"></div>
<div class="wow slideInRight" data-wow-offset="10"  data-wow-iteration="10"></div>

3、JavaScript

new WOW().init();

如果需要自定义配置,可如下使用:

var wow = new WOW({
    boxClass: 'wow',
    animateClass: 'animated',
    offset: 0,
    mobile: true,
    live: true
});
wow.init();

选项配置

属性/方法 说明 默认值
boxClass 需要执行动画的元素的class,字符串 'wow'
animateClass animation.css 动画的class,字符串 'animated'
offset 距离可视区域多少开始执行动画,整数 0
mobile 是否在移动设备上执行动画,布尔值 true
live 异步加载的内容是否有效,布尔值 true

0条评论