steveosoule
6/28/2013 - 10:42 PM

Javascript Animated Page Transition

Javascript Animated Page Transition

// http://www.smashingmagazine.com/2013/06/25/workflow-design-develop-modern-portfolio-website/
/* 
* Function to animate leaving a page
*/
$.fn.leavePage = function() {   
  	
	this.click(function(event){

		// Don't go to the next page yet.
		event.preventDefault();
		linkLocation = this.href;
		
		// Fade out this page first.
		$('body').fadeOut(500, function(){
			
			// Then go to the next page.
			window.location = linkLocation;
		});      
	}); 
};


/* 
* Call the leavePage function upon link clicks with the "transition" class
*/
$('.transition').leavePage();