Skip to content

Instantly share code, notes, and snippets.

@smeric
Created November 5, 2015 21:57
Show Gist options
  • Save smeric/f182b22db0de5e4671b5 to your computer and use it in GitHub Desktop.
Save smeric/f182b22db0de5e4671b5 to your computer and use it in GitHub Desktop.
/**
* Smooth scroll :
* <a href="#top" class="go-top">Top</a>
* $( '.go-top' ).click( function( e ){ e.preventDefault(); $( this ).autoscroll( $( this ).attr( 'href' ) ); });
**/
( function( $ ) {
$.fn.autoscroll = function( selector ) {
$( 'html,body' ).animate({
scrollTop: $( selector ).offset().top
}, 200);
};
})( jQuery );
/*! Smooth scroll packed */
!function(o){o.fn.autoscroll=function(s){o("html,body").animate({scrollTop:o(s).offset().top},200)}}(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment