diff --git a/themes/doc-theme/static/js/smooth-scroll.js b/themes/doc-theme/static/js/smooth-scroll.js new file mode 100644 index 0000000..b6cfbf5 --- /dev/null +++ b/themes/doc-theme/static/js/smooth-scroll.js @@ -0,0 +1,23 @@ +/* +* Smooth scroll to anchor link +*/ + + +$(document).ready(function(){ + $( 'a[href^="#"]' ).on( 'click', function( e ) { + + if ( this.hash !== '' ) { + e.preventDefault(); + + var hash = this.hash; + var nav = $( '.navbar' ).outerHeight(); + var targetOffset = $( hash ).offset().top - nav; + + $( 'html, body' ).animate( { + scrollTop: targetOffset + }, 1100, function() { + //window.location.hash = hash; + } ); + } + } ); +} );