This commit is contained in:
juanatsap
2025-11-12 23:07:44 +00:00
parent c99bb5590b
commit 15b73a915d
4 changed files with 139 additions and 111 deletions
+55 -1
View File
@@ -101,7 +101,61 @@
}
</script>
</head>
<body {{if .ThemeClean}}class="theme-clean"{{end}}>
<body {{if .ThemeClean}}class="theme-clean"{{end}}
_="init
set :lastScroll to 0
set :scrollThreshold to 100
set :keepHeaderVisible to false
on scroll from window
set currentScroll to window.pageYOffset
set isMenuOpen to .navigation-menu.classList.contains('menu-open')
-- Calculate if at bottom (within 50px)
set scrollHeight to document.documentElement.scrollHeight
set clientHeight to document.documentElement.clientHeight
set isAtBottom to (scrollHeight - currentScroll - clientHeight) < 50
-- Reset keepHeaderVisible when scrolling up
if currentScroll < :lastScroll
set :keepHeaderVisible to false
end
-- Header visibility based on scroll direction
if currentScroll > :scrollThreshold
if currentScroll > :lastScroll and not :keepHeaderVisible
-- Scrolling down - hide header
add .header-hidden to .action-bar
if isMenuOpen then add .header-hidden to .navigation-menu end
else
-- Scrolling up - show header
remove .header-hidden from .action-bar
if isMenuOpen then remove .header-hidden from .navigation-menu end
end
else
-- At top - always show header
remove .header-hidden from .action-bar
if isMenuOpen then remove .header-hidden from .navigation-menu end
end
-- Back to top button visibility (show after 300px scroll)
if currentScroll > 300
set #back-to-top's *display to 'flex'
else
set #back-to-top's *display to 'none'
end
-- At-bottom positioning for fixed buttons
if isAtBottom
add .at-bottom to #back-to-top
add .at-bottom to #info-button
else
remove .at-bottom from #back-to-top
remove .at-bottom from #info-button
end
-- Update last scroll position
set :lastScroll to currentScroll">
<!-- Top anchor for back-to-top link -->
<div id="top"></div>