Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pointer events #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/Browser/Events.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ effect module Browser.Events where { subscription = MySub } exposing
( onAnimationFrame, onAnimationFrameDelta
, onKeyPress, onKeyDown, onKeyUp
, onClick, onMouseMove, onMouseDown, onMouseUp
, onPointerMove, onPointerDown, onPointerUp
, onResize, onVisibilityChange, Visibility(..)
)

Expand Down Expand Up @@ -30,6 +31,11 @@ If there is something else you need, use [ports] to do it in JavaScript!
@docs onClick, onMouseMove, onMouseDown, onMouseUp


# Pointer

@docs onPointerMove, onPointerDown, onPointerUp


# Window

@docs onResize, onVisibilityChange, Visibility
Expand Down Expand Up @@ -178,6 +184,38 @@ onMouseUp =



-- POINTER


{-| Subscribe to pointer moves anywhere on screen. This could be of any
pointer type (including mouse and touch).

**Note:** Unsubscribe if you do not need these events! Running code on every
single pointer movement can be very costly, and it is recommended to only
subscribe when absolutely necessary.

-}
onPointerMove : Decode.Decoder msg -> Sub msg
onPointerMove =
on Document "pointermove"


{-| Subscribe to get pointer information whenever the pointer goes down.
-}
onPointerDown : Decode.Decoder msg -> Sub msg
onPointerDown =
on Document "pointerdown"


{-| Subscribe to get pointer information whenever the pointer goes up.
Often used in combination with [`onVisibilityChange`](#onVisibilityChange)
to be sure keys do not appear to down and never come back up.
-}
onPointerUp : Decode.Decoder msg -> Sub msg
onPointerUp =
on Document "pointerup"


-- WINDOW


Expand Down