Hammer.js skips 'case' inside 'switch'

余生颓废 提交于 2019-12-12 04:50:59

问题


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:


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



来源:https://stackoverflow.com/questions/26847219/hammer-js-skips-case-inside-switch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!