Skip to content

driebit/elm-swipe-events

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elm-swipe-events

Swipe events, in Elm

Adapted for Elm 0.19 from elm-touch-events.

Usage

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 }

License

BSD-3 © Ilias Van Peer

Packages

No packages published

Languages

  • Elm 100.0%