结合使用 velocity.js' slideUp 和 begin: 函数

Combine the use of velocity.js' slideUp and begin: function

如何将这两者结合起来,以便可以向上滑动项目,但在动画开始时触发一些 JS。

SlideUp代码

 .velocity("slideUp", { delay: 500, duration: 1500 });

开始:代码

$element.velocity({
    opacity: 0
}, { 
    /* Log all the animated divs. */
    begin: function(elements) { console.log(elements); }
});

这样做是行不通的。

.velocity("slideUp", { delay: 500, duration: 1500 }), { 
    /* Log all the animated divs. */
    begin: function(elements) { console.log(elements); }
});

您必须将begin 属性 放在选项对象中:

.velocity("slideUp", {
    delay: 500, duration: 150,
    begin: function(elements) { console.log(elements); }
});