Last active
August 29, 2015 14:27
-
-
Save freddielore/fadf572891a16416a312 to your computer and use it in GitHub Desktop.
Scroll to specific ID. Must be added in the footer area.
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
<script type="text/javascript"> | |
jQuery(document).ready(function($){ | |
var scroll_delay = 4000; | |
var top = 230; | |
var app = { | |
init: function(){ | |
var sel = window.location.hash; | |
// only autoscroll if ID is detected in the URL | |
if( sel != "" ){ | |
app.scrollView(sel); | |
} | |
}, | |
scrollView: function (el) { | |
$('html, body').animate({ | |
scrollTop: $(el).offset().top - top | |
}, 500); | |
} | |
} | |
setTimeout(function(){ | |
app.init(); | |
}, scroll_delay); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment