Line 986: | Line 986: | ||
$( document ).ready(function() { $("body").scrollspy({target: "#myScrollspy", offset:200}); }); | $( document ).ready(function() { $("body").scrollspy({target: "#myScrollspy", offset:200}); }); | ||
// Add smooth scrolling on all links inside the navbar | // Add smooth scrolling on all links inside the navbar | ||
− | $( | + | |
− | + | $(document).ready(function() | |
− | + | { | |
− | + | $('a[href*="#snav"]').bind("click", jump); | |
− | + | ||
− | + | if (location.hash){ | |
+ | setTimeout(function(){ | ||
+ | $('html, body').scrollTop(0).show() | ||
+ | jump() | ||
+ | }, 0); | ||
+ | }else{ | ||
+ | $('html, body').show() | ||
+ | } | ||
}); | }); | ||
+ | |||
+ | var jump=function(e) | ||
+ | { | ||
+ | if (e){ | ||
+ | e.preventDefault(); | ||
+ | var target = $(this).attr("href"); | ||
+ | }else{ | ||
+ | var target = location.hash; | ||
+ | } | ||
+ | |||
+ | $('html,body').animate( | ||
+ | { | ||
+ | scrollTop: $(target).offset().top | ||
+ | },1000,function() | ||
+ | { | ||
+ | location.hash = target; | ||
+ | }); | ||
+ | |||
+ | } | ||
+ | |||
+ | $('html, body').hide() | ||
</script> | </script> | ||
</html> | </html> |
Revision as of 14:49, 28 October 2017