Ver Fonte

Добавил файл Scroll.js для появление панели навигации при скролле страницы

KzHsTn há 3 anos atrás
pai
commit
765c57632f
2 ficheiros alterados com 19 adições e 0 exclusões
  1. 18 0
      static/js/Scroll.js
  2. 1 0
      templates/main.html

+ 18 - 0
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";
+  }
+}
+

+ 1 - 0
templates/main.html

@@ -1,4 +1,5 @@
 <link rel="stylesheet" href="../static/css/main.css">
+<script src="../static/js/Scroll.js"></script>
 {% extends "base.html" %}
 
 {% block content %}