zaboco / elm-draggable / Draggable.Events

Listeners for the various events involved in dragging (onDragBy, onDragStart, etc.). Also handles click events when the mouse was not moved.

onDragStart : (a -> msg) -> Internal.Config a msg -> Internal.Config a msg

Register a DragStart event listener. It will not trigger if the mouse has not moved while it was pressed. It receives the element key.

onDragEnd : msg -> Internal.Config a msg -> Internal.Config a msg

Register a DragEnd event listener. It will not trigger if the mouse has not moved while it was pressed.

onDragBy : (Internal.Delta -> msg) -> Internal.Config a msg -> Internal.Config a msg

Register a DragBy event listener. It will trigger every time the mouse is moved. The sent message will contain a Delta, which is the distance between the current position and the previous one.

case Msg of
    OnDragBy ( dx, dy ) ->
        { model | position = { x = position.x + dx, y = position.y + dy } }

onClick : (a -> msg) -> Internal.Config a msg -> Internal.Config a msg

Register a Click event listener. It will trigger if the mouse is pressed and immediately release, without any move. It receives the element key.

onMouseDown : (a -> msg) -> Internal.Config a msg -> Internal.Config a msg

Register a MouseDown event listener. It will trigger whenever the mouse is pressed and will indicate the target element by the given key.