Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including nanodraggable with all npm packages installed. Try it out:

var nanodraggable = require("nanodraggable")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

nanodraggable v1.0.0

Draggable nanocomponent


Draggable nanocomponent


npm i -S nanodraggable


var Nanodraggable = require('nanodraggable')
var html = require('choo/html')

class DraggableObject extends Nanodraggable {
  constructor(x, y) {
    super(x, y)

  content(text) {
    return html`<div>${text}</div>`

var draggable = new DraggableObject(0, 0)

function view (state, emit) {
  return html`
      ${draggable.render('Drag me')}


draggable = Draggable(x, y)

Creates a new component. Takes x and y as default position.


An abstract function to override that returns the content of the draggable component. The arguments from the render function are forwarded to this.


An optional abstract function to override. Called on mousedown.


An optional abstract function to override. Called on mouseup.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free