Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jrstaatsiii
Last active December 19, 2015 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jrstaatsiii/5877221 to your computer and use it in GitHub Desktop.
Save jrstaatsiii/5877221 to your computer and use it in GitHub Desktop.
setTimeout to reconfigure the viewport
jQuery(document).ready(function($){ // so as to wait for any CSS-effecting assets to download
setTimeout(function() { // prepare the timeout
if(location.hash){ // is there a location hash?
if($(location.hash)){ // is there an element with an id that matches the location hash?
// determine the x location of the element we want to be in the viewport
var targetTop = $('#content').offset().top;
// accommodate the sticky element
targetTop -= $('#header').height() + $('#nav').height() - 23;
// force our scroll position based on what we want to show
$('body').scrollTop(targetTop);
}
}
}, 500);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment