Skip to content

Commit

Permalink
Add delta & adjust padding
Browse files Browse the repository at this point in the history
  • Loading branch information
Blendify committed Apr 12, 2021
1 parent 25ea466 commit fb6219c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sphinx_rtd_theme/static/js/theme.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ var jQuery = (typeof(window) != 'undefined') ? window.jQuery : require('jquery')

// Sphinx theme nav state
function ThemeNav () {
var delta = 5;

/* When the user scrolls down, hide the navbar. When the user scrolls up, show the navbar */
var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
if ((prevScrollpos > currentScrollPos) || (currentScrollPos < 40)) {


if(Math.abs(prevScrollpos - currentScrollPos) <= delta)
return

if ((prevScrollpos > currentScrollPos) || (currentScrollPos < 25)) {
document.getElementById("navbar").style.top = "0";
} else {
document.getElementById("navbar").style.top = "-50px";
Expand Down

0 comments on commit fb6219c

Please sign in to comment.