I definately think you are on the right track thinking toggle
is the way to go. Check this fiddle out for my quick and dirty:
I made a one line change
$('#map-legend').animate({width: "toggle"}, 1000);
vs
$('#map-legend').hide("slide", { direction: "right"}, 1000);
#map-legend p {
padding-left: 25px;
width: 400px;
}
Full code here:
var state = false;
$("#toggle-slide-button").click(function () {
if (!state) {
$('#map-legend').animate({width: "toggle"}, 1000);
$('#toggle-slide-button img').attr('src', 'http://www.redearthtrail.com/img/map-arrow-open.png');
state = true;
}
else {
$('#map-legend').animate({width: "toggle"}, 1000);
$('#toggle-slide-button img').attr('src', 'http://www.redearthtrail.com/img/map-arrow-close.png');
state = false;
}
});