ember-test-helpers icon indicating copy to clipboard operation
ember-test-helpers copied to clipboard

Improve touch event support

Open ggayowsky opened this issue 5 years ago • 3 comments

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.

ggayowsky avatar Jul 23 '19 19:07 ggayowsky

We already have tap, and I am not particularly opposed to other touch specific helper methods. What do you have in mind?

rwjblue avatar Jul 29 '19 15:07 rwjblue

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.

ggayowsky avatar Aug 02 '19 00:08 ggayowsky

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.

rwjblue avatar Aug 02 '19 14:08 rwjblue