gpt4 book ai didi

javascript - 锤子js : pinchend sometimes doesn't fire

转载 作者:行者123 更新时间:2023-11-28 06:09:41 25 4
gpt4 key购买 nike

我正在使用 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);
});

最佳答案

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.

关于javascript - 锤子js : pinchend sometimes doesn't fire,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36521123/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com