julianshapiro / velocity

Accelerated JavaScript animation.
VelocityJS.org
MIT License
17.29k stars 1.56k forks source link

UI pack: Can’t use slideUp/Down or fadeIn/Out within Velocity.RegisterEffect #772

Closed danielvdspuy closed 7 years ago

danielvdspuy commented 7 years ago

I’d like to leverage slideUp/Down in my UI transition, but am unable to.

Have tried something like this:

$.Velocity.RegisterEffect("transition.openDrawer", {
    defaultDuration: 800,
    calls: [
        [{ slideDown }, { duration: 1200 }],
        [{ opacity: 1 }, { queue: false }]
    ]
});

As well as:

// line 4
        [slideDown, { duration: 1200 }],

Console output

Uncaught ReferenceError: slideDown is not defined

Is this possible at present?

Many thanks.

Rycochet commented 7 years ago

Both of those are completely invalid Javascript, so not surprising that they don't work to begin with.

I don't know if it's possible to work, but I don't expect it to - feel free to try with valid code -

["slideDown", { duration: 1200 }],

If not then it'll go on the todo list :-)

danielvdspuy commented 7 years ago

Ah! I did try [{"slideDown"},{opts}] but not ["slideDown",{opts}]

Fair enough, slideDown doesn’t belong in an object…

This works:

$.Velocity.RegisterEffect("transition.openDrawer", {
    defaultDuration: 800,
    calls: [
        ["slideDown", { duration: 1200 }],
        [{ opacity: 1 }, { queue: false }]
    ]
});

Thanks!

Rycochet commented 7 years ago

Cool, I didn't know and didn't expect it to, but good to hear :-)

danielvdspuy commented 7 years ago

Thanks for your help with my syntax. 😂

This is probably handy to have in the docs I guess, under UI pack > Effects: Registration, or perhaps under the example(s) for slideUp/Down/fadeIn/Out…

Unfortunately, the queue prop doesn’t work for slideDown, i.e.:

$.Velocity.RegisterEffect("transition.openDrawer", {
    defaultDuration: 2000,
    calls: [
        ["fadeIn", { duration: animationDuration.steady }],
        ["slideDown", { easing: animationBezier.swiftIn, queue: false }],
    ]
});
Rycochet commented 7 years ago

A lot of the props aren't passed on - but changing (which will happen) will be a breaking change in the future.