Top posts

Every blog post that took off on Hacker News, ranked by the votes of its best submission. 4,614 posts.

Web & Frontend
Any year
80

Draggable objects

Many of my interactive pages have a draggable object . I want the reader to move the object around, and I want the diagram to respond in some way. Here I’ll document the code I use to make this work with both mouse and touch input, using browser features that are widely supported since 2020. Here’s a common case I…