Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
}, 500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment