Created
November 7, 2011 15:45
-
-
Save mbmccormick/1345316 to your computer and use it in GitHub Desktop.
Handle browser's back button, 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
| $(window).bind("popstate", function() { | |
| $("body").css("cursor", "progress"); | |
| $(".main").after("<section class='left'></section>"); | |
| $(".left").load(location.pathname + " .main>*", function() { | |
| if ($(".left h1").text().length > 0) | |
| document.title = "Matt McCormick - " + $(".left h1").text(); | |
| else | |
| document.title = "Matt McCormick"; | |
| $("body").css("cursor", "auto"); | |
| $(".main").animate({ left: widthB + "px"}, function() { | |
| $(".main").remove(); | |
| }); | |
| $(".left").show(); | |
| $(".left").animate({ left: widthA + "px"}, function(){ | |
| $(".left").addClass("main"); | |
| $(".left").removeClass("left"); | |
| }); | |
| render(); | |
| $("html, body").animate({ scrollTop:0 }, 0); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment