Skip to content

Instantly share code, notes, and snippets.

@mbmccormick
Created November 7, 2011 15:40
Show Gist options
  • Save mbmccormick/1345302 to your computer and use it in GitHub Desktop.
Save mbmccormick/1345302 to your computer and use it in GitHub Desktop.
Override navigation links, dynamically load content, transition to replace content
$("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