-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscript.js
More file actions
34 lines (26 loc) · 955 Bytes
/
script.js
File metadata and controls
34 lines (26 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Infinite Horizontal Scroll Animation
window.addEventListener("load", () => {
const wrapper = document.querySelector(".scroll-wrapper");
const inner = document.getElementById("scrollInner");
const track = document.getElementById("track");
const gap = 15;
const loopWidth = track.getBoundingClientRect().width + gap;
while (inner.getBoundingClientRect().width < wrapper.offsetWidth + loopWidth) {
inner.appendChild(track.cloneNode(true));
}
const pxPerSec = 50;
inner.style.setProperty("--loop-width", loopWidth + "px");
inner.style.setProperty("--duration", loopWidth / pxPerSec + "s");
});
// Navbar Live Time
function updateTime() {
const now = new Date();
const time = now.toLocaleTimeString([], {
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
});
document.getElementById('time').textContent = time;
}
updateTime();
setInterval(updateTime, 1000);