Skip to content

Commit

Permalink
Add smootheScrool function
Browse files Browse the repository at this point in the history
As a nice bonus to adding anchors to the top and buttom menu, heres a function that going to make a smooth scroll at the page from anchor to anchor.
  • Loading branch information
arielsafari committed Jun 24, 2014
1 parent bd6942c commit ca00a06
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions assets/js/functions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
$(function() {

});
smoothScrool(1000);
});

// smoothScroll function is applied from the document ready function
function smoothScrool (duration) {
$('a[href^="#"]').on('click', function(event) {

var target = $( $(this).attr('href') );

if( target.length ) {
event.preventDefault();
$('html, body').animate({
scrollTop: target.offset().top
}, duration);
}
});
}

0 comments on commit ca00a06

Please sign in to comment.