Serhio g. Lazin Serhio g. Lazin - 5 months ago 19
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?

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.