velocity.js 进度回调函数不工作

velocity.js progress callback function not working

我已经使用 velocity.js 为页面上的某些内容设置动画,但进行中的回调函数对我不起作用。我得到 tweenValue 段的空值。

这是代码。

$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)
    }
});

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

$("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 在页面

中加载速度和 jquery