Blur Fade
svelte-animations/blur-fadeFreeBlock
A component that animates content with blur and fade effects, supporting directional movement and intersection observer triggering.
Install it
npx shadcn@latest add https://sv-animations.vercel.app/r/blur-fade.jsonSource
1<script lang="ts">2 import { motion, AnimatePresence, useInView, type Variants } from "motion-sv";3 import { cn } from "$UTILS$";4 import type { Snippet } from "svelte";56 type MarginType = string;78 interface BlurFadeProps {9 children: Snippet;10 class?: string;11 variant?: Variants;12 exit?: boolean;13 duration?: number;14 delay?: number;15 offset?: number;16 direction?: "up" | "down" | "left" | "right";17 triggerOnView?: boolean;18 inViewMargin?: MarginType;19 blur?: string;20 once?: boolean;21 }2223 let {24 children,25 class: className,26 variant,27 exit = false,28 duration = 0.4,29 delay = 0,30 offset = 6,31 direction = "down",32 triggerOnView = true,33 inViewMargin = "-50px",34 blur = "6px",35 once = true,36 }: BlurFadeProps = $props();3738 let containerRef: HTMLDivElement | null = $state(null);39 let view = useInView(40 () => containerRef!,41 () =>42 ({43 once,44 amount: 0.1,45 margin: inViewMargin,46 }) as any47 );4849 const defaultVariants = $derived.by(() => {50 return {51 hidden: {52 [direction === "left" || direction === "right" ? "x" : "y"]:53 direction === "right" || direction === "down" ? -offset : offset,54 opacity: 0,55 filter: `blur(${blur})`,56 },57 visible: {58 [direction === "left" || direction === "right" ? "x" : "y"]: 0,59 opacity: 1,60 filter: `blur(0px)`,61 },62 } as Variants;63 });6465 const combinedVariants = $derived(variant || defaultVariants);66 const shouldAnimate = $derived(!triggerOnView || view.current);67</script>6869<div bind:this={containerRef}>70 <AnimatePresence>71 <motion.div72 initial="hidden"73 animate={shouldAnimate ? "visible" : "hidden"}74 exit={exit ? "hidden" : undefined}75 variants={combinedVariants}76 transition={{77 delay: 0.04 + delay,78 duration,79 ease: "easeOut",80 }}81 class={cn(className)}82 >83 {@render children()}84 </motion.div>85 </AnimatePresence>86</div>
What it pulls in
npm packages
Files it writes
More from Svelte Animations
All 66 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Beamanimated-beam | Svelte Animations | Blocks | Free | 1 dep · 6 files | |
| Animated Circular Progress Baranimated-circular-progress-bar | Svelte Animations | Blocks | Free | no deps · 2 files | |
| Animated Gradient Textanimated-gradient-text | Svelte Animations | Blocks | Free | no deps · 2 files | |
| Animated Grid Patternanimated-grid-pattern | Svelte Animations | Blocks | Free | 1 dep · 2 files | |
| Animated Listanimated-list | Svelte Animations | Blocks | Free | 1 dep · 2 files | |
| Animated Shiny Textanimated-shiny-text | Svelte Animations | Blocks | Free | no deps | |
| Animated Theme Toggleranimated-theme-toggler | Svelte Animations | Blocks | Free | no deps · 2 files | |
| Arc Timelinearc-timeline | Svelte Animations | Blocks | Free | no deps · 3 files |
