Browse Source

Lock modal and only allow vertical scrolling

Boss
Default User 4 weeks ago
parent
commit
be6f85533e
  1. 26
      supply.html

26
supply.html

@ -461,8 +461,8 @@
flex-direction: column; flex-direction: column;
z-index: 1000; z-index: 1000;
overflow: hidden; overflow: hidden;
/* 防止iOS滚动穿透和模态框拖动 */ /* 防止iOS滚动穿透和模态框拖动,只允许垂直滑动 */
touch-action: none; touch-action: pan-y;
/* 防止拖动 */ /* 防止拖动 */
user-select: none; user-select: none;
-webkit-user-select: none; -webkit-user-select: none;
@ -478,18 +478,19 @@
background-color: white; background-color: white;
width: 100%; width: 100%;
height: 100%; height: 100%;
max-width: none; max-width: 100%;
max-height: none; max-height: none;
border-radius: 0; border-radius: 0;
overflow: hidden; overflow: hidden;
overflow-x: hidden;
box-shadow: none; box-shadow: none;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
/* 启用iOS原生滚动 */ /* 启用iOS原生滚动 */
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
overscroll-behavior: contain; overscroll-behavior: contain;
/* 允许触摸操作 */ /* 允许垂直触摸操作 */
touch-action: auto; touch-action: pan-y;
/* 允许内容选择 */ /* 允许内容选择 */
user-select: auto; user-select: auto;
-webkit-user-select: auto; -webkit-user-select: auto;
@ -500,11 +501,12 @@
.modal-body { .modal-body {
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden;
/* 启用iOS原生滚动 */ /* 启用iOS原生滚动 */
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
overscroll-behavior: contain; overscroll-behavior: contain;
/* 允许触摸操作 */ /* 允许垂直触摸操作 */
touch-action: auto; touch-action: pan-y;
} }
/* iOS滚动穿透修复 */ /* iOS滚动穿透修复 */
@ -6005,6 +6007,16 @@
// 定义触摸事件监听器 // 定义触摸事件监听器
touchMoveListener = function(e) { touchMoveListener = function(e) {
// 计算水平和垂直滑动距离
const deltaX = Math.abs(e.touches[0].pageX - e.changedTouches[0].pageX);
const deltaY = Math.abs(e.touches[0].pageY - e.changedTouches[0].pageY);
// 阻止水平滑动
if (deltaX > deltaY) {
e.preventDefault();
return;
}
// 获取触摸目标 // 获取触摸目标
const target = e.target; const target = e.target;
const createSupplyModal = document.getElementById('createSupplyModal'); const createSupplyModal = document.getElementById('createSupplyModal');

Loading…
Cancel
Save