jquery - how to animate from left to right? -
demo: animates right left movement.but need use animation left right.
basically, i'm using script:
var counter = 1; var thisw = $('.btn.close').parent().outerwidth(); var thish = $('.btn.close').parent().outerheight(); $('.btn.close').on('click',function(){ counter = !counter; if(counter){ $(this).parent().animate({width: '5em', height: '2em'},1000); } else{ $(this).parent().animate({width: thisw, height: thish}, 1000); } }).click();//click trigger added because on first click doesn't animate //the reason is not getting actual width , height value set in em jquery px value.
i think script can written better using ternary operator. i'm stacked on this.
question:
- so what's better way write jquery of above code?
- is possible animate left right without using position absolute?
use this:
div{ width: 50em; height: 50em; background: red; float:right; direction:rtl; } <div style="direction:rtl;"> <div>click me</div> </div>
Comments
Post a Comment