Last active
August 29, 2015 14:05
-
-
Save timarney/ac3702cbdb3fc37548d2 to your computer and use it in GitHub Desktop.
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
//note:offset & speed could be setup as globals | |
/** | |
on page load or ajax update: | |
if(window.location.hash) { | |
// Fragment exists | |
scroll(window.location.hash,100,500); | |
} | |
direct: | |
scroll('#id3',100,750) | |
*/ | |
function scroll(anchor,offset,speed){ | |
$('html, body').animate({ // animate both for cross browser support | |
scrollTop:$(anchor).position().top - offset | |
}, speed); | |
} | |
// Scroll down to content | |
$('a.anchor-click').click( function(evt) { | |
evt.preventDefault(); | |
scroll('#id3',100,750); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment