【问题标题】:velocity.js progress callback function not workingvelocity.js 进度回调函数不起作用
【发布时间】:2015-08-18 06:29:00
【问题描述】:

我已使用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)
    }
});

【问题讨论】:

    标签: javascript velocity.js


    【解决方案1】:

    当我在文档正文上尝试时,您的示例运行良好,

    $("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

    【讨论】:

      猜你喜欢
      • 2010-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-28
      • 1970-01-01
      • 1970-01-01
      • 2016-10-20
      相关资源
      最近更新 更多