UNPKG

@omicrxn/mercury

Version:

Mercury is a Svelte animation library powered by Motion. It simplifies complex animations with Svelte actions, provides layout and exit animations, and integrates seamlessly with Svelte features.

17 lines (16 loc) 663 B
import { animate as motionAnimate, inView } from 'motion'; import { mapTransitionToMotion } from '../utils.js'; export const handleScroll = (element, params) => { if (params?.scroll) { const scroll = params.scroll; const transitionOptions = mapTransitionToMotion(scroll.transition); return inView(element, (element) => { motionAnimate(element, scroll.enter ?? {}, transitionOptions); return () => motionAnimate(element, scroll.exit ?? params.animate ?? {}, transitionOptions); }, { root: scroll.root, amount: scroll.amount, margin: scroll.margin }); } };