Holding swipes down by default using a hammer

I am using hammer js for gestures on any mobile desk. its simplest left / right scrolling goes forward / backward.

But I want it up / down to stay as it is (scroll up / down).

The code is pretty simple, problems occur when I scroll up / down the page up or down and down. At times, it doesn't scroll at all, or it scrolls a tiny bit up or down.

function hammerEvent( event ){

    if(event.type == 'swipe' ){
        if(event.direction == 'left'){
            event.preventDefault();
            document.location = gNext.href              
        }
        if(event.direction == 'right'){
            event.preventDefault();
            document.location = gBack.href  
        }

    }
}

      

Has anyone experienced this?

+3


source to share


1 answer


Sorry for the late answer, but still ...

If you are using a fairly old version of Hammer (about 0.6) - you can pass appropriate parameters to it, for example



var hammer1 = new Hammer(element, {
    drag_vertical: false,
    swipe: false
});

      

I'm not sure about newer versions, but it seems that you just need to pass other parameters (smth like drag_block_vertical: true

). For more information on parameters, see the Hammer page .

0


source







All Articles