summaryrefslogtreecommitdiffstats
path: root/assets/js/article-lazy.js
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-04-22 12:42:56 +0200
committerDanilo M. <danix@danix.xyz>2026-04-22 12:42:56 +0200
commit631547a75142326a7c71bdf123e1475217a5ad73 (patch)
treef3cfef6b3c5b42bf626fc823ddcf63b8dcf4cdbb /assets/js/article-lazy.js
parent77ccbe72fad5a4870185fff374f75471c16a9043 (diff)
downloaddanixxyz-theme-631547a75142326a7c71bdf123e1475217a5ad73.tar.gz
danixxyz-theme-631547a75142326a7c71bdf123e1475217a5ad73.zip
chore: replace with extracted danix.xyz-hacker theme (danix2-hugo-theme)
Diffstat (limited to 'assets/js/article-lazy.js')
-rw-r--r--assets/js/article-lazy.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/assets/js/article-lazy.js b/assets/js/article-lazy.js
new file mode 100644
index 0000000..64ca862
--- /dev/null
+++ b/assets/js/article-lazy.js
@@ -0,0 +1,34 @@
+document.addEventListener('DOMContentLoaded', function () {
+ var timeline = document.querySelector('ol.timeline');
+ if (!timeline) return;
+
+ // Progressive enhancement: activates CSS hidden state
+ timeline.classList.add('js-lazy-timeline');
+
+ var items = Array.prototype.slice.call(
+ timeline.querySelectorAll('.timeline-item')
+ );
+
+ function reveal(item) {
+ item.classList.add('is-visible');
+ }
+
+ var observer = new IntersectionObserver(
+ function (entries) {
+ entries.forEach(function (entry) {
+ if (entry.isIntersecting) {
+ reveal(entry.target);
+ observer.unobserve(entry.target);
+ }
+ });
+ },
+ {
+ rootMargin: '-80px 0px 0px 0px',
+ threshold: 0.12,
+ }
+ );
+
+ items.forEach(function (item) {
+ observer.observe(item);
+ });
+});