JohanWinther/elm-pan-and-zoom/2.0.0

NOTE: the latest version is 3.0.0

PanZoom.Mouse

This module includes abstractions for handling mouse events.

Custom event listeners

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

Custom event listener for mousemove that returns the mouse Position.

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

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

onWheelScroll : (Position -> ScrollDirection -> msg) -> Attribute msg

Custom event listener for wheel that returns the mouse Position and the ScrollDirection of the wheel.

Mouse position

Mouse position.

asCoordinate : Position -> Coordinate

Mouse position as coordinate record.

type alias Coordinate =
{ x : Float
, y : 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 }

Scroll wheel

= ScrollUp
| ScrollHorizontal
| ScrollDown

Scroll wheel direction.