2

When trying the animate within toggle, it always slides from left to right by default.

How can I slide from right to left?

$("#subcontainer").toggle("slow", function(){       
    $('#subcontainer').delay(1000, function(){
        $(".innercontainer").animate({
            marginLeft: parseInt($(".innercontainer").css('marginLeft'),10) == 0 ?
                $(".innercontainer").outerWidth() : 0
        });
    });
});
Manse
  • 37,765
  • 10
  • 83
  • 108
CodeJack
  • 21
  • 2

4 Answers4

0

From the code you have pasted and the question you ask it seems that you might need to have a good look at the following tutorial -> http://www.learningjquery.com/2009/02/slide-elements-in-different-directions

Have a read of that then update your code and then if you get stuck come back with code you understand

Manse
  • 37,765
  • 10
  • 83
  • 108
0

For example you can float the innercontainer right and instead marginLeft use marginRight for the animation. here the fiddle: http://jsfiddle.net/SfjLk/

html with style (example):

<div id="subcontainer">subcontainer</div>
<div class="innercontainer" style="float:right">innercontainer</div>

javascript:

$("#subcontainer").toggle("slow", function() {
    $(this).delay(1000, function() {
        $(".innercontainer").animate({
            marginRight: parseInt($(".innercontainer").css('marginLeft'), 10) == 0 ? $(".innercontainer").outerWidth() : 0
        });
    });
});
ggzone
  • 3,661
  • 8
  • 36
  • 59
0

Check below it will Help you

http://api.jquery.com/animate/

http://www.visualjquery.com/

samirprogrammer
  • 438
  • 5
  • 18
0

Take a look, maybe this will help

http://jsfiddle.net/3kPXU/1/

Lee
  • 10,496
  • 4
  • 37
  • 45