UNPKG

rune-scroller

Version:

Lightweight, high-performance scroll animations for Svelte 5. ~2KB bundle, zero dependencies.

14 lines (13 loc) 593 B
/** * Animation type definitions and utilities */ /** * Calculate rootMargin for IntersectionObserver from offset or custom rootMargin * @param offset - Viewport offset (0-100). 0 = bottom of viewport touches top of element, 100 = top of viewport touches top of element * @param rootMargin - Custom rootMargin string (takes precedence over offset) * @returns rootMargin string for IntersectionObserver */ export function calculateRootMargin(offset, rootMargin) { return rootMargin ?? (offset !== undefined ? `-${100 - offset}% 0px -${offset}% 0px` : '-10% 0px -10% 0px'); }