1
2
3
4
5
6
7
8
9
.dummy {
position: absolute;
width: 100px;
height: 100px;
border-radius: 50%;
background-color: red;
}

<div class="dummy" id="dummy1"></div>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

// 自定义缓动
Velocity.Easings.myCustomEasing = function(p, opts, tweenDelta) {
// easeIn: function(t, b, c, d) t 当前时间, b 初始值, c 差值, d 时间
return Tween.Bounce.easeOut(p* opts.duration ,0,tweenDelta,1*opts.duration)/tweenDelta;
// return Tween.Bounce.easeOut(p,0,tweenDelta,1)/tweenDelta;
};


document.querySelector('#dummy1').addEventListener('click',function(){
Velocity(document.querySelector('#dummy1'), {
top: '300px'
}, {
easing: 'myCustomEasing',
duration: 600
})
})
2016-06-02

⬆︎TOP