easing.js是一款jQuery动画效果插件,使用该插件可以实现直线匀速运功、变加速运动、缓冲等丰富的动画效果。它非常小巧,且有多种动画方式供选择,使用简单且免费。
1. 引入插件:引入jQuery库文件和Easing js文件。
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.easing.min.js"></script>
2. 示例
//css
.div1 {
position: absolute;
left: 0;
top: 0;
width: 100px;
height: 100px;
background: red;
margin: 5px;
cursor: pointer;
}
//html
<div class="div1">示例</div>
//js
$(".div1").click(function () {
$(this).animate({
width: 300
}, {
easing: "easeInOutBack",
complete: function () {//回调函数
$(this).animate({
height: 200
}, {
easing: "easeOutBounce"
})
}
})
});