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

214 views Asked by At

How do you combine these two, so that one can slide an item up, but trigger some JS just as that animation starts.

SlideUp code

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

Begin: code

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

Doing something like this doesn't work.

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

There are 1 answers

0
ydaniv On BEST ANSWER

You have to put thebegin property inside the options object:

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