Line 994: | Line 994: | ||
// Add smooth scrolling on all links inside the navbar | // Add smooth scrolling on all links inside the navbar | ||
− | + | var animateScroll = function(target, offset) { | |
var is = $(document).scrollTop(); | var is = $(document).scrollTop(); | ||
var must = parseInt($(target).offset().top) + offset; | var must = parseInt($(target).offset().top) + offset; | ||
if (is < must) { | if (is < must) { | ||
− | $(document).scrollTop(is+(must/200)); | + | $(document).scrollTop(Math.min(Math.max(is+(must/200), 0), must)); |
setTimeout(function() {animateScroll(target, offset);}, 10); | setTimeout(function() {animateScroll(target, offset);}, 10); | ||
} else if (is > must) { | } else if (is > must) { | ||
− | $(document).scrollTop(is-(must/200)); | + | $(document).scrollTop(Math.min(Math.max(is-(must/200), 0), must)); |
setTimeout(function() {animateScroll(target, offset);}, 10); | setTimeout(function() {animateScroll(target, offset);}, 10); | ||
} | } |
Revision as of 21:14, 31 October 2017