This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
1.0.0
README

MouseCompat

For compatibility with elm-lang/mouse. The Mouse module name is also used in mpizenberg/elm-pointer-events. This creates a compiler error if both packages are needed.

To circumvent this issue, elm-lang/mouse Mouse module is re-exposed here under the MouseCompat module name.

Mouse Position

type alias Position = { x : Int , y : Int }

The position of the mouse relative to the whole document (pageX, pageY). So if you are scrolled down a bunch, you are still getting a coordinate relative to the very top left corner of the whole document.

position : Decoder Position

The decoder used to extract a Position from a JavaScript mouse event.

Subscriptions

clicks : (Position -> msg) -> Sub msg

Subscribe to mouse clicks anywhere on screen.

moves : (Position -> msg) -> Sub msg

Subscribe to mouse moves anywhere on screen. It is best to unsubscribe if you do not need these events. Otherwise you will handle a bunch of events for no benefit.

downs : (Position -> msg) -> Sub msg

Get a position whenever the user presses the mouse button.

ups : (Position -> msg) -> Sub msg

Get a position whenever the user releases the mouse button.

module MouseCompat exposing (..)

{-| For compatibility with [elm-lang/mouse].
The `Mouse` module name is also used in [mpizenberg/elm-pointer-events].
This creates a [compiler error][issue-1625] if both packages are needed.

To circumvent this issue, elm-lang/mouse `Mouse` module
is re-exposed here under the `MouseCompat` module name.

[elm-lang/mouse]: http://package.elm-lang.org/packages/elm-lang/mouse/latest
[mpizenberg/elm-pointer-events]: http://package.elm-lang.org/packages/mpizenberg/elm-pointer-events/latest
[issue-1625]: https://github.com/elm-lang/elm-compiler/issues/1625


# Mouse Position

@docs Position, position


# Subscriptions

@docs clicks, moves, downs, ups

-}

import Json.Decode exposing (Decoder)
import Mouse


{-| The position of the mouse
relative to the whole document (pageX, pageY).
So if you are scrolled down a bunch,
you are still getting a coordinate relative to
the very top left corner of the whole document.
-}
type alias Position =
    { x : Int
    , y : Int
    }


{-| The decoder used to extract a Position from a JavaScript mouse event.
-}
position : Decoder Position
position =
    Mouse.position


{-| Subscribe to mouse clicks anywhere on screen.
-}
clicks : (Position -> msg) -> Sub msg
clicks =
    Mouse.clicks


{-| Subscribe to mouse moves anywhere on screen.
It is best to unsubscribe if you do not need these events.
Otherwise you will handle a bunch of events for no benefit.
-}
moves : (Position -> msg) -> Sub msg
moves =
    Mouse.moves


{-| Get a position whenever the user presses the mouse button.
-}
downs : (Position -> msg) -> Sub msg
downs =
    Mouse.downs


{-| Get a position whenever the user releases the mouse button.
-}
ups : (Position -> msg) -> Sub msg
ups =
    Mouse.ups