锤子js:pinchend有时不会开火

时间:2016-04-09 18:43:39

标签: javascript hammer.js interact.js

我正在使用pinchinpinchoutpinchend。如果长pinchinpinchout pinchend可以点火,但如果它是短pinchinpinchoutpinchend不会触发。这是一个错误还是我做错了什么?

gestos = new Hammer.Manager(document.body, {
    touchAction: "manipulation"
});
gestos.add(new Hammer.Pinch({event: 'pinch'})); // If it isn't added, pinchout and pinchend never fires 
gestos.add(new Hammer.Pinch({event: 'pinchin'}));
gestos.add(new Hammer.Pinch({event: 'pinchout'}));
gestos.add(new Hammer.Pinch({event: 'pinchend'}));
gestos.on("pinchin pinchout pinchend", function (e) { 
    if (e.type == "pinchin")
        interact("#mapa").resizable(false);
    else
        interact("#mapa").resizable(true);
    console.log(e.type);
});

1 个答案:

答案 0 :(得分:0)

gestos.add(new Hammer.Pinch({event: 'pinchcancel'}));
gestos.on("pinchin pinchout pinchend pinchcencel", function (e) { 
    if (e.type == "pinchin")
        interact("#mapa").resizable(false);
    else
        interact("#mapa").resizable(true);
    console.log(e.type);
});
//sometimes the device just recognize our move as pinchcancel when we actually want to fire pinchend event.