ember-dnd-helpers v0.1.0
ember-dnd-helpers
(drag-set 'plain/text' 'some text')
Use in ondragstart event handler to set data on the event. (drag-set 'plain/text' 'some text') is equivalent to calling event.dataTrasfer.setData('plain/text') in the event handler.
<div draggable="true" ondragstart={{action (drag-set 'plain/text' 'some text')}}></div>This helper can accept application/json mime type in which case it will JSON.stringify the received data.
<div draggable="true" ondragstart={{action (drag-set "application/json" (hash id=123 color='red'))}}></div>(drag-get 'plain/text')
Use in ondrop event handler to retrieve data set with event.dataTransfer.setData. (drag-get 'plain/text') is equivalent to event.dataTransfer.getData('plain/text').
<div ondrop={{action (pipe (prevent-default) (drag-get 'plain/text') (action 'dosomething'))}}></div>This helper can accept application/json mime type in which case it will JSON.parse the received data.
(prevent-default)
Calls event.preventDefault().
`(stop-propagating)
Calls event.stopPropagating().
(drop-effect 'move')
Applies specified drop effect onto the event. Equivalent to calling even.dropEvent = move;
Installation
git clonethis repositorynpm installbower install
Running
ember server- Visit your app at http://localhost:4200.
Running Tests
npm test(Runsember try:testallto test your addon against multiple Ember versions)ember testember test --server
Building
ember build
For more information on using ember-cli, visit http://ember-cli.com/.
Credits
Thank you Miguel Camba for suggesting to try doing drag and drop with pure events.