在iPadOS 14中为Safari编写的PWA中,我使用一个简单的监听器在单击按钮时显示弹出窗口。虽然包含iPadOS 14.6的代码运行良好,但iPadOS 15.0中却没有相同的代码。
侦听器"touchend“导致弹出窗口只显示一微秒,然后再次关闭。当仅使用侦听器“单击”时,相同的操作工作得很好。但动作“触觉”要直观得多。
$('.popup').on('touchend click', function(e) {
e.preventDefault();
$('#popup-content').toggleClass('d-flex d-none');
});同时,当触摸任何超过0.5s的按钮时,会显示一个空的小窗口(标注)。在iPadOS 14中,可以通过简单的CSS防止这种行为:
-webkit-user-select: none;
user-select: none;
-webkit-touch-callout: none;如何在最新的iPadOS 15中防止这两种行为?
发布于 2021-09-22 08:46:42
我找到的简单解决方案是将带有preventDefault()的"touchstart“监听器添加到相同的按钮中:
$('.popup').on('touchstart', function(e) {
e.preventDefault();
});这两个操作的行为都与iPadOS 14中的行为相同。
https://stackoverflow.com/questions/69280933
复制相似问题