This package allows you to make multiple elements draggable simultaneously.
type InteractionLocation
= GraphNode Int
| Label IntviewGraphNode: Int -> Node -> Html Msg
viewGraphNode key node =
div
[ Drag.onMouseDownWithOptions
{ stopPropogation = False, preventDefault = False }
(GraphNode key)
-- ...
]
[ text <| "Graph Node " ++ (String.fromInt key) ] (Drag.Start location currentMousePosition) as dragMsg ->
{ model | dragState = Drag.update dragMsg model.dragState }
(Drag.Moved location currentMousePosition) as dragMsg ->
let
(dx, dy) = Drag.delta dragMsg model.dragState
updatedModel =
{ model | dragState = Drag.update dragMsg model.dragState }
in
case location of
GraphNode key ->
-- Handle the drag of the node ...
Label key ->
-- Handle the drag of a label ...
(Drag.End location currentMousePosition) as dragMsg ->
{ model | dragState = Drag.update dragMsg model.dragState }
(Drag.Click location currentMousePosition) as dragMsg ->
{ model | dragState = Drag.update dragMsg model.dragState }
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.batch
[ Drag.subscriptions
--, ... your subscriptions
]