I'm looking to slide a div on and off screen, from the right hand side, on click of a link (.toggle-caption)
I had this working fine when both values were based on their position from the right, e.g.
$('.toggle-caption').toggle(
function()
{
$('#caption-box').animate({right: "480px"}, 500);
},
function()
{
$('#caption-box').animate({right: "-2000px"}, 500);
}
);
However, when attempting to toggle between a left and a right value, it stops working:
$('.toggle-caption').toggle(
function()
{
$('#caption-box').animate({left: "480px"}, 500);
},
function()
{
$('#caption-box').animate({right: "-2000px"}, 500);
}
);
#caption-box is 2000px wide, but only a portion of this will be displayed (depends on screen resolution). However, when sliding in, it must always land 480px away from the edge of its containing div. Hence I needed a 'left' value.
Any help appreciated!
RT