Documentation Index
Fetch the complete documentation index at: https://mintlify.com/apursley2012/spooky-developer/llms.txt
Use this file to discover all available pages before exploring further.
SpiderScare delivers a one-shot jump-scare: the first time a visitor clicks anywhere on the page, a SpiderIcon rappels down from off-screen on a gossamer thread, lingers at mid-viewport, then retreats back into the shadows. Because the trigger is captured by hasClicked from HauntContext and persisted via sessionStorage, the spider fires exactly once per browser session — closing and reopening the tab resets it, but a full-page refresh within the same session does not.
Prerequisites
SpiderScare must be rendered inside a HauntProvider. It consumes three values from useHaunt():
| Value | Type | Purpose |
|---|---|---|
isHaunted | boolean | Guards the click listener entirely |
hasClicked | boolean | Prevents retriggering after the first click |
registerClick() | function | Marks the click in state and sessionStorage |
motion.div and AnimatePresence.
Trigger logic
Aclick listener is attached to window on mount and torn down on unmount. The handler only acts when isHaunted is true and hasClicked is false:
registerClick() is called immediately so that any subsequent clicks during the 4-second display window are ignored.
registerClick() writes "true" to sessionStorage under the key haunt-clicked. The spider will fire again on a fresh browser session (new tab, or after the session storage is cleared), but not on a simple page refresh within the same session.Animation
The spider is amotion.div wrapped in AnimatePresence. It enters from y: '-100vh' (entirely above the viewport) and plays a four-keyframe sequence that simulates swinging on a thread before retreating:
| Time | y | x | What the user sees |
|---|---|---|---|
0 s (t=0) | -100vh | 50vw | Spider hidden above viewport, centred |
1.6 s (t=0.4) | 20vh | 45vw | Spider drops to 20 % down, swings left |
2.4 s (t=0.6) | 20vh | 55vw | Spider hangs at 20 %, swings right |
4 s (t=1) | -100vh | 50vw | Spider retreats back off-screen |
Visual structure
Themotion.div uses flex flex-col items-center to stack two children vertically:
Thread
100 vh tall pulled upward with -mt-[100vh], creating the illusion of an infinitely long silk thread receding above the spider.
Spider icon
64 × 64 px (w-16 h-16) in the teal haunt-moon colour, set on a dark rounded background with a teal glow shadow (rgba(94,234,212,0.3)).
z-index and pointer events
The entiremotion.div is fixed top-0 left-0 z-[9999] pointer-events-none, placing the spider above all other page content while ensuring it never captures mouse events or prevents clicks on the underlying page.