Skip to content

Instantly share code, notes, and snippets.

@emaildano
Last active December 27, 2015 08:39
Show Gist options
  • Save emaildano/7298052 to your computer and use it in GitHub Desktop.
Save emaildano/7298052 to your computer and use it in GitHub Desktop.
Create .scroll class to use with jQuery ease and anchor tags / links
<a id="introArrow" href="#about" class="scroll"><i class="fa fa-angle-down fa-5x"></i></a>
<div class="text-center" id="about"></div>
//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