ir4y/elm-dnd/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

DnD

This library allow you to simple build grate ui with drag-and-drop. It is astracting you from mouse events and other low level staff. You can operate high livel things such as draggable and droppable areas.

Draggable type

type alias Draggable a =
Maybe
{ meta : a
, position : Position
, atDroppable : Bool
}

Type of Draggable object it could be Nothing or Just object It is parametrized by the type of meta information.

#Helper to get information about draggable object

atDroppable : Draggable a -> Bool

Helper that allow you to check if draggable object over valid droppable area

getMeta : Draggable a -> Maybe a

Helper that allow you to get meta information from draggable object

#Message type

type Msg a

Inner messages, you should pass them to DnD.update at your update function

#Subscriptions

subscriptions : (a -> m) -> (Msg a -> m) -> Draggable a -> Sub m

Subscriptions alow you to get drop event

#update function

update : Msg a -> Draggable a -> Draggable a

Update function handle all low level staff

#viwe helpers

draggable : (Msg a -> m) -> a -> List (Attribute m) -> List (Html m) -> Html m

View wrapper for draggable object, you could drag object wraped by this helper

droppable : (Msg a -> m) -> List (Attribute m) -> List (Html m) -> Html m

View helper for droppable area, you could drop object to this area, after that your ondrop command will fire

dragged : Draggable a -> (a -> Html m) -> Html m

View helper for draggable object, it drows html of dragged object under your mouse in process of drag