PinchZoom.js 在 Apple 更新 13.4 后无法在 iOS 设备上运行

PinchZoom.js not working on iOS devices after 13.4 update by Apple

所以我 运行 再次遇到此插件的问题 - PinchZoom.js 在 Apple 为 iOS 设备更新 13.4 后开始发生。

问题是双击功能现在在 iOS 设备上突然完全停止工作。

具体测试可以参考插件演示页面:http://manuelstofer.github.io/pinchzoom/demo/pinchzoom.html

在 iOS 设备上,您将无法双击以放大图像,而这在 iOS 的早期版本中工作正常。

我什至深入研究了插件的源代码,但我不确定是什么导致双击在更新后无法在 iOS 设备上工作。

如果有人对此有任何 idea/workaround,那将非常有帮助。

谢谢

在所有浏览器上,touchstart 事件过去都有 300-350 毫秒的延迟。显然,在 iOS 上仍然存在。您可以通过在 touchstart 事件侦听器中记录点击事件和时间来对此进行测试。

对于您的问题,您可以通过修改 pinchzoom.js 以使用 touchend 而不是 touchstart 来解决它,或者通过阻止 [=] 上的默认行为来解决它11=]。

我选择了后者,在touchstart事件监听器中添加了event.preventDefault()。你也可以这样做,直到开发者提供官方解决方案。

el.addEventListener('touchstart', function (event) {
    event.preventDefault(); //add this

    if (target.enabled) {
        firstMove = true;
        fingers = event.touches.length;
        detectDoubleTap(event);
    }
});