This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Will deprecate in favor of elm-pointer-events in elm 0.19
version 2.0.0
license MPL-2.0
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 2.0.0
Committed At 2017-12-17 11:33:06 UTC
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-mouse-events

WARNING: This package will be merged into elm-pointer-events when the release 0.19 of elm will be out. It won't be updated to elm 0.19.

This package aims at handling mouse events in elm with more details than in Html.Events.

Motivation

When dealing with mouse events, I often need to access mouse coordinates. Functions onMouseDown and others from elm Html.Events module do not provide the coordinates of the mouse event.

Thanks to the use of the on function from Html.Events and some custom json decoders, this package provides mouse events with coordinates.

Usage

A functional example is available in the examples/ folder. But to have an overview of how to use this package, see below what a Msg type and an Attribute Msg might look like using this Mouse module:

import Mouse

type Msg
    = MouseDown Mouse.Event
    | MouseMove Mouse.Event
    | MouseUp Mouse.Event

mouseEvents : List (Html.Attribute Msg)
mouseEvents =
    [ Mouse.onDown MouseDown
    , Mouse.onMove MouseMove
    , Mouse.onUp MouseUp
    ]

The Mouse.Event type

The Mouse.Event type is a reflection of the JavaScript specification of a mouse event. The attributes kept are:

Go see it's definition in the Mouse module to know its exact record structure.

Documentation

The package documentation is available on the elm package website.

License

This Source Code Form is subject to the terms of the Mozilla Public License,v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

Authors

Original author: Matthieu Pizenberg (matthieu.pizenberg@gmail.com)