0

I'm using only Press on an Element. I changed the threshold to 1000 to be able to scroll while pressing. But the pressup event doesnt fire if I scrolled. Is there a way to define a threshold for the pressup too?

Here's my code:

var myElement = document.getElementById('testuso');
var mc = new Hammer.Manager(myElement);

mc.add(new Hammer.Press({
    event: 'press',
    pointer: 1,
    threshold: 1000,
    time: 1,
}));

    mc.on('press', function(event) {
    $('.skills').addClass( "show" );
    });

    mc.on('pressup', function(event) {
    $('.skills').removeClass( "show" );
    });

1 Answer 1

1

My Solution (It binds the event to each div in a grid):

$('.class').each(function(){
    var $this = $(this);
    var mc = new Hammer.Manager(this);

    mc.add( new Hammer.Tap() );
    mc.add(new Hammer.Press({
        event: 'press',
        pointer: 1,
        threshold: 1000,
        time: 1,
    }));

    mc.on('press tap', function(event) {
        //do stuff
        if (event.type == "tap") {
            window.location.href = link;
            $('.skills').removeClass( "show" );
        }   
    });

    mc.on('pressup', function(event) {
    //undo stuff
    });

});

Not the answer you're looking for? Browse other questions tagged or ask your own question.