JQuery animate () - multiple selectors and variables, a unique call to animate ()

I am changing several divs in a loop with animation () in jQuery. At the same time, I am moving (property left, no resizing) the div where they are contained.

The problem is that even though they have the same duration, resized animated calls end before the call forwarding. They are not synchronized. Is there a way to create a list of selectors and its properties and then run a unique call to animate ()?

Or is there an alternative to make multiple animations at once?

I saw there a property called a step, which happens every time an animation loop occurs, but, again, each call to animimate () has its own step.

Thanks in advance:)

Here is an example of pseudocode if necessary:

for(...){
    $(target_x).stop().animate({property_a:random_value, property_b:random_value}, {duration:300});
    }
$(container).stop().animate({property_z:random_value}, {duration:300});
+3
source share
4 answers

When he asks for something else, but is somehow connected , I find that there was no solution for him.

The best workaround is the step callback function proposed here . Thanks to Nick Craver for the link.

+1
source

@ozke: , - . , , , , ( ), ...

0

Try changing stop () to .delay (400)

0
source

Look at the animation queue and deactivate. Chain accordingly.

0
source

Source: https://habr.com/ru/post/1747876/


All Articles