nuway
nuway

Reputation: 2394

touchMove event on mobile safari - causes the whole page to be dragged

when applying touch events as per apple documentation

element.addEventListener("touchstart", touchStart, false);
element.addEventListener("touchmove", touchMove, false);
element.addEventListener("touchend", touchEnd, false);
element.addEventListener("touchcancel", touchCancel, false);

and dragging, the whole html page (on ipad or iphone) tends to be dragged along. How do I prevent that?

I tried adding

event.preventDefault();

to the callbacks, as well as

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />

with no success.

Upvotes: 1

Views: 2642

Answers (1)

Alexey Ogarkov
Alexey Ogarkov

Reputation: 2916

You can try to use preventing default action with returning false from a handler.

event.preventDefault();
return false;

Also you can try to use event.stopPropagation();

I think one of that should work

Upvotes: 2

Related Questions