BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/fancy/use-elastic-line-events

Use Elastic Line Events

fancy/use-elastic-line-events
FreeHook

A hook component.

Install it

npx shadcn@latest add https://www.fancycomponents.dev/r/use-elastic-line-events.json

Source

hooks/use-elastic-line-events.tswww.fancycomponents.dev/r/use-elastic-line-events.json
1import { useEffect, useState } from "react"
2
3import { useDimensions } from "@/hooks/use-dimensions"
4import { useMousePosition } from "@/hooks/use-mouse-position"
5
6interface ElasticLineEvents {
7 isGrabbed: boolean
8 controlPoint: { x: number; y: number }
9}
10
11export function useElasticLineEvents(
12 containerRef: React.RefObject<SVGSVGElement | null>,
13 isVertical: boolean,
14 grabThreshold: number,
15 releaseThreshold: number
16): ElasticLineEvents {
17 const mousePosition = useMousePosition(containerRef)
18 const dimensions = useDimensions(containerRef)
19 const [isGrabbed, setIsGrabbed] = useState(false)
20 const [controlPoint, setControlPoint] = useState({
21 x: dimensions.width / 2,
22 y: dimensions.height / 2,
23 })
24
25 useEffect(() => {
26 if (containerRef.current) {
27 const { width, height } = dimensions
28 const x = mousePosition.x
29 const y = mousePosition.y
30
31 // Check if mouse is outside container bounds
32 const isOutsideBounds = x < 0 || x > width || y < 0 || y > height
33
34 if (isOutsideBounds) {
35 setIsGrabbed(false)
36 return
37 }
38
39 let distance: number
40 let newControlPoint: { x: number; y: number }
41
42 if (isVertical) {
43 const midX = width / 2
44 distance = Math.abs(x - midX)
45 newControlPoint = {
46 x: midX + 2.2 * (x - midX),
47 y: y,
48 }
49 } else {
50 const midY = height / 2
51 distance = Math.abs(y - midY)
52 newControlPoint = {
53 x: x,
54 y: midY + 2.2 * (y - midY),
55 }
56 }
57
58 setControlPoint(newControlPoint)
59
60 if (!isGrabbed && distance < grabThreshold) {
61 setIsGrabbed(true)
62 } else if (isGrabbed && distance > releaseThreshold) {
63 setIsGrabbed(false)
64 }
65 }
66 }, [mousePosition, isVertical, isGrabbed, grabThreshold, releaseThreshold])
67
68 return { isGrabbed, controlPoint }
69}

Files it writes

  • hooks/use-elastic-line-events

Facts

Registry
fancy
Type
registry:hook
Access
Free
Files written
1
Licence
the repository states none
In the index
at or before 2026-08-11
Last confirmed
today

Go to the source

www.fancycomponents.dev danielpetho/fancy on GitHub Raw registry item This item as JSON

More from fancy

All 158 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Use Debounced Dimensionsuse-debounced-dimensionsfancyHooksFreeno deps
Use Detect Browseruse-detect-browserfancyHooksFreeno deps
Use Dimensionsuse-dimensionsfancyHooksFreeno deps
Use Line Breakdownuse-line-breakdownfancyHooksFreeno deps
Use Line Countuse-line-countfancyHooksFreeno deps
Use Mounteduse-mountedfancyHooksFreeno deps
Use Mouse Positionuse-mouse-positionfancyHooksFreeno deps
Use Mouse Position Refuse-mouse-position-reffancyHooksFreeno deps

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

ToolDrift

What the AI coding tools changed last night

tooldrift.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex