• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

How to disable tap&drag as scrolling in browser?

cdehaan

Lurker
Hello all. I'm sorry to double post, but this is very important to me. I am making an intranet website that exactly fits the screen of the device it will be used on (Archos 7 home tablet in this case, Android 1.5).

All browsers (default, dolphin, steel, UC) interpret tap&drag on a website as scrolling. I don't want this. Ideally, I want it to be registered as mouse actions. Is there a way to do this? Thanks in advance!

- Chris
 
Well, in case anyone else wants to know how to do this, here's the answer:

First, register onTOUCH (not onMOUSE) events in the body tag, or wherever you want this behavior. For example:


<body ontouchstart="touchStartFunction(event);" ontouchmove="touchMoveFunction(event);" ontouchend="touchEndFunction(event);">


Second, in your ontouchstart event, add the following line:

event.preventDefault();


Now you can use the touch events. To get the X position of the touch, for example, use this:

var touch = event.touches[0];
document.getElementById('touchMoveTextbox').value = "Touch move at " + touch.pageX;


Hope this helps someone.
 
Back
Top Bottom