From c51e44c8714f396ef63df5c47d356f7463aeaa6f Mon Sep 17 00:00:00 2001 From: Default User Date: Thu, 5 Feb 2026 14:12:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A1=B5=E9=9D=A2=E8=A2=AB?= =?UTF-8?q?=E9=94=81=E6=AD=BB=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?iOS=E6=BB=9A=E5=8A=A8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supply.html | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/supply.html b/supply.html index 7bba1af..9d82f79 100644 --- a/supply.html +++ b/supply.html @@ -5925,20 +5925,42 @@ setupAutoSave(); } + // 存储触摸事件监听器的引用 + let touchMoveListener = null; + // 防止iOS页面拖动的函数 function preventiOSScrolling() { - // 阻止触摸事件的默认行为,防止页面滚动 - document.addEventListener('touchmove', function(e) { + // 先移除之前的监听器,避免重复添加 + if (touchMoveListener) { + document.removeEventListener('touchmove', touchMoveListener, { passive: false }); + } + + // 定义触摸事件监听器 + touchMoveListener = function(e) { + // 只阻止页面滚动,不阻止模态框内的滚动 + const target = e.target; + const createSupplyModal = document.getElementById('createSupplyModal'); + + // 如果触摸目标在模态框内,允许滚动 + if (createSupplyModal && createSupplyModal.contains(target)) { + return; + } + + // 阻止页面滚动 e.preventDefault(); - }, { passive: false }); + }; + + // 添加触摸事件监听器 + document.addEventListener('touchmove', touchMoveListener, { passive: false }); } // 恢复iOS页面滚动的函数 function restoreiOSScrolling() { // 移除触摸事件监听器,恢复页面滚动 - document.removeEventListener('touchmove', function(e) { - e.preventDefault(); - }, { passive: false }); + if (touchMoveListener) { + document.removeEventListener('touchmove', touchMoveListener, { passive: false }); + touchMoveListener = null; + } } // 隐藏创建货源模态框