Last active
December 22, 2015 23:49
-
-
Save stephenscaff/6549826 to your computer and use it in GitHub Desktop.
Got a scroll-based site with more than one page, and some page anchor nav links? Nice. But, when clicking a page anchor link from another page, let's load the new page first, slow our damn rolls, then scroll down to the bad boy all sexy like. Throw in a bit of offset for a fixed nav too. Don't forget them easing equations son. They make life wor…
This file contains 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
//Scroll to anchor on new page load | |
$(document).ready(function() { | |
//This a page anchor link? | |
if (window.location.hash) { | |
//Then, slow your roll son, load then scroll | |
setTimeout(function() { | |
$('html, body').scrollTop(0).show(); | |
$('html, body').animate({ | |
//how about a touch of offset, cause I'm rockin' a fixed nav | |
scrollTop: $(window.location.hash).offset().top-50 | |
}, 2000, 'easeInOutQuad') | |
}, 2); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment