diff --git a/static/js/Scroll.js b/static/js/Scroll.js new file mode 100644 index 0000000..0486bd5 --- /dev/null +++ b/static/js/Scroll.js @@ -0,0 +1,18 @@ +var prevScrollpos = window.pageYOffset; +window.onload = function() +{ +document.getElementById("navbar").style.display = "none"; +} +window.onscroll = function() { + var currentScrollPos = window.pageYOffset; + + // 20 is an arbitrary number here, just to make you think if you need the prevScrollpos variable: + if (currentScrollPos > 1250) { + // I am using 'display' instead of 'top': + document.getElementById("navbar").style.display = "initial"; + } + else { + document.getElementById("navbar").style.display = "none"; + } +} + diff --git a/templates/main.html b/templates/main.html index 80c9627..4d34dab 100644 --- a/templates/main.html +++ b/templates/main.html @@ -1,4 +1,5 @@ + {% extends "base.html" %} {% block content %}