This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
1.0.0 1.0.1
We were not able to find the expected elm-package.json file at this tag.
Tag 1.0.2
Committed At 2018-08-31 18:26:45 UTC

Modules

    README

    elm-swiper

    This package has a very specific use-case. It's purpose is to make it easier to detect and react to "swiping" gestures on mobile devices. There are no actual "swipe" events in the DOM - so this package evaluates "touchstart" and "touchend" events to determine if a user swiped in a specific direction.

    Because this has to be handled in a two-step fashion, the application using this library must store some "state" that can be passed back to the library to determine a swipe event.

    Installation

    elm-package install marshallformula/elm-swiper
    

    Usage

    import Swiper
    
    -- Application Model
    type alias Model =
        { swipingState : Swiper.SwipingState
        , userSwipedLeft : Bool
        }
    
    -- Messages
    type Msg
        = Swiped Swiper.SwipeEvent
    
    -- Update
    init : ( Model, Cmd Msg )
    init =
        let
            initialModel =
                { swipingState = Swiper.initialSwipingState
                , userSwipedLeft = False
                }
        in
            ( initialModel, Cmd.none )
    
    
    update : Msg -> Model -> ( Model, Cmd Msg)
    update msg model =
        case msg of
            Swiped evt ->
                let
                    ( newState, swipedLeft) =
                        Swiper.hasSwipedLeft evt model.swipingState
                in
                    ( { model | swipingState = newState, userSwipedLeft = swipedLeft }, Cmd.none )
    
    -- View
    view : Model -> Html Msg
    view model =
        div ( [ id "Main" ] ++ Swiper.onSwipeEvents Swiped ) [ text "main website" ]