Skip to content

Instantly share code, notes, and snippets.

@amitabhaghosh197
Last active September 9, 2017 18:55
Show Gist options
  • Save amitabhaghosh197/5a67a918f8956e2f7f0a to your computer and use it in GitHub Desktop.
Save amitabhaghosh197/5a67a918f8956e2f7f0a to your computer and use it in GitHub Desktop.
Javascript Scroll to next page section #jquery #scroll
<a href="#testimonial-01" class="go-down scroll" rel="testimonial-01_link"><i class="fa fa-angle-down"></i></a>
rel="testimonial-01_link" <-- is the next div testimonial-01 id
/**
* Scroll to a section on the page.
*/
$('.scroll a, a.scroll').click(function(e){
var rel = $(this).attr('rel');
var destination = rel.split('_')[0];
var window_width = $(window).width();
var the_offset = 120;
$('body , html').animate({ scrollTop: $('#' + destination).offset().top-the_offset } , 2000 , 'easeInOutCirc' );
e.preventDefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment