Adam Pietrasiak
Adam Pietrasiak

Reputation: 13194

jQuery add animation to element during another animation

fiddle

We have some div slowly changin its height. When div is clicked, it moves a little left.

What I want to do is that when you click div during its height animation it will begin moving left immediatetly without affecting height animation/stopping it etc.

So in fact there will be animation of height and of position at once then.

Upvotes: 2

Views: 79

Answers (2)

Smeegs
Smeegs

Reputation: 9224

http://jsfiddle.net/FDz4v/2/

I know the other solution is much better than mine :) But here is another method. You can use two divs and animate them separately.

$('#wrapperdiv').click(function(){
    $(this).stop().animate(
        {left: '+=50px'});
});

$('#innerdiv').animate({'height':'800px'},5000);

Upvotes: 1

ayyp
ayyp

Reputation: 6598

If you change 5000 to { queue: false, duration: 5000 }, it will work. Here's an updated fiddle: http://jsfiddle.net/FDz4v/1/

Upvotes: 9

Related Questions