zaboco/elm-draggable/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Draggable.Events

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

onDragStart : msg -> Event msg

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

onDragEnd : msg -> Event msg

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

onDragBy : (Delta -> msg) -> Event 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.

Note The delta values are Float, so the code bellow assumes that the point is of type { x: Float, y: Float }. If you want to use a Mouse.Position instead (which has Int coordinates), you might want to convert the Delta to a Position, using deltaToPosition

case Msg of
    OnDragBy (dx, dy) ->
        { model | point = { x = point.x + dx, y = point.y + dy } }
onClick : msg -> Event msg

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

onMouseDown : msg -> Event msg

Register a MouseDown event listener. It will trigger whenever the mouse is pressed.

onMouseUp : msg -> Event msg

Register a MouseUp event listener. It will trigger whenever the mouse is released.