Last Updated: February 25, 2016
·
2.926K
· koryteg

Simultaneous events with Queue: false

{queue: false} could be your friend when chaining animate() to events.

I was toggling a show and hide but wanted to add more custom animation to it. looked like this

$(this).show("slow").animate({
    left: "+=400px",
}, "slow");

this chain fires off show() and when it is done, then fires off animate().

by adding queue:false, they fire at the same time. syntax looks like this

$(this).show("slow").animate({
    left: "+=400px",
}, {queue: false, duration: "slow"});

check out the jQuery api for more on animate and queue

2 Responses
Add your response

I was always wondering why isn't it the default behavior in jQuery...

over 1 year ago ·

@dpashkevich yeah it seems like the most common use case.

over 1 year ago ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside