Hammer.js skips 'case' inside 'switch'

302 views Asked by At

After updating Hammer to v2 it doesn't recognize gestures anymore. It does trigger 'switch(event.type)' but skips all of the cases. Is 'case' not supported anymore?

Example of the code:

function handleHammer(event) {
    // disable browser scrolling
    event.preventDefault();

    switch(event.type) {
        case 'tap':
            the_single_post.removeClass('grab');
            var tapPos = (event.gesture.center.pageX) - (element.offset().left);

            if (tapPos > paneWidth/2) {
                hammer.next('easeinout');
            }
            else if (tapPos < paneWidth/2) {
                hammer.prev('easeinout');
            }
            break;

        case 'drag':
            (etc.)
    }
}
1

There are 1 answers

2
Benjamin Mesing On BEST ANSWER

Hammer.js 2.0 is rewritten from scratch and works totally different. For example there is no drag event, instead the pan event is supported. You will have to change quite some code to switch to hammer.js 2.0