1

I hope you can help me to solve a little issue about jquery async managment.

the example code i've written is here (it's commented): Async Jquery Problem

Description

Well. I have a bunch of element aligned. They have a function triggered on click that take the current element the previous and the next and animate them to an hight += 50.

What i Need

I need that the clicks piled up and execute once at time when the last group of element finish their animation.

I make the animation duration random to simulate async event.

The Problem

First

Custom queue doesn't autostart . So i need a way to check that there are no animation running before dequeue the queue

Second

Call the function .is(':animated') on the complete call of the function .animate is pointless.

At that time the element is still set as :animated, so i use a cheap way to resolve the problem calling a setTimeout in the complete function so at the time of setTimeout is triggered the complete function is executed and .is(':animated') is correctly set to false.

I need a better solution becouse there are small window in which the test return true and the dequeue function is triggere twice. (see code comment for a better explanation)

Third

Despite a sentinel i inject in the queue array (as fx queue does in jQuery), there is a short window of time that trigger the dequeue when it shouldn't (read code comment for a better explanation, i know again) due to the lack of sync lock in javascript language.

Personal Comment

Yes i know that jquery is threadless language but i need a way to sync this animation in a robust way.

Bottom Line

Any comments, solutions or thoughts are welcomed ...

1
  • I landed on the similiar problem. have you resolved it yet. If so can you share it so I can refer it to resolve it..Thanks
    – Ajax3.14
    Jun 28, 2012 at 15:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.