From 765c57632f99a14ab3294bb964ffa37ac3d5cbe2 Mon Sep 17 00:00:00 2001 From: KzHsTn Date: Tue, 13 Dec 2022 21:55:04 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=20Scroll.js=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BF=D0=BE=D1=8F=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BB=D0=B8=20=D0=BD=D0=B0=D0=B2=D0=B8=D0=B3?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BF=D1=80=D0=B8=20=D1=81=D0=BA?= =?UTF-8?q?=D1=80=D0=BE=D0=BB=D0=BB=D0=B5=20=D1=81=D1=82=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=86=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js/Scroll.js | 18 ++++++++++++++++++ templates/main.html | 1 + 2 files changed, 19 insertions(+) create mode 100644 static/js/Scroll.js 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 %}