Drag and Drop for sortable lists in Elm web apps with mouse and pointer support.
$ npm install -g elm elm-live
$ npm run watchcreate : DnDList.Config a -> Msg -> DnDList.System a Msg
port onPointerMove : (Json.Encode.Value -> msg) -> Sub msg
port onPointerUp : (Json.Encode.Value -> msg) -> Sub msg
port releasePointerCapture : Json.Encode.Value -> Cmd msg
createWithTouch :
Config a
-> (Msg -> msg)
-> ((Json.Encode.Value -> msg) -> Sub msg) -- onPointerMove
-> ((Json.Encode.Value -> msg) -> Sub msg) -- onPointerUp
-> (Json.Encode.Value -> Cmd msg) -- releasePointerCapture
-> System a msgupdate: DnDList.Msg -> DnDList.Model -> List a -> ( DnDList.Model, List a )
dragEvents : DragIndex -> DragElementId -> List (Html.Attribute Msg)
dropEvents : DropIndex -> DropElementId -> List (Html.Attribute Msg)
ghostStyles : DnDList.Model -> List (Html.Attribute Msg)
info : DnDList.Model -> Maybe DnDList.Infopseudocode type alias Config a =
{ beforeUpdate : DragIndex -> DropIndex -> List a -> List a
, movement : Free
| Horizontal
| Vertical
, listen : OnDrag
| OnDrop
, operation : InsertAfter
| InsertBefore
| Rotate
| Swap
| Unaltered
}type alias Info =
{ dragIndex : Int
, dropIndex : Int
, dragElementId : String
, dropElementId : String
, dragElement : Browser.Dom.Element
, dropElement : Browser.Dom.Element
, startPosition : { x : Float, y : Float }
, currentPosition : { x : Float, y : Float }
}This package was inspired by the following shiny gems: