# Package for Mouse, Touch, Pointer, Wheel and Drag APIs

**URL:** <https://discourse.elm-lang.org/t/package-for-mouse-touch-pointer-wheel-and-drag-apis/704>\
**Category:** Show and Tell\
**Created:** [February 18, 2018, 3:17am UTC](https://discourse.elm-lang.org/t/package-for-mouse-touch-pointer-wheel-and-drag-apis/704 "2018-02-18T03:17:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattpiz](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/mattpiz/32/860_2.png) [@mattpiz](https://discourse.elm-lang.org/u/mattpiz)\
**Post date:** [February 18, 2018, 3:17am UTC](https://discourse.elm-lang.org/t/package-for-mouse-touch-pointer-wheel-and-drag-apis/704/1 "2018-02-18T03:17:30Z")

</div>

Here it is: [mpizenberg/elm-pointer-events](http://package.elm-lang.org/packages/mpizenberg/elm-pointer-events/2.0.1)

As pointed out in [this reddit post](https://www.reddit.com/r/elm/comments/7gksya/pointer_mousetouchpointer_events_community/) there are currently at least 7 packages dealing with mouse/touch/pointer interactions:

- knledg/touch-events
- mbr/elm-mouse-events
- mpizenberg/elm-touch-events
- mpizenberg/elm-mouse-events
- Elm-Canvas/element-relative-mouse-events
- zwilias/elm-touch-events
- mpizenberg/elm-pointer-events

I’m trying to reduce the count and end the name conflicts by merging all mpizenberg packages into elm-pointer-events. My mouse and touch packages will not be updated to elm 0.19.

This version 2.0.0 has a much better cover of mouse/touch/pointer APIs. In addition, it covers Wheel events and partial support of Drag events (for file dropping use cases).

Regarding the Pointer API, a polyfill is also provided at [mpizenberg/elm-pep](https://github.com/mpizenberg/elm-pep) to support Firefox \< 59 and Safari. Thanks a lot to Rob for his contribution in making this apple-friendly!

This package aims at being a solid base for pointer-like events but does not go beyond. Meaning that gestures (swipe, pinch, …) are not directly supported. For those, I suggest looking at zwilias package.

Version 2.0.0 is focused on almost full cover of APIs. In future work, I’ll focus on being gesture-friendly, meaning work on performances and API suitability for implementing gesture packages on top of this.

---

<div class="post-metadata">

**Author:** ![ianmackenzie](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/ianmackenzie/32/86_2.png) [@ianmackenzie](https://discourse.elm-lang.org/u/ianmackenzie)\
**Post date:** [February 19, 2018, 3:19pm UTC](https://discourse.elm-lang.org/t/package-for-mouse-touch-pointer-wheel-and-drag-apis/704/2 "2018-02-19T15:19:41Z")

</div>

This looks great, I’m looking forward to transitioning some of my internal code over to using it!

It seems to me that one possibly controversial choice is the inclusion of `pagePos`, `screenPos` _and_ `clientPos` in the returned records, but I think this is the right decision for a relatively low-level package that others can build on top of. I’ve certainly run into cases where I needed to use multiple different kinds of event coordinates in internal code in order to be able to expose a nicer high-level API.

My only suggestion would be to rename `typeMIME` to `mimeType` in the `File` record =)

---

<div class="post-metadata">

**Author:** ![supermario](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/supermario/32/92_2.png) [@supermario](https://discourse.elm-lang.org/u/supermario)\
**Post date:** [February 20, 2018, 9:42am UTC](https://discourse.elm-lang.org/t/package-for-mouse-touch-pointer-wheel-and-drag-apis/704/3 "2018-02-20T09:42:02Z")

</div>

I spotted your package some time ago and have been using an earlier version in fury for a couple months now.

I’ve built the rudimentary start of gesture controls on top and so far things seem to be working quite well for my very specific use cases.

The polyfill was the crucial missing piece for me compared to the other packages, will be checking out 2.0.0 shortly.

Thanks for your (and Rob’s) work on this!

---

<div class="post-metadata">

**Author:** ![mattpiz](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/mattpiz/32/860_2.png) [@mattpiz](https://discourse.elm-lang.org/u/mattpiz)\
**Post date:** [February 20, 2018, 10:08am UTC](https://discourse.elm-lang.org/t/package-for-mouse-touch-pointer-wheel-and-drag-apis/704/4 "2018-02-20T10:08:07Z")

</div>

@ianmackenzie Thanks! I added an issue with the `mimeType` change. It makes sense for consistency.

@supermario Thanks for the kind words! Rob significantly improved the polyfill last December and came up with the pointer capture trick to behave like touch. Beware that due to the more complete API, the models/decoders are quite bigger than they used to be. It might impact gesture processing but I hope not too much.

PS: the polyfill is independent from this package so you can use it with others, even pure JS if you want ^^

---

<div class="post-metadata">

**Author:** ![ivanceras](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/ivanceras/32/290_2.png) [@ivanceras](https://discourse.elm-lang.org/u/ivanceras)\
**Post date:** [February 20, 2018, 5:14pm UTC](https://discourse.elm-lang.org/t/package-for-mouse-touch-pointer-wheel-and-drag-apis/704/5 "2018-02-20T17:14:04Z")

</div>

Looks neat, I didn’t know listening to Mouse events is possible without using subscriptions. I would definitely use this library to replace my subscription base drag listener. Thanks for this!
