Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use touchmove vs mousemove?

I build a web mobile game, it runs on browsers (PC/Mobile).

Do I need to use the touchmove or not?

How can I run the touchmove event like the mousemove event?

like image 702
Soliman Avatar asked Nov 22 '12 10:11

Soliman


People also ask

How does MouseMove work?

MouseMove is a simple event that is executed when a pointer is moving over or around an element. Mousemove is a javascript event that inside a web page. The mousemove event can also be understood as a part of an event handler, whereupon some action or movement by a mouse pointer, an intended script is executed.

Does MouseMove work on mobile?

The jQuery Mobile vmousemove event handler simulates the "onmousemove" event handler on mobile devices. This plugin extends jQuery's built-in method. If jQuery Mobile is not loaded, calling the . vmousemove() method may not fail directly, as the method still exists.

Does Touchstart work on desktop?

onTouchStart works only for mobile. Also, this event goes before the onClick event.

What happens when you move the mouse on the canvas?

As we move the mouse, a line is drawn on the canvas between the current and the previous mouse position. When we release the mouse (mouseup event), drawing stops. We will demonstrate this application using Mouse Events, Touch Events and finally combining both with Pointer Events.

What is a touchmove event?

Definition and Usage The touchmove event occurs when the user moves the finger across the screen. The touchmove event will be triggered once for each movement, and will continue to be triggered until the finger is released. Note: The touchmove event will only work on devices with a touch screen.

Can web applications handle touch and mouse input?

Web applications wanting to handle mobile devices use Touch Events (touchstart, touchup, touchmove). But in addition to handling touch, they must handle mouse input as well. So to do the same job, they have to duplicate the code or bring an unnecessary if-else to handle both mouse and touch.

What is the difference between touchover and mouseout events?

The behavior of these events is very close, but subtly different - in particular, touch events always target the element where that touch STARTED, while mouse events target the element currently under the mouse cursor. This is why we have mouseover and mouseout events, but there are no corresponding touchover and touchout events - only touchend.


2 Answers

For parity between desktop and touch you have the following equivalences:

mousedown === touchstart mousemove === touchmove mouseup === touchend 

Thus if you handle mousedown, mousemove and mouseup then you don't need to handle the corresponding equivalent events under touch. The same handlers should be executing.

like image 194
Konstantin Dinev Avatar answered Sep 24 '22 14:09

Konstantin Dinev


Except on the ipad -- where mouse hover, mouse down, mouse up and click are all triggered... except if you change anything in mouse hover .. then nothing else gets triggered.... very annoying...more details see http://sitr.us/2011/07/28/how-mobile-safari-emulates-mouse-events.html

like image 31
guest Avatar answered Sep 23 '22 14:09

guest