Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

In hammer.js 1.1.3 version 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'm struggling to find an 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.github.io/getting-started.html) for the new hammer.js 2.0, there are 5 recognizers:

    Pan, Pinch, Press, Rotate, Swipe, Tap

I couldn't find a appropriate recognizer that would allow release type functionality. Any thoughts, suggestions or ideas are appreciated. Cheers for reading!

like image 866
Mr. Smith Avatar asked Oct 20 '22 05:10

Mr. Smith


1 Answers

This will be supported in the next release, 2.0.1! https://github.com/hammerjs/hammer.js/commit/a764fde2e89c3af2575ae02d3af41d7787a60dc5

like image 194
Jorik Avatar answered Oct 23 '22 03:10

Jorik