diff options
Diffstat (limited to 'docs/js')
-rw-r--r-- | docs/js/index.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/js/index.js b/docs/js/index.js new file mode 100644 index 000000000..029a9e703 --- /dev/null +++ b/docs/js/index.js @@ -0,0 +1,21 @@ +$(document).ready(function() { + window.sr = ScrollReveal(); + sr.reveal(".scala-logo-container", { duration: 2000, delay: 100, mobile: false }); + + var hostname = new RegExp(location.host); + $('a').each(function(){ + var url = $(this).attr("href"); + if (hostname.test(url) || url.slice(0, 1) == "#") + $(this).addClass('local'); + }); + + $("a").on('click', function(event) { + if ($(this).hasClass("local") && this.hash != "") { + event.preventDefault(); + var hash = this.hash; + $('html, body').animate({ scrollTop: $(hash).offset().top }, 800, function() { + window.location.hash = hash; + }); + } + }); +}); |