add pointerDown, pointerMove and pointerUp events for API
See original GitHub issueI think it would be beneficial to have pointerDown, pointerMove, and pointerUp user events so you can encapsulate touch events, mouse events, pointer events all under one API.
The reason why I think something like this should exist is it would allow for testing complex UI components like a slider input.
the basic implementation I think could work from a high level is the following:
const input = document.getElementById('input');
// you could use a percent to represent the bounds of the element
// or use a specific number to represent a pixel value
userEvent.pointerDown(input, {x: '50%', y: '50%'}); // starting point of where you "clicked"
userEvent.pointerMove(input, {x: '75%', y: '50%', duration: '1s'}); // where you want to move to over a period of time
userEvent.pointerUp(input); // remove your finger from the screen/mouse/etc
@kentcdodds what do you think?
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Pointer events - Web APIs | MDN
The events needed to handle generic pointer input are analogous to mouse events ( mousedown / pointerdown , mousemove / pointermove , etc.)....
Read more >The HTML5 Pointer Events API: Combining touch, mouse, and ...
The Pointer Events API combines touch, mouse, pen and other inputs into a single unified ... Add an event handler for the pointerdown...
Read more >Pointer events - The Modern JavaScript Tutorial
When the user moves and then removes a finger, we get pointermove and pointerup events with the same pointerId as we had in...
Read more >Pointer Events - W3C
If the event is pointerdown , pointermove , or pointerup set active ... A pointerrawupdate listener should only be added if JavaScript needs ......
Read more >Pointer events API inconsistency - javascript - Stack Overflow
Pointer Events do not fire overlapping pointerdown and pointerup events for ... of the state if you read buttons out of e.g. pointermove...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Personally I’d just use cypress. JSDOM doesn’t support layout so you’d have to mock that out of you wanted to do it in that environment…
@ph-fritsche
I’ve put up a pull request to add @lifeiscontent! 🎉