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`
<div>
${draggable.render('Drag me')}
</div>
`
}
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
.