Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Replace Element w/ Slide Left Effect

Currently im using fadeOut animation effect in replace content of a div element.

$('#divID').fadeOut('slow', function(){
    $(this).replaceWith( $div );
});

How can I achieve slide to left effect when replace content of the div element?

like image 805
JR Galia Avatar asked Feb 25 '13 08:02

JR Galia


1 Answers

Don't know if there is a specific effect for that, I used $().animate({left: val}) to achieve that.

var width = $(window).width();

$('#divID').animate({left : -width}, 500, function(){ $div.hide() });
$div.css({left: width}).show().animate({left: 0}, 500);

You will need to set your elements' css to position: absolute, and tune the containers and other items.

Here is a jsfiddle

like image 177
LeGEC Avatar answered Nov 03 '22 01:11

LeGEC