Skip to content

Instantly share code, notes, and snippets.

@freddielore
Last active August 29, 2015 14:27
Show Gist options
  • Save freddielore/fadf572891a16416a312 to your computer and use it in GitHub Desktop.
Save freddielore/fadf572891a16416a312 to your computer and use it in GitHub Desktop.
Scroll to specific ID. Must be added in the footer area.
<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