Line 989: | Line 989: | ||
// Add smooth scrolling on all links inside the navbar | // Add smooth scrolling on all links inside the navbar | ||
− | var jump=function(e) | + | var jump=function(e) { |
− | { | + | if (e){ |
− | + | e.preventDefault(); | |
− | + | //$("body").scrollspy({target: "#myScrollspy", offset:100}); legion says this is bad and dumb | |
− | + | var target = $(this).attr("href"); | |
− | + | } | |
− | + | else { | |
− | + | var target = location.hash; | |
− | + | } | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | $('html,body').animate( { scrollTop: $(target).offset().top - 90 },1000,function() { location.hash = target; }); | ||
} | } | ||
$('html, body').hide(); | $('html, body').hide(); | ||
− | $(document).ready(function() | + | $(document).ready(function() { |
− | { | + | $('a[href^="#snav"]').bind("click", jump); |
− | $('a[href^="#snav"]').bind("click", jump); | + | |
− | + | if (location.hash){ | |
− | + | setTimeout(function(){ | |
− | + | $('html, body').scrollTop(0).show(); | |
− | + | $("body").scrollspy({target: "#myScrollspy", offset:100}); jump(); }, 0); | |
− | + | } | |
− | + | else { | |
− | + | $('html, body').show(); | |
− | + | $("body").scrollspy({target: "#myScrollspy", offset:100}); | |
− | + | } | |
− | + | ||
}); | }); | ||
Revision as of 12:31, 31 October 2017