Horizontal Depth Fade Demo
unlumen-ui/demo-horizontal-depth-fadePaidComponent
Demo showing the Horizontal Depth Fade component.
Install it
npx shadcn@latest add https://ui.unlumen.com/r/demo-horizontal-depth-fade.jsonSource
1"use client";23import { useEffect, useMemo, useRef, useState } from "react";4import Lenis from "lenis";56import {7 HorizontalDepthFade,8 type HorizontalDepthFadeProps,9} from "@/components/unlumen-ui/horizontal-depth-fade";1011type HorizontalDepthFadeDemoProps = Pick<12 HorizontalDepthFadeProps,13 | "travel"14 | "blur"15 | "dim"16 | "brightnessBoost"17 | "darknessStrength"18 | "minSaturation"19 | "saturationStrength"20 | "focusSpread"21 | "scaleEffect"22 | "scrollSensitivity"23 | "gap"24 | "itemWidth"25 | "itemHeight"26 | "scrollLength"27> & {28 imageCount?: number;29 smooth?: boolean;30};3132export default function HorizontalDepthFadeDemo({33 travel = 100,34 blur = 10,35 dim = 20,36 brightnessBoost = 55,37 darknessStrength = 1.35,38 minSaturation = 0,39 saturationStrength = 1.35,40 focusSpread = 0.14,41 scaleEffect = 0.11,42 scrollSensitivity = 0.6,43 gap = 24,44 itemWidth = 360,45 itemHeight = 460,46 scrollLength = 360,47 imageCount = 20,48 smooth = true,49}: HorizontalDepthFadeDemoProps) {50 const scrollContainerRef = useRef<HTMLDivElement>(null);51 const contentRef = useRef<HTMLDivElement>(null);52 const [previewWidth, setPreviewWidth] = useState(900);5354 useEffect(() => {55 const node = scrollContainerRef.current;56 if (!node) return;5758 const update = () => setPreviewWidth(node.clientWidth || 900);59 update();6061 const observer = new ResizeObserver(update);62 observer.observe(node);6364 return () => observer.disconnect();65 }, []);6667 useEffect(() => {68 const wrapper = scrollContainerRef.current;69 const content = contentRef.current;70 if (!smooth || !wrapper || !content) return;7172 const lenis = new Lenis({73 wrapper,74 content,75 smoothWheel: true,76 wheelMultiplier: 0.95,77 lerp: 0.09,78 });7980 let rafId = 0;81 const raf = (time: number) => {82 lenis.raf(time);83 rafId = window.requestAnimationFrame(raf);84 };8586 rafId = window.requestAnimationFrame(raf);8788 return () => {89 window.cancelAnimationFrame(rafId);90 lenis.destroy();91 };92 }, [smooth]);9394 const images = useMemo(() => {95 const targetWidth = Math.max(220, Math.round(itemWidth));96 const targetHeight = Math.max(260, Math.round(itemHeight));97 const qualityBias = Math.max(1, Math.round(previewWidth / 900));9899 return Array.from({ length: imageCount }, (_, i) => ({100 src: `https://picsum.photos/seed/hbs${i + 1}/${targetWidth * qualityBias}/${targetHeight * qualityBias}`,101 alt: `Demo image ${i + 1}`,102// … truncated
What it pulls in
Other registry items
More from Unlumen Ui
All 233 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| AI Chatai-chat | Unlumen Ui | Components | Paid | 2 deps | |
| Vercel Animate Countanimate-count | Unlumen Ui | Components | Free | 1 dep | |
| Animate Digitsanimate-digits | Unlumen Ui | Components | Free | 1 dep | |
| Animated Inputanimate-text-input-typing | Unlumen Ui | Components | Paid | 1 dep | |
| Animated Listanimated-list | Unlumen Ui | Components | Free | 1 dep | |
| Apple Switchapple-switch | Unlumen Ui | Components | Free | 1 dep | |
| Aurora Barsaurora-bars | Unlumen Ui | Components | Free | 1 dep | |
| Aurora Bluraurora-blur | Unlumen Ui | Components | Free | 2 deps |
