Skip to content Skip to sidebar Skip to footer

Prevent App Dragging But Permit Scroll Of Inner Div Elements In Ios

I have a web app that I am adapting to iOS5 using Phonegap. Everything works except for one issue: My inner
s, which are set to scroll if overflowed and scroll perfectl

Solution 1:

This is more of a hack, but you can do some checking to see if you're touching the div or not, and depending on that, you prevent scrolling like so:

document.body.addEventListener('touchmove', function (e){
    if(document.elementFromPoint(e.pageX, e.pageY) !== document.getElementById('yourdiv'){
        e.preventDefault();
    }
}, false);

MDN reference

Solution 2:

I was able to prevent dragging of the main app/page by using the following code:

var myDiv = document.getElementById('idMyDiv');

myDiv.addEventListener('touchmove', function (e){
    e.preventDefault();
}, false);

Post a Comment for "Prevent App Dragging But Permit Scroll Of Inner Div Elements In Ios"