finds.dev

bcherny/draggable

High performance, fully cross browser, full featured drag and drop in a tiny (2k gzipped), dependency-free package

View on GitHubHomepage ↗

★ 203JavaScriptMITupdated Dec 2022

// the take

draggable is a dependency-free JavaScript library that makes a DOM element draggable, with grid snapping, drag handles, bounds limits and a start threshold, in about 2k gzipped. It suits someone who needs simple element dragging on a page without a framework or a drag-and-drop library, and who does not need drop targets or sortable lists.

The limit option is the most useful part. It accepts an element, per-axis ranges, a fixed value per axis, or a function that receives the current and origin coordinates, and the README's circular-radius example shows the function form doing real geometry instead of rectangle clamping. smoothDrag defaults to snapping to the grid only on drop, so the element moves freely and snaps on release. The runtime surface is small and explicit: get, set and setOption cover control after creation, and destroy removes the listeners.

The last push was in December 2022, and the tested-on list stops at Chrome 29, Firefox 23, Safari 6 and IE 8 to 10. Nothing in the README shows that touch and pointer handling has been checked against current browsers or iOS, and the to-do list admits there are no unit tests. The README says nothing about keyboard or screen-reader access, which matters if the dragged content must stay reachable without a mouse. It ships as browser globals, AMD or CommonJS, with no documented ES module export or TypeScript typings, and the examples use var, so using it in a modern build means writing your own wrapper.

We read the README, the directory tree and a key source file in October 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
203
Forks
53
Language
JavaScript
License
MIT
Last commit
8 Dec 2022

// nearby

If draggable isn't quite it.

All repos →