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
Creates an invisible perimeter around a target element and monitors breaches
version 1.0.2
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.2
Committed At 2017-04-16 20:11:06 UTC
elm-lang/mouse 1.0.1 <= v < 2.0.0 1.0.1
elm-lang/html 2.0.0 <= v < 3.0.0 2.0.0
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1

Modules

README

ELM Perimeter

Creates an invisible perimeter around a target element and monitors mouse breaches.

Demo can be found here.

Code sample:

module Main exposing (view, update, subscriptions)

import Html exposing (..)
import Perimeter exposing (Perimeter)


type alias Model =
    { perimeter : Perimeter }


init : ( Model, Cmd Msg )
init =
    ( initialModel, Cmd.none )


initialModel : Model
initialModel =
    { perimeter = Perimeter.init }


perimeterConfig =
    { padding = 12
    , onBreach = Breached
    , onLeave = Left
    , debug = True
    }


type Msg
    = Breached
    | Left
    | PerimeterMsg Perimeter.Msg


update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        Breached ->
            model ! []

        Left ->
            model  ! []

        PerimeterMsg subMsg ->
            let
                ( newPerimeterModel, maybeMsg ) =
                    Perimeter.update subMsg model.perimeter perimeterConfig
            in
                case maybeMsg of
                    Nothing ->
                        ( { model | perimeter = newPerimeterModel }, Cmd.none )

                    Just msg ->
                        update msg { model | perimeter = newPerimeterModel }


view : Model -> Html Msg
view model =
    Html.map PerimeterMsg (Perimeter.view perimeterConfig model.perimeter [ button [] [ text model.buttonText ] ])


subscriptions : Model -> Sub Msg
subscriptions model =
    Sub.map PerimeterMsg (Perimeter.subscriptions model.perimeter)


main =
    program
        { init = init
        , update = update
        , subscriptions = subscriptions
        , view = view
        }