interact.js: A Pointer-Events Library for Drag, Drop, Resize and Gestures
JavaScript drag and drop, resizing and multi-touch gestures with inertia and snapping for modern browsers (and also IE9+)
At a glance
- What is it?
- interact.js is a TypeScript library that adds drag, drop, resize and multi-touch gestures to any web page, with inertia and snapping. It targets modern browsers and IE9+, and it does not modify the DOM except for the cursor.
- Who is it for?
- Adopt interact.js if you need drag, drop, resizing or gesture support in a web app and want a standalone library that works across desktop and mobile browsers, including IE9+. It is a good fit for canvas-based interactions, SVG manipulation, or any UI where you want to avoid heavy framework dependencies.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 46 days ago.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
The Problem: Inconsistent Pointer Handling Across Browsers
Web developers who need drag and drop, resizing or pinch gestures face a fragmented landscape. The native HTML5 drag and drop API has poor touch support and inconsistent behavior across browsers. Pointer Events are standardized but not uniformly implemented, and older browsers like IE9 require vendor-specific handling. interact.js solves this by providing a unified API that works with mouse, touch and pen input, and it promises support for IE9+, which is a rare claim in 2024. The library is aimed at developers building interactive interfaces, from simple draggable cards to complex canvas editors, who want a single codebase that behaves the same on desktop and mobile.
How It Works: Pointer Events and Modifiers
interact.js is built on top of the Pointer Events API, with fallbacks for older browsers. The core mechanism is that you call interact() on a selector or element, and then chain methods like .draggable() or .resizable() to define the interaction. The library handles the event lifecycle internally, firing move events with properties like event.dx and event.dy that represent the delta from the last move. What stands out is the modifier system. The README shows a snap modifier that snaps to a grid, created with interact.modifiers.snap() and a snapper function like interact.snappers.grid(). This is a declarative way to apply constraints, and it is separate from the interaction itself. The library also supports inertia, which adds a physics-based glide after the user releases the pointer, and it can handle multiple simultaneous interactions, which is essential for multi-touch gestures. The documentation states that it does not modify the DOM except for the cursor, which is a deliberate design choice to keep the library lightweight and predictable.
Getting Started: Installation and a Concrete Example
Installation is straightforward. You can use npm with 'npm install interactjs', or load it from a CDN like jsDelivr or unpkg with a script tag pointing to dist/interact.min.js. For Rails 5.1+, you add it via Yarn and then require it with '//= require interactjs/interact'. The npm package includes TypeScript definitions, which is useful for TypeScript projects, and you can install the typings alone with 'npm install --save-dev @interactjs/types'. The README provides a working example: a canvas element with the class 'rainbow-pixel-canvas' is made draggable. The code sets an origin of 'self', which means the drag coordinates are relative to the element itself. It then defines a snap modifier that snaps to a grid with a pixel size of 16. On the move event, it calculates the drag angle using Math.atan2(event.dx, event.dy) and draws colored squares. This example shows the key API surface: the interact() factory, the .draggable() method with a modifiers array, and the listener object with a move callback.
Limitations and Failure Modes
The library is not a drop-in solution for every interaction. The README mentions that it supports SVG elements, which is a strength, but it does not mention support for complex drop zones like nested droppables or sorting. If you need a sortable list with reordering, you would need to build that logic yourself. Another limitation is that the library only changes the cursor by default, which means you have to implement visual feedback like element repositioning or resizing manually. The example does this by drawing on a canvas, but for DOM elements you would need to update style.left and style.top in the move listener. The documentation is not included in the README, so you must rely on the docs site for advanced topics like custom gestures or pointer event handling. Also, the 'upcoming changes' link in the README suggests that the API may change, so you need to check the CHANGELOG before upgrading. There is no mention of accessibility features like keyboard support or ARIA attributes, which could be a problem for users who rely on assistive technology.
Alternatives: Native HTML5 Drag and Drop vs. interact.js
The most direct alternative is the native HTML5 drag and drop API. It is built into browsers, requires no library, and supports dragstart, dragover and drop events. However, it has significant drawbacks: it does not work with touch events on most mobile browsers without polyfills, it is limited to dragging DOM elements (not canvas or SVG as easily), and it does not provide inertia or snapping out of the box. interact.js takes a different approach by abstracting pointer input and providing a consistent API across mouse, touch and pen. For resizing, native HTML5 has no built-in resizing API, so you would need to implement it manually with mousedown/mousemove listeners. interact.js gives you .resizable() directly. The trade-off is that interact.js adds a dependency and you must learn its API, whereas native drag and drop is zero-cost but limited. If you only need basic drag and drop on desktop, native might suffice, but for multi-touch gestures and resizing, interact.js is more practical.
Maintenance and Upgrade Cost
The repository is written in TypeScript and has an active CI workflow, as indicated by the workflow badge in the README. It is not archived, and the default branch is main, but the README does not state the last release date or the latest version number. The 'upcoming changes' link in the CHANGELOG suggests that breaking changes are planned, which means you should pin a specific version in your package.json and review the changelog before upgrading. The npm package includes type definitions, which helps with type checking during upgrades, but it also means that API changes may require updating your TypeScript code. The library is MIT licensed, so you can use it in commercial projects without restriction, but you must retain the copyright notice. There is no mention of a maintenance guarantee or a roadmap, so you should treat it as a community project and be prepared to fork it if needed.
Who Should Use It and What to Verify First
interact.js is a solid choice for developers building interactive prototypes, canvas-based editors, or dashboards that need drag, resize and touch gestures without a heavy framework. It is especially useful if you need to support IE9+, which is rare in modern libraries. However, if you are building a production app with complex accessibility requirements or you need a full-featured drag-and-drop library like SortableJS, you might want to look elsewhere. Before adopting it, verify the current version on npm and check the CHANGELOG for any upcoming breaking changes. Also, test the library on the specific browsers and devices you support, especially touch devices, because the README only claims support, it does not detail edge cases. The library's promise of not modifying the DOM is a double-edged sword: it keeps things clean, but you must handle all visual updates yourself, which can be error-prone. If you are comfortable with that, interact.js is a lightweight and flexible tool.
Editorial conclusion
Adopt interact.js if you need drag, drop, resizing or gesture support in a web app and want a standalone library that works across desktop and mobile browsers, including IE9+. It is a good fit for canvas-based interactions, SVG manipulation, or any UI where you want to avoid heavy framework dependencies. Do not adopt it if you need complex nested drop zones, full accessibility support, or if you are on a modern-only codebase that can rely on native HTML5 drag and drop, which has simpler semantics for some use cases. Before adopting, verify the current state of the CHANGELOG, especially the 'upcoming changes' section, to see if any breaking changes affect your target browser or use case. Also test touch and pointer event behavior on the specific devices you support, since the library's behavior on older IE versions may differ from modern browsers.
Community notes