glowing-effect
obsidianui/glowing-effectFreeComponent
obsidianui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by obsidianui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://obsidianui.dev/r/glowing-effect.jsonSource
1"use client";23import { memo, useCallback, useEffect, useRef, useState } from "react";4import { cn } from "@/lib/utils";56interface GlowingEffectProps {7 blur?: number;8 inactiveZone?: number;9 proximity?: number;10 spread?: number;11 variant?: "default" | "white";12 glow?: boolean;13 className?: string;14 disabled?: boolean;15 movementDuration?: number;16 borderWidth?: number;17}1819const GlowingEffect = memo(20 ({21 blur = 0,22 inactiveZone = 0.01,23 proximity = 100,24 spread = 40,25 variant = "default",26 glow = true,27 className,28 movementDuration = 0.15,29 borderWidth = 2,30 disabled = false,31 }: GlowingEffectProps) => {32 const containerRef = useRef<HTMLDivElement>(null);33 const angleRef = useRef(0);34 const [angle, setAngle] = useState(0);35 const [isActive, setIsActive] = useState(false);36 const animationRef = useRef<number>();3738 const handlePointerMove = useCallback(39 (e: PointerEvent) => {40 if (disabled || !containerRef.current) return;4142 const element = containerRef.current;43 const rect = element.getBoundingClientRect();44 const mouseX = e.clientX;45 const mouseY = e.clientY;4647 const centerX = rect.left + rect.width / 2;48 const centerY = rect.top + rect.height / 2;4950 // Check proximity51 const isWithinProximity =52 mouseX > rect.left - proximity &&53 mouseX < rect.right + proximity &&54 mouseY > rect.top - proximity &&55 mouseY < rect.bottom + proximity;5657 if (!isWithinProximity) {58 setIsActive(false);59 return;60 }6162 setIsActive(true);6364 // Calculate target angle65 const targetAngle = Math.atan2(mouseY - centerY, mouseX - centerX) * (180 / Math.PI) + 90;6667 // Smooth angle interpolation68 const currentAngle = angleRef.current;69 let diff = targetAngle - currentAngle;7071 // Handle 360-degree wrap72 if (diff > 180) diff -= 360;73 if (diff < -180) diff += 360;7475 const newAngle = currentAngle + diff * 0.15; // Smooth factor76 angleRef.current = newAngle;77 setAngle(newAngle);78// … truncated
Files it writes
More from obsidianui
All 111 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ai-inputai-input | obsidianui | Components | Free | 2 deps | |
| alertalert | obsidianui | Components | Free | no deps | |
| animated-tab-baranimated-tab-bar | obsidianui | Components | Free | no deps | |
| apple-spotlightapple-spotlight | obsidianui | Components | Free | 2 deps | |
| avataravatar | obsidianui | Components | Free | 1 dep | |
| badgebadge | obsidianui | Components | Free | 1 dep | |
| breadcrumbbreadcrumb | obsidianui | Components | Free | 2 deps | |
| buttonbutton | obsidianui | Components | Free | 1 dep |
