A lightweight module for dragging elements using CSS transforms


stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
20Feb 23, 2017Oct 27, 2016Minified + gzip package size for @bufferapp/dragme in KB



NPM Version

A super lightweight module for dragging elements using CSS3 Transforms. The goal of this module is to be a minimal way to make certain elements draggable on a page, i.e. modal windows.

Dragme makes use of some modern JS APIs – make sure to polyfill it depending on the browser support wanted:

  • Element.classList
  • Object.assign()
  • Element.closest()


npm install @bufferapp/dragme


const dragMe = new DragMe(document.querySelector('#draggable-component'));

Prevent dragging on certain elements:

const dragMe = new DragMe(document.querySelector('#draggable-component'), {
  cancel: 'textarea, .button',

Cleanup bindings to disable a DragMe instance:


Listen to when dragging starts and stops using callbacks:

const dragMe = new DragMe(document.querySelector('#draggable-component'), {
  onDragStart: () => console.log('Started dragging'),
  onDragEnd: () => console.log('Stopped dragging'),


  • Use requestAnimationFrame for smoother movement


Bug fixes or improvements welcome!


This builds upon jwilsson's non-jQuery fork of Buffer's jQuery DragMe.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.