Swipe events, in Elm
Adapted for Elm 0.19 from elm-touch-events.
In your model:
{ gesture = Swipe.Gesture }
In your init:
{ gesture = Swipe.blanco }
In your Msg:
type Msg
= Swipe Swipe.Event
| SwipeEnd Swipe.Event
In your view:
Html.div
[ Swipe.onStart Swipe
, Swipe.onMove Swipe
, Swipe.onEnd SwipeEnd
]
[ Html.text "Swipe me!" ]
In your update:
Swipe touch ->
{ model | gesture = Swipe.record touch model.gesture }
SwipeEnd touch ->
let
gesture : Swipe.Gesture
gesture =
Swipe.record touch model.gesture
-- use inspection functions like `isTap` and `isLeftSwipe`
in
{ model | gesture = Swipe.blanco }
BSD-3 © Ilias Van Peer