12.9K ·GitHub
What is this?
interact.js is a JavaScript library that adds drag and drop, resizing, and multi-touch gesture support to web elements, with built-in inertia and snapping effects.
Is it a framework or a library?
It's a standalone library, not a framework: it doesn't touch the DOM besides optionally changing the cursor, and it works alongside any other code or framework.
How do I add it to a project?
Install via npm with 'npm install interactjs', or pull it from the jsDelivr/unpkg CDN; there's also a Rails 5.1+ gem path (yarn add interactjs plus a require line) and a Webjars dependency for SBT/Play 2.
Do I need TypeScript to use it?
No. It's written in TypeScript and ships type definitions in the npm package, but you can also install the typings standalone if you just want them for a plain JS project.
Does it work on older browsers like IE?
Yes, it specifically supports IE9 and up in addition to modern desktop and mobile versions of Chrome, Firefox, and Opera.
Does it work with touch devices and SVG?
Yes, it handles multi-touch and simultaneous interactions across devices, and it can interact with SVG elements directly.
What does the inertia and snapping feature actually do?
Inertia lets dragged or resized elements keep moving briefly after release like a physical object would, while snapping locks elements to a grid or specific points during interaction.
Can I run multiple drag/resize interactions on the page at once?
Yes, it supports multi-touch with simultaneous interactions, so multiple gestures can be handled at the same time.
Is there a live demo to see it in action?
Yes, the README links to a working example page showing the library's code running live.
What are similar projects?
dragula, lenis, headroom.js, slick, filepond, react-sortable-hoc, Sortable, draggable
Which topics is it in?
snap, touch, drag-and-drop, responsive, animation, css, browser, mobile, ui, web-development, gui, npm