This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
1.0.0
A low- and high-level interface to mouse drag actions
version 1.0.1
license BSD3
native-modules False
elm-version 0.15.0 <= v < 0.17.0
Tag 1.0.1
Committed At 2016-05-12 10:19:04 UTC
evancz/automaton 1.0.0 <= v < 2.0.0 1.1.0
elm-lang/core 2.0.0 <= v < 4.0.0 3.0.0

Modules

README

elm-drag

A low- and high-level interface to mouse drag actions in Elm. For documentation of the latest published version, see also http://package.elm-lang.org/packages/jvoigtlaender/elm-drag/latest/Drag.

For reporting any issues, see https://github.com/jvoigtlaender/elm-drag/issues.

The low-level interface is:

type MouseEvent
    = StartAt ( Int, Int )
    | MoveFromTo ( Int, Int ) ( Int, Int )
    | EndAt ( Int, Int )

mouseEvents : Signal MouseEvent

The recommended, high-level interface consists of the track-functions:

type Action
    = Lift
    | MoveBy ( Int, Int )
    | Release

track : Bool -> Signal Bool -> Signal (Maybe Action)

trackMany : Maybe a -> Signal (Maybe a) -> Signal (Maybe ( a, Action ))

In those track-functions, the Bool/Signal Bool or Maybe a/Signal (Maybe a) arguments are the initial value and input signal which tell whether the mouse is (currently) hovering over something draggable. See Example1.elm (demo), Example2.elm (demo), Example3.elm (demo), and Example3b.elm (demo).

The library also exposes an Automaton:

type Input a
    = Mouse MouseEvent
    | Hover (Maybe a)

automaton : Maybe a -> Automaton (Input a) (Maybe ( a, Action ))

This can be used in specific situations where the track-functions are not applicable. See Example4.elm (demo), where the automaton is used to realize accurate dragging of non-rectangular shapes.

(Said automaton is also used internally in the track-functions.)