elm/libraries/Touch.elm

35 lines
935 B
Elm
Raw Permalink Normal View History

module Touch where
2013-09-10 17:10:34 +00:00
{-| This is an early version of the touch library. It will likely grow to
include gestures that would be useful for both games and web-pages.
# Touches
2013-09-11 01:21:30 +00:00
@docs Touch, touches
2013-09-10 17:10:34 +00:00
# Gestures
@docs taps
-}
import Signal (Signal)
import Native.Touch
2013-07-26 17:05:48 +00:00
import Time (Time)
2013-09-11 01:21:30 +00:00
{-| Every `Touch` has `xy` coordinates. It also has an identifier
`id` to distinguish one touch from another.
2013-09-10 17:10:34 +00:00
A touch also keeps info about the initial point and time of contact:
`x0`, `y0`, and `t0`. This helps compute more complicated gestures
like taps, drags, and swipes which need to know about timing or direction.
-}
2013-09-11 01:21:30 +00:00
type Touch = { x:Int, y:Int, id:Int, x0:Int, y0:Int, t0:Time }
2013-09-10 17:10:34 +00:00
{-| A list of ongoing touches. -}
touches : Signal [Touch]
touches = Native.Touch.touches
2013-09-10 17:10:34 +00:00
{-| The last position that was tapped. Default value is `{x=0,y=0}`.
Updates whenever the user taps the screen.
-}
taps : Signal { x:Int, y:Int }
2013-09-10 17:10:34 +00:00
taps = Native.Touch.taps