ractive-drag-events
v0.1.1
Published
HTML5 drag/drop proxy events for a Ractive element
Downloads
21
Readme
ractive-drag-events
Adds HTML5 drag/drop proxy events to a Ractive element.
Code is loosely inspired by
these updates to
this module.
Difference with this module is that it applies events to a given element
rather than to all its children, and it doesn't clobber
the element's draggable
attribute.
Usage
- Require or include Ractive and this project
- Add
on-dragndrop='foo'
to something in the template - Add
ractive.on('foo', fn)
in your source
Example
var ractive = new Ractive({
el: '#container',
template: '<div on-dragndrop="DND" draggable="true">{{text}}</div>',
data: {
text: 'Drag me!'
}
})
ractive.on('DND', function(event) {
console.log(event)
}
See live demo or example/index.html
for a full example.
Event Object
type
- One of: [start
,enter
,over
,leave
,drop
,end
]context
- Ractive context of the event itemkeypath
- Ractive keypath of the event itemnode
- HTML element of the event itemoriginal
- the original DOM MouseEvent
Note that the event item is the item being dragged for start/end events, and the item you're dragging to for all the others.