Last active
December 27, 2015 08:39
-
-
Save emaildano/7298052 to your computer and use it in GitHub Desktop.
Create .scroll class to use with jQuery ease and anchor tags / links
This file contains 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 id="introArrow" href="#about" class="scroll"><i class="fa fa-angle-down fa-5x"></i></a> | |
<div class="text-center" id="about"></div> |
This file contains 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
//scrollto ease | |
$(".scroll").click(function(event){ | |
event.preventDefault(); | |
//calculate destination place | |
var dest=0; | |
if($(this.hash).offset().top > $(document).height()-$(window).height()){ | |
dest=$(document).height()-$(window).height(); | |
}else{ | |
dest=$(this.hash).offset().top; | |
} | |
//go to destination | |
$('html,body').animate({scrollTop:dest}, 2000,'swing'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment