1. Check out our app, Forums for Android! Download and leave feedback here!

How to disable tap&drag as scrolling in browser?

Discussion in 'Android Devices' started by cdehaan, Sep 15, 2010.

  1. cdehaan

    cdehaan Member
    Thread Starter
    25

    Sep 15, 2010
    7
    0
    25
    Hello all. I am making a 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. I want it to be registered as mouse actions. Is there a way to do this? :thinking: Thanks in advance!

    - Chris
     

    Advertisement

  2. cdehaan

    cdehaan Member
    Thread Starter
    25

    Sep 15, 2010
    7
    0
    25
    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.
     

Share This Page

Loading...