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

This commit is contained in:
KzHsTn 2022-12-13 21:55:04 +05:00
parent 158409f158
commit 765c57632f
2 changed files with 19 additions and 0 deletions

18
static/js/Scroll.js Normal file
View File

@ -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";
}
}

View File

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