2025-04-03 15:14:38 -04:00
|
|
|
{{ $images := slice }}
|
|
|
|
|
{{ range readDir "static/backgrounds" }}
|
2026-01-06 23:33:22 -05:00
|
|
|
{{ if or (in .Name ".webp") (in .Name ".jpg") }}
|
2025-04-03 15:14:38 -04:00
|
|
|
{{ $images = $images | append .Name }}
|
|
|
|
|
{{ end }}
|
|
|
|
|
{{ end }}
|
|
|
|
|
|
2026-01-07 00:43:05 -05:00
|
|
|
<div class="background-container" id="bg-container">
|
2026-01-06 23:33:22 -05:00
|
|
|
<img id="background-thumb" alt="Background" class="background-image">
|
|
|
|
|
<img id="background-full" alt="Background" class="background-image background-full" loading="lazy">
|
2026-01-07 00:43:05 -05:00
|
|
|
<div id="cursor-circle"></div>
|
2025-04-03 15:14:38 -04:00
|
|
|
<script>
|
|
|
|
|
const images = {{ $images }};
|
|
|
|
|
const randomImage = images[Math.floor(Math.random() * images.length)];
|
2026-01-06 23:33:22 -05:00
|
|
|
const thumbImg = document.getElementById('background-thumb');
|
|
|
|
|
const fullImg = document.getElementById('background-full');
|
|
|
|
|
const thumbPath = `/backgrounds/thumbs/${randomImage}`;
|
|
|
|
|
const fullPath = `/backgrounds/${randomImage}`;
|
|
|
|
|
|
|
|
|
|
thumbImg.src = thumbPath;
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
const preloadImg = new Image();
|
|
|
|
|
preloadImg.onload = () => {
|
|
|
|
|
fullImg.src = fullPath;
|
|
|
|
|
fullImg.classList.add('loaded');
|
|
|
|
|
setTimeout(() => thumbImg.remove(), 2000);
|
|
|
|
|
};
|
|
|
|
|
preloadImg.onerror = () => {
|
|
|
|
|
fullImg.src = fullPath;
|
|
|
|
|
fullImg.classList.add('loaded');
|
|
|
|
|
};
|
|
|
|
|
preloadImg.src = fullPath;
|
|
|
|
|
}, 800);
|
2026-01-07 00:43:05 -05:00
|
|
|
|
|
|
|
|
const container = document.getElementById('bg-container');
|
|
|
|
|
const circle = document.getElementById('cursor-circle');
|
|
|
|
|
let hoverTimer = null;
|
|
|
|
|
let revealTimer = null;
|
|
|
|
|
let isRevealed = false;
|
|
|
|
|
|
|
|
|
|
container.addEventListener('mousemove', (e) => {
|
|
|
|
|
if (isRevealed) return;
|
|
|
|
|
|
|
|
|
|
circle.style.left = e.clientX + 'px';
|
|
|
|
|
circle.style.top = e.clientY + 'px';
|
|
|
|
|
|
|
|
|
|
if (!hoverTimer) {
|
|
|
|
|
hoverTimer = setTimeout(() => {
|
|
|
|
|
circle.classList.add('active');
|
|
|
|
|
revealTimer = setTimeout(() => {
|
|
|
|
|
circle.classList.remove('active');
|
|
|
|
|
circle.classList.add('fade-out');
|
|
|
|
|
fullImg.classList.add('unblurred');
|
|
|
|
|
isRevealed = true;
|
|
|
|
|
}, 4000);
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const resetEffect = () => {
|
|
|
|
|
clearTimeout(hoverTimer);
|
|
|
|
|
clearTimeout(revealTimer);
|
|
|
|
|
hoverTimer = null;
|
|
|
|
|
revealTimer = null;
|
|
|
|
|
circle.classList.remove('active', 'fade-out');
|
|
|
|
|
fullImg.classList.remove('unblurred');
|
|
|
|
|
isRevealed = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
container.addEventListener('mouseleave', resetEffect);
|
|
|
|
|
window.addEventListener('mouseout', (e) => {
|
|
|
|
|
if (!e.relatedTarget || e.relatedTarget.nodeName === 'HTML') {
|
|
|
|
|
resetEffect();
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-04-03 15:14:38 -04:00
|
|
|
</script>
|
|
|
|
|
</div>
|