From 631547a75142326a7c71bdf123e1475217a5ad73 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 22 Apr 2026 12:42:56 +0200 Subject: chore: replace with extracted danix.xyz-hacker theme (danix2-hugo-theme) --- assets/js/reading-progress.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 assets/js/reading-progress.js (limited to 'assets/js/reading-progress.js') diff --git a/assets/js/reading-progress.js b/assets/js/reading-progress.js new file mode 100644 index 0000000..ee1192f --- /dev/null +++ b/assets/js/reading-progress.js @@ -0,0 +1,29 @@ +// Reading progress bar for single pages/articles +(function() { + const progressBar = document.getElementById('reading-progress'); + + if (!progressBar) return; + + function updateProgress() { + const windowHeight = window.innerHeight; + const documentHeight = document.documentElement.scrollHeight - windowHeight; + const scrollProgress = documentHeight > 0 ? (window.scrollY / documentHeight) * 100 : 0; + progressBar.style.width = scrollProgress + '%'; + } + + // Throttle the scroll event for better performance + let ticking = false; + + window.addEventListener('scroll', function() { + if (!ticking) { + window.requestAnimationFrame(function() { + updateProgress(); + ticking = false; + }); + ticking = true; + } + }, false); + + // Initial call + updateProgress(); +})(); -- cgit v1.2.3