on 577fc17 help sign in
elk/libraries/Touch.elm
34 lines 935 B history raw
1module Touch where
3{-| This is an early version of the touch library. It will likely grow to
4include gestures that would be useful for both games and web-pages.
6# Touches
7@docs Touch, touches
9# Gestures
10@docs taps
11-}
13import Signal (Signal)
14import Native.Touch
15import Time (Time)
17{-| Every `Touch` has `xy` coordinates. It also has an identifier
18`id` to distinguish one touch from another.
20A touch also keeps info about the initial point and time of contact:
21`x0`, `y0`, and `t0`. This helps compute more complicated gestures
22like taps, drags, and swipes which need to know about timing or direction.
23-}
24type Touch = { x:Int, y:Int, id:Int, x0:Int, y0:Int, t0:Time }
26{-| A list of ongoing touches. -}
27touches : Signal [Touch]
28touches = Native.Touch.touches
30{-| The last position that was tapped. Default value is `{x=0,y=0}`.
31Updates whenever the user taps the screen.
32-}
33taps : Signal { x:Int, y:Int }
34taps = Native.Touch.taps