Skip to content

annaghi/dnd-list

Repository files navigation

Latest Version Build Status

DnD List

Drag and Drop for sortable lists in Elm web apps with mouse support.

Demos and Sources

Examples

$ npm install -g elm elm-live
$ npm run watch

Basic API

create : DnDList.Config a -> Msg -> DnDList.System a Msg
update: 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.Info

Config

pseudocode type alias Config a =
    { beforeUpdate : DragIndex -> DropIndex -> List a -> List a

    , movement : Free
               | Horizontal
               | Vertical

    , listen : OnDrag
             | OnDrop

    , operation : InsertAfter
                | InsertBefore
                | Rotate
                | Swap
                | Unaltered
    }

Info

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 }
    }

Real Projects

  • Risk Register by ProjectBalm is a risk management add-on for Atlassian Jira.
    dnd-list is used in the risk model editor for re-ordering risk levels, and is even used to re-order the rows and columns of the risk matrix.

Credits

This package was inspired by the following shiny gems:

About

Drag and Drop for sortable lists in Elm web apps with mouse support

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages