在fullpage的滚屏中使用wow.js
下面展示一些 内联代码片
。
// 整屏滚动
$('#fullpage').fullpage({
resize: true,
autoScrolling: false,
// scrollBar: true,
scrollingSpeed: 700,
sectionsColor: ['#003b75', '#003b75', '#003b75', '#fefefe', '#ffffff', '#ffffff', '#003b75'],// 背景色
afterRender: function () {
// 加载wow动画
wow = new WOW({
animateClass: 'animated',
});
wow.init();
},
onLeave: function (prev, index, direction) {
// 这一段解决wow的兼容问题
$("#fullpage .section").eq(index - 1).find('.wow').each(function () {
if ($(this).attr('data-wow-delay')) {
$(this).attr('style', 'animation-delay:' + $(this).attr('data-wow-delay'))
} else {
$(this).attr('style', '')
};
});
$("#fullpage .section").eq(index - 1).find('.wow').addClass('animated');
// 结束
}
});
// 宽度变化监测
$(window).resize(function () {
autoScrolling();
});
// 整屏滚动判断
function autoScrolling() {
var $ww = $(window).width();
if ($ww < 1024) {
$.fn.fullpage.setAutoScrolling(false);
} else {
$.fn.fullpage.setAutoScrolling(true);
}
}