Last active
September 9, 2017 18:55
-
-
Save amitabhaghosh197/5a67a918f8956e2f7f0a to your computer and use it in GitHub Desktop.
Javascript Scroll to next page section #jquery #scroll
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
<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 |
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
/** | |
* 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