JavaScript mapping touch events to mouse events

Viewed 92704

I'm using the YUI slider that operates with mouse move events. I want to make it respond to touchmove events (iPhone and Android). How can I produce a mouse move event when a touchmove event occurs? I'm hoping that just by adding some script at the top that touchmove events will get mapped to the mouse move events and I won't have to change anything with the slider.

6 Answers

I just discovered this code resolving, i'm stuck on this situation in which I would like to put touch events and mouse event:

https://codepen.io/benstl/details/LYQjKvN

I supposed I have to add in te html the touchevents in the line :

div class="cube" onmousedown="grabOn(true)" onmouseup="grabOff()">

and on the javascript on :

document.addEventListener('mouseup', grabOff);
document.addEventListener('mousemove', handleMouseMove); 

But there's also the grab function to link to either.

Related