Skip to content

No.435 · Media

Image Compare

Two pictures of the same object in one frame, split by a jelly line that bows when you drag fast and wobbles back straight.

The prompt

Copy this text

Automatic copying is unavailable. Copy the selected text using your device’s copy command.

Written for the variant you picked above: X-ray

Build a before/after image comparison whose divider behaves like jelly. Both pictures are the same scene at the same size, stacked in one 8:5 frame (18px radius, deep shadow); the left picture is clipped to the left of the divider. The knob sets x. The divider's ends chase it on a soft spring integrated every frame — v += ((x − e)·620 − v·44)·dt, e += v·dt (slightly under-damped, so it overshoots once) — and the curve is a quadratic from (e, 0) to (e, h) whose control point is 2x − e, so the middle always passes through the knob. The left picture is cut along exactly that curve with clip-path: path("M0 0 L e 0 Q (2x−e) h/2 e h L0 h Z"), and an SVG path draws the same curve as a 2px seam with a soft shadow. The loop stops once the ends settle. Pointer down anywhere jumps the knob there and drags it (pointer capture; touch-action pan-y so vertical scrolling still works). The knob is a 44px round handle with ⟨ ⟩ chevrons that grows slightly while hovered or dragged, and two frosted mono pills label the sides. The demo pictures are one illustrated camera drawn twice from the same SVG geometry — a colour product shot and a second "inside" render that shows the battery, board, shutter and sensor — so the halves line up exactly. Selected variant — X-ray (xray): Inside render as an x-ray: near-black navy (#03070f) with glowing pale blue-white lines (#dff1ff) and a blue glow (#6fb6ff) through a blur-and-merge filter; seam and knob in #e8f4ff; left label "X-ray". This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Drag anywhere in the frame (or click to jump) to move the divider; fast moves bow the line and it springs straight. Motion: Divider ends: spring k 620, damping 44, integrated per frame with dt; knob scale 200ms. Accessibility: The knob is a role="slider" (0–100) labelled with both sides, with arrows (Shift ×5), Page Up/Down, Home and End. Reduced motion moves the line rigidly with no spring. Responsive behavior: Keeps its 8:5 aspect at any width; the clip path is rebuilt from measured size on resize. Touch: Touch drags move the divider horizontally while vertical swipes still scroll the page. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.

Notes

Interaction
Drag anywhere in the frame (or click to jump) to move the divider; fast moves bow the line and it springs straight.
Motion
Divider ends: spring k 620, damping 44, integrated per frame with dt; knob scale 200ms.
Accessibility
The knob is a role="slider" (0–100) labelled with both sides, with arrows (Shift ×5), Page Up/Down, Home and End. Reduced motion moves the line rigidly with no spring.
Responsive
Keeps its 8:5 aspect at any width; the clip path is rebuilt from measured size on resize.
On touch
Touch drags move the divider horizontally while vertical swipes still scroll the page.