Yus*_*ick 5 jquery animation velocity.js
我正在使用Velocity在屏幕上翻译元素.完成后,我希望元素返回其原点并循环动画,绕过循环时发生的默认反向效果.
我有我的标准动画功能,我传递了我的值:
$(element).delay(initialDelay).velocity(animationValues, {duration: duration, easing: easing, loop: loop, complete: function() {
callback();
}});
Run Code Online (Sandbox Code Playgroud)
有没有办法通过翻译元素而不是旋转元素来实现此功能?
确保在动画函数中初始化位置 - 请参阅下面的示例:
$(document).ready(function(){
var el = $('#target');
function anim() {
el.velocity({ 'left': 0 }, 0 )
.velocity({ 'left': 300 }, { duration: 2000, complete: anim });
};
anim();
});Run Code Online (Sandbox Code Playgroud)
#target {
background: #999; width: 100px; height: 100px; position: absolute;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.jsdelivr.net/velocity/1.4.2/velocity.min.js"></script>
<div id="target"></div>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
629 次 |
| 最近记录: |