Skip to content

Commit fb7590c

Browse files
committed
feat/docs: marquee
1 parent 256a1e8 commit fb7590c

5 files changed

Lines changed: 1328 additions & 1305 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.25.3
44

55
require (
66
github.com/mangoumbrella/goldmark-figure v1.4.0
7+
github.com/mattn/go-isatty v0.0.20
78
github.com/rs/zerolog v1.34.0
89
github.com/spf13/cobra v1.10.2
910
github.com/yuin/goldmark v1.7.16
@@ -16,7 +17,6 @@ require (
1617
github.com/inconshreveable/mousetrap v1.1.0 // indirect
1718
github.com/kr/pretty v0.3.1 // indirect
1819
github.com/mattn/go-colorable v0.1.14 // indirect
19-
github.com/mattn/go-isatty v0.0.20 // indirect
2020
github.com/rogpeppe/go-internal v1.14.1 // indirect
2121
github.com/spf13/pflag v1.0.10 // indirect
2222
golang.org/x/sys v0.40.0 // indirect

site/content/developer-guide.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
---
22
date: 2024-04-28
33
title: Developer Guide
4-
toc: true
4+
toc: false
55
collections:
66
- anna
77
- guide
88
layout: page_2
99
---
1010

11-
# Developer Guide
12-
1311
This document explains the repository layout, development commands and how to contribute.
1412

1513
## Repository layout (high level)

site/content/index.md

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ Anna is a lightning fast static site generator written in Go, designed for simpl
1414

1515
<script>
1616
const urls = [
17+
"https://adihegde.com",
1718
"https://hsp-ec.xyz",
1819
"https://anirudhsudhir.com",
19-
"https://adihegde.com",
20-
"https://polarhive.net"
20+
"https://adhesh.netlify.app",
21+
"https://polarhive.net",
22+
"https://sameermanvi.me"
2123
];
2224

2325
const gallery = document.getElementById('embed-gallery');
@@ -40,6 +42,99 @@ urls.forEach((url, index) => {
4042
item.appendChild(frame);
4143
gallery.appendChild(item);
4244
});
45+
46+
// wrap the gallery in a scrollable marquee container if not already wrapped
47+
if (!gallery.parentElement.classList.contains('marquee')) {
48+
const marquee = document.createElement('div');
49+
marquee.className = 'marquee';
50+
gallery.parentNode.replaceChild(marquee, gallery);
51+
marquee.appendChild(gallery);
52+
gallery.classList.add('marquee-track');
53+
}
54+
55+
// setup auto-scroll + drag timeline
56+
function setupMarquee() {
57+
const container = gallery.parentElement; // .marquee
58+
const track = gallery; // .marquee-track
59+
const initial = Array.from(track.children);
60+
if (!initial.length) return;
61+
62+
// duplicate items until track width >= 2x container width
63+
let totalWidth = initial.reduce((sum, el) => sum + el.getBoundingClientRect().width + parseFloat(getComputedStyle(track).gap || 0), 0);
64+
let i = 0;
65+
while (totalWidth < container.getBoundingClientRect().width * 2) {
66+
const clone = initial[i % initial.length].cloneNode(true);
67+
track.appendChild(clone);
68+
totalWidth += clone.getBoundingClientRect().width + parseFloat(getComputedStyle(track).gap || 0);
69+
i++;
70+
if (i > 60) break;
71+
}
72+
73+
const trackWidth = Array.from(track.children).reduce((w, node) => w + node.getBoundingClientRect().width + parseFloat(getComputedStyle(track).gap || 0), 0);
74+
const half = trackWidth / 2;
75+
76+
// auto-scroll state
77+
let last = null;
78+
const speed = 12; // px/s
79+
let isPointerDown = false;
80+
let isHover = false;
81+
let isFocused = false;
82+
83+
let startX = 0;
84+
let startScroll = 0;
85+
86+
container.addEventListener('pointerdown', (e) => {
87+
isPointerDown = true;
88+
container.setPointerCapture?.(e.pointerId);
89+
startX = e.clientX;
90+
startScroll = container.scrollLeft;
91+
});
92+
93+
container.addEventListener('pointermove', (e) => {
94+
if (!isPointerDown) return;
95+
const dx = e.clientX - startX;
96+
container.scrollLeft = startScroll - dx;
97+
if (container.scrollLeft >= half) container.scrollLeft -= half;
98+
if (container.scrollLeft < 0) container.scrollLeft += half;
99+
});
100+
101+
container.addEventListener('pointerup', (e) => {
102+
isPointerDown = false;
103+
try { container.releasePointerCapture?.(e.pointerId); } catch (err) {}
104+
});
105+
106+
container.addEventListener('pointercancel', () => { isPointerDown = false; });
107+
container.addEventListener('mouseleave', () => { isPointerDown = false; });
108+
109+
container.addEventListener('mouseenter', () => { isHover = true; });
110+
container.addEventListener('mouseleave', () => { isHover = false; });
111+
container.addEventListener('focusin', () => { isFocused = true; });
112+
container.addEventListener('focusout', () => { isFocused = false; });
113+
114+
function step(t) {
115+
if (!last) last = t;
116+
const dt = (t - last) / 1000;
117+
last = t;
118+
119+
if (!isPointerDown && !isHover && !isFocused) {
120+
container.scrollLeft += speed * dt;
121+
if (container.scrollLeft >= half) container.scrollLeft -= half;
122+
}
123+
124+
requestAnimationFrame(step);
125+
}
126+
127+
requestAnimationFrame(step);
128+
129+
// ensure initial scroll is positioned within first half
130+
container.scrollLeft = 0;
131+
}
132+
133+
window.addEventListener('load', setupMarquee);
134+
window.addEventListener('resize', () => {
135+
clearTimeout(window._marqueeTimer);
136+
window._marqueeTimer = setTimeout(setupMarquee, 150);
137+
});
43138
</script>
44139

45140
---

site/content/posts/building-anna/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Building anna
33
date: 2024-04-04
44
type: post
5-
toc: true
5+
toc: false
66
description: A lightning-fast static site generator written in Go
77
tags: ["acm", "hsp", "go", "tech", "talks", "aiep", "anna"]
88
authors:

0 commit comments

Comments
 (0)