I recently used this code to have a div
move from left to right on the screen. Now, my goal is to make the div
snap to the leftmost position with a smooth animation whenever someone clicks
outside of it.
For a live demonstration, visit:
$('.top-tittle .menu-icon').click(function () {
var targetValue;
if ($('.main-menu').css('left') == "0px") {
targetValue = '-78%';
} else {
targetValue = '0px';
}
$(".main-menu").animate({
left: targetValue
}, 400);
});