elm-touch-events | Handle multitouch events in elm
kandi X-RAY | elm-touch-events Summary
kandi X-RAY | elm-touch-events Summary
Handle multitouch events in elm
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of elm-touch-events
elm-touch-events Key Features
elm-touch-events Examples and Code Snippets
Community Discussions
Trending Discussions on elm-touch-events
QUESTION
Is there a way to detect a "long press" in Elm? i.e. a mouse/pointer down event followed by a period of time without movement (or at least no movement across an element boundary).
I am using the elm package mpizenberg/elm-touch-events.
I have found discussion of doing this in javascript, but not in Elm.
Thanks
Ivan
...ANSWER
Answered 2018-Jun-16 at 17:29Here's how I'd do it:
- Track how long the button has been pressed -- initialize it as "not pressed", represented by
Nothing
- When the button is pressed, update the model to show the button has been pressed for 0 seconds (
Just 0
) - Use a
Time.every
subscription to increment the 'pressed time' every second or so - After every increment, check how long the button has been pressed, and do something if it's been long enough
You would need to track this state in your model for every element that can be "long pressed".
Full example: https://ellie-app.com/wRngKVN6Gca1
I'm not familiar with the mpizenberg/elm-touch-events package, but I think you could adapt this code to use the package without too much trouble.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install elm-touch-events
Elm packages are available at elm-lang.org. If you are going to make HTTP requests, you may need elm/http and elm/json. You can get them set up in your project with the following commands: elm install elm/http and elm install elm/json. It adds these dependencies into your elm.json file, making these packages available in your project. Please refer guide.elm-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page