Greetings,
I am changing the width of an element which serves as a bar , and that works. However I can't make it so that it animates it in the opposite direction. I tried putting - in front of bar_width but to no avail. Width will be dynamically calculated it's just that I want the direction to go to the left rather than to the right like so <------- not ----------->
var bar_width=$(this).css('width') ;
$(this).css('width', '0').animate({ width: bar_width }, queue:false,duration:3500,easing: easing});
Instead of
0
you can use"toggle"
as the parameter, like this:"toggle"
will animate from it's full width to0
, and the reverse next time.You could animate it from right to left by animating both the
margin-left
andwidth
of the element at the same time:CSS
jQuery
In action here.
Alternative, if your element is positioned absolutely you could animate the
left
property andwidth
at the same time.