Equivalent to "hold" and "release" in hammer.js 2.0

In hammer.js version 1.1.3, I was able to use the following code perfectly:

        var button = Hammer(element, {
            hold: true,
            release: true
        });

        button .on('hold', function() {
            //Do something when the hold event starts
        });

        button .on('release', function() {
            //Do something when the hold event stops
        });

But in hammer.js 2.0, I struggle to find the equivalent:

    var button = new Hammer.Manager(element);

    button.add(new Hammer.Press({
        event: 'press',
        pointer: 1,
        threshold: 5,
        time: 500
    }));

    button.on('press', function(event) {
        //Do something when the the element is pressed after 500ms
    });

    //Possible handler when the element is released?

According to the documentation ( http://hammerjs.imtqy.com/getting-started.html ) for the new hammer.js 2.0 there are 5 recognizers:

    Pan, Pinch, Press, Rotate, Swipe, Tap

I could not find a suitable recognizer that would allow using functions like release. Any thoughts, suggestions or ideas are welcome. Greetings to read!

+4
source share
2 answers

$(button).on('touchend',function(e){});

jQuery.

-1

Source: https://habr.com/ru/post/1548176/


All Articles