hammerjs / simulator

Simulate gestures for testing purposes.
MIT License
29 stars 17 forks source link

Example for using the Simulator #1

Open sbradl opened 10 years ago

sbradl commented 10 years ago

For unit-testing parts of our web application I want to simulate touch events. Could you provide some examples for this? (I am using the HammerJS jQuery plugin and the Jasmine framework).

jtangelder commented 10 years ago

Implementation can be found at the tests in Hammerjs

sbradl commented 10 years ago

Thanks, I looked at the tests and managed to get something working.

Now I have the following problem: I have a component which binds to the tap event. In the unit test I get the hammer instance by using "element.data('hammer')" and then bind my test function with "hammer.on('tap', ...)". Using "Simulator.gestures.tap(element)" I trigger the gesture. The problem now is that the gesture handler of the component is called after the gesture handler from the test.

Edit: when I use "element.hammer().bind('tap', ..)" instead of "hammer.on" the order is correct. So it seems like the order is different from raw hammerjs and the jquery version.