Skip to content

Instantly share code, notes, and snippets.

@guilherme
Created December 6, 2010 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilherme/730680 to your computer and use it in GitHub Desktop.
Save guilherme/730680 to your computer and use it in GitHub Desktop.
function content_changer(container,wrapper, baseHeight = 0) {
var newHash = "",
$mainContent = container,
$pageWrap = wrapper,
baseHeight,
$el;
$pageWrap.height($pageWrap.height());
baseHeight = $pageWrap.height() - $mainContent.height();
$("nav").delegate("a", "click", function() {
window.location.hash = $(this).attr("href");
return false;
});
$(window).bind('hashchange', function(){
newHash = window.location.hash.substring(1);
if (newHash) {
$mainContent
.find("#guts")
.fadeOut(200, function() {
$mainContent.hide().load(newHash + " #guts", function() {
$mainContent.fadeIn(200, function() {
$pageWrap.animate({
height: baseHeight + $mainContent.height() + "px"
});
});
$("nav a").removeClass("current");
$("nav a[href="+newHash+"]").addClass("current");
});
});
};
});
$(window).trigger('hashchange');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment