Created
November 7, 2011 15:40
-
-
Save mbmccormick/1345302 to your computer and use it in GitHub Desktop.
Override navigation links, dynamically load content, transition to replace content
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("aside a.logo, nav ul li a").live("click", function(e) { | |
if ((e.which == 1 && !e.metaKey && !e.shiftKey) == false) | |
return true; | |
history.pushState("", "", this.href); | |
$("body").css("cursor", "progress"); | |
$(".main").after("<section class='right'></section>"); | |
$(".right").load(location.href + " .main>*", function() { | |
if ($(".right h1").text().length > 0) | |
document.title = "Matt McCormick - " + $(".right h1").text(); | |
else | |
document.title = "Matt McCormick"; | |
$("body").css("cursor", "auto"); | |
$(".main").fadeOut(function() { | |
$(".main").remove(); | |
$(".right").addClass("main"); | |
$(".right").removeClass("right"); | |
$(".main").hide(); | |
$(".main").fadeIn(); | |
}); | |
$("html, body").animate({ scrollTop:0 }, 0); | |
}); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment