Serhio g. Lazin Serhio g. Lazin - 1 year ago 106
iOS Question

Prevent vertical touchmove event, but leave horizontal touch and scroll opportunity via buttons

I have an iPad app with jQuery widget. Widget can be scrolled horizontally and vertically. I need to prevent vertical scroll via touch event, but leave opportunity to scroll via buttons (like slider).

Needs just remove user vertical touch, but leave horizontal touch. Ideas?

Answer Source
mainContainer.on('touchmove', function(e) {

    var xStart, yStart = 0;

    xStart = e.touches[0].screenX;
    yStart = e.touches[0].screenY;

    var xMovement = Math.abs(e.touches[0].screenX - xStart);
    var yMovement = Math.abs(e.touches[0].screenY - yStart);
    if (friendsList.has($(
        || msgContainer.has($( {

        if ((yMovement * 3) > xMovement) {



This code inside 'touchmove' event prevents vertical scroll by user touching, but allows scroll as it is.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download