JohanWinther / elm-pan-and-zoom / PanZoom.Mouse

This module includes abstractions for handling mouse events.

Custom event listeners

onMouseMove : (Position -> msg) -> Html.Attribute msg

Custom event listener for mousemove that returns the mouse Position.

onMouseDown : (Position -> List String -> msg) -> Html.Attribute msg

Custom event listener for mousedown that returns the mouse Position and the classes of the target element that was clicked.

onWheelScroll : (Position -> Basics.Float -> msg) -> Html.Attribute msg

Custom event listener for wheel that returns the mouse Position and the scroll amount of the wheel (in pixels).

Mouse position


type Position

Mouse position.

asCoordinate : Position -> Coordinate

Mouse position as coordinate record.


type alias Coordinate =
{ x : Basics.Float, y : Basics.Float }

Two dimensional vector that can represent a point or direction.

delta : Position -> Position -> Coordinate

Delta/difference vector between two mouse Positions.

delta (Position { x = 50, y = 10 }) (Position { x = 20, y = -10 }) == { x = -30, y = -20 }

delta (Position { x = 50, y = 10 }) (Position { x = 20, y = -10 }) == { x = -30, y = -20 }