ember-test-helpers
ember-test-helpers copied to clipboard
Improve touch event support
Currently, creating trying to create touch events with this library is very manual at best. Can can call triggerEvent with the type being 'touchstart', 'touchmove', 'touchend' or 'touchcancel' however a generic UIEvent (not a TouchEvent) will be created and sent.
Would be nice for this library to include better support for touch events.
We already have tap
, and I am not particularly opposed to other touch specific helper methods. What do you have in mind?
I am referring to having better triggerEvent
support for touch events. Looking at fire-event.ts
for mouse events (click
, mouseup
, mousemove
, etc) a MouseEvent
is returned and similarly for keyboard events a KeyboardEvent is returned, if the browser supports them. Also with mouse and keyboards event the library does some basic setup (add clientX
and clientY
in the case of mouse event)
For touch events, it just falls to the default handler which returns an Event instead of a TouchEvent, so I figured this library could simulate touch events a little better
i.e. returning a TouchEvent if the browser supports it, initializing the event with the targetTouches (for touchStart
) or changedTouches (for touchmove
, touchend
touchcancel
), etc.
I have some code in my application that does some of this setup I will try to open a PR when I get the chance.
I have a mini library in my application that does some of this setup I will try to open a PR when I get the chance.
Sounds great! Definitely seems like an improvement.