interact.js adds drag-and-drop, resizing, and multi-touch gestures with inertia and snapping for modern browsers. You control how elements move using pointer event data.
Overview
interact.js is a JavaScript library for drag-and-drop, resizing, and multi-touch interactions in web pages. It targets modern browsers and legacy Internet Explorer 9 and up, with TypeScript types shipped in the npm package.
Rather than moving DOM nodes itself, the library exposes pointer data through a flexible API so you choose how elements, canvases, or scrolling behave. Features include inertia, snap and restriction modifiers, simultaneous interactions, auto-scroll, and support for HTML and SVG targets.
It aims to stay standalone and configurable, avoid altering the DOM beyond optional cursor changes, and unify mouse and touch handling. Installation is via yarn or npm as interactjs.
Demos on the project site illustrate dragging, dropzones with overlap rules, grid snapping, resizable edges, rotation and pinch gestures on touchscreens, tap and hold events, and SVG-based examples.
Key features
- Draggable and resizable targets
- Dropzones with overlap thresholds
- Inertia and snap modifiers
- Multi-touch gesturable areas
- Auto-scroll while dragging
- HTML and SVG element support
- Unified mouse and touch API
- Optional cursor-only DOM changes
Use cases
- Custom drag-and-drop UIs
- Touch-friendly dashboards
- Interactive canvas tools
- Grid-aligned layout editors
- Gesture controls on mobile web