页面滚动--添加animation动画效果

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>动画</title>
<script src="jquery-1.7.2.min.js" type="text/javascript" charset="utf-8"></script>

<!--<script src="modernizr-1.6.min.js" type="text/javascript" charset="utf-8"></script>-->

<link rel="stylesheet" type="text/css" href="animate.css"/>
<style>
*{padding: 0;margin: 0;list-style-type: none;}

/*页面滚动加载*/
.animation-box{width: 100%;clear: both;}
.animation-box ul{width: 100%;float: left;margin-bottom: 60px;}
.animation-box ul li{width: 25%;float: left;}
.animation-box ul li img{width: 100%;float: left;}
</style>
</head>
<body style="height: 1000px;">
<div class="animation-box ">
<ul >
<li><img class="bounce animated" src="feng01.jpg"/></li>
<li><img class="" src="feng02.jpg"/></li>
<li><img class="" src="feng01.jpg"/></li>
<li><img class="" src="feng02.jpg"/></li>
</ul>

<ul >
<li><img class="" src="feng01.jpg"/></li>
<li><img class="" src="feng02.jpg"/></li>
<li><img class="" src="feng01.jpg"/></li>
<li><img class="" src="feng02.jpg"/></li>
</ul>

<ul >
<li><img class="revealOnScroll" data-animation="lightSpeedIn" data-timeout="800" src="feng01.jpg"/></li>
<li><img class="" src="feng02.jpg"/></li>
<li><img class="" src="feng01.jpg"/></li>
<li><img class="" src="feng02.jpg"/></li>
</ul>

<ul>
<li><img class="revealOnScroll" data-animation="lightSpeedIn" data-timeout="400" src="feng01.jpg"/></li>
<li><img class="revealOnScroll" data-animation="bounceInLeft" data-timeout="600" src="feng02.jpg"/></li>
<li><img class="revealOnScroll" data-animation="bounceInRight" data-timeout="800"src="feng01.jpg"/></li>
<li><img class="revealOnScroll" data-animation="lightSpeedIn" data-timeout="1000" src="feng02.jpg"/></li>
</ul>

<ul>
<li><img class="revealOnScroll" data-animation="bounce" data-timeout="400" src="feng01.jpg"/></li>
<li><img class="revealOnScroll" data-animation="bounceInLeft" data-timeout="400" src="feng02.jpg"/></li>
<li><img class="revealOnScroll" data-animation="bounceInRight" data-timeout="400"src="feng01.jpg"/></li>
<li><img class="revealOnScroll" data-animation="bounceInTop" data-timeout="400" src="feng02.jpg"/></li>
</ul>
</div>

</body>

<script>
$(function() {

var $window = $(window);
win_height_padded = $window.height() * 1.1;
//isTouch = Modernizr.touch;

//if (isTouch) { $('.revealOnScroll').addClass('animated'); }

$window.on('scroll', revealOnScroll);

function revealOnScroll() {
var scrolled = $window.scrollTop(),
win_height_padded = $window.height() * 1.1;

// Showed...
$(".revealOnScroll:not(.animated)").each(function () {
var $this = $(this),
offsetTop = $this.offset().top;

if (scrolled + win_height_padded > offsetTop) {
if ($this.data('timeout')) {
window.setTimeout(function(){
$this.addClass('animated ' + $this.data('animation'));
}, parseInt($this.data('timeout'),10));
} else {
$this.addClass('animated ' + $this.data('animation'));
}
}
});
// Hidden...
$(".revealOnScroll.animated").each(function (index) {
var $this = $(this),
offsetTop = $this.offset().top;
if (scrolled + win_height_padded < offsetTop) {
$(this).removeClass('animated fadeInUp flipInX lightSpeedIn bounceInLeft bounceInRight')
}
})

}

}) 

</script>
</html>

 

转载于:https://www.cnblogs.com/-zhuli/p/5633831.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值