velocity.js进程回调函数不起作用

时间:2015-08-18 06:29:01

标签: javascript velocity.js

我已经使用velocity.js在页面上制作动画,但是正在进行的回调函数对我不起作用。我得到tweenValue para的空值。

这是代码。



$element.velocity({
    opacity: 0,
    tween: 1000 // Optional
}, {
    progress: function(elements, complete, remaining, start, tweenValue) {
        console.log((complete * 100) + "%");
        console.log(remaining + "ms remaining!");
        console.log("The current tween value is " + tweenValue)
    }
});




1 个答案:

答案 0 :(得分:0)

当我在文档正文中尝试时,您的示例正常工作

$("body").velocity({
    opacity: 0,
    tween: 1000 // Optional
}, {
    progress: function p(elements, complete, remaining, start, tweenValue) {
        console.log((complete * 100) + "%");
        console.log(remaining + "ms remaining!");
        console.log("The current tween value is " + tweenValue)
    }
});

它会记录以下消息

4%
VM740:8 384ms remaining!
VM740:9 The current tween value is 3.942649342761062

我使用了github的最新1.2.2版本, https://github.com/julianshapiro/velocity/blob/master/velocity.js 我使用requirejs在页面中加载velocity和jquery

相关问题