This library makes it easy to implement HTML5 drag-and-drop operations with Elm and @danielnarey's Modular Ui framework.
Ui.Element nodes can be made draggable and droppable, with the state represented by an opaque object you can store in your model.
Each draggable/droppable element should correspond to some kind of id. This could be an (id for an) item in a list, a tag value from a type representing the various draggable/droppable elements, or whatever you want.
Your application must provide messages for each of the events triggered by this framework. The library provides helper methods to query and update the current state.
This method will tell you whether a given item is currently being hovered over to allow you to provide a visual hint.
This method will return the currently dragged item (if any). Note that this will return the id (data) that corresponds to the Ui.Element node being dragged, rather than the actual DOM node itself.
This method will tell you whether the dragged element (if any) is currently over a drop zone.
The initial state on page load, with nothing being dragged or dropped.
When the dragStarted message is received by your app, call this method to update the state with the newly-dragged object.
When dragging stops because either the dragEnded or dropped message were received or the user has done something else in your application, call this method to update the state appropriately.
When the user drags an element over a potential drop zone and the dropTargetChanged message is received by your app, call this method to update the state with the currently targeted drop zone.
Messages the Ui.DragDrop framework will send to your application as events occur. It is up to your application to call the appropriate Ui.DragDrop update function and store the result in your model.
makeDraggable makes an element draggable. When an element is being dragged, it will gain the "being-dragged" CSS class, with which you can control the display of the moving element.
makeDroppable marks an element as a place that a dragged object can be dropped onto. If the dragged object is currently hovering over the droppable element, it gains the CSS class "drop-target" to allow for appropriate visual indication.
An opaque container for state data.