Added background and foreground settings to blocks, and scroll in animations

This commit is contained in:
Jakub Dorfman 2026-05-18 18:39:49 +02:00
parent b4fbf3e411
commit 94c1e0b679
24 changed files with 826 additions and 44 deletions

View file

@ -0,0 +1,30 @@
/**
* Scroll reveal Svelte action — applies a CSS class when the element enters the viewport.
* Usage: <div use:scrollReveal class="reveal">...</div>
* The `reveal` class is hidden initially; `reveal-visible` is added on intersection.
*/
export function scrollReveal(node: HTMLElement, delay: number = 0) {
const observer = new IntersectionObserver(
(entries) => {
for (const entry of entries) {
if (entry.isIntersecting) {
if (delay > 0) {
node.style.transitionDelay = `${delay}s`;
}
node.classList.add('reveal-visible');
observer.unobserve(node);
}
}
},
{ threshold: 0.1, rootMargin: '0px 0px -40px 0px' }
);
observer.observe(node);
return {
destroy() {
observer.disconnect();
}
};
}