首页禁止下拉回弹:锁 html/body + 滚动区 contain + 触摸拦截(统一规则)v26101012
Co-Authored-By: AI 助手
This commit is contained in:
29
index.html
29
index.html
@@ -7,7 +7,7 @@
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<title>兜爸心选 · 孕育陪伴</title>
|
||||
<!-- V:26101011 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
|
||||
<!-- V:26101012 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
|
||||
<link rel="stylesheet" href="mama-box.css">
|
||||
<link rel="stylesheet" href="night.css">
|
||||
<!-- 夜晚模式:首屏绘制前就按上次的选择加 class,避免先白后黑闪一下(开关在首页右上角 #nightBtn,逻辑见 app.js) -->
|
||||
@@ -2089,5 +2089,32 @@
|
||||
<!-- 2026-10-05 首页头图:宝宝时不时动一动小手小脚(独立文件,删掉这一行即下线) -->
|
||||
<script src="js/baby-limbs.js"></script>
|
||||
|
||||
<!-- 禁止下拉回弹(2026-10-11 统一规则,与孕期体重同一段):竖向拖动时从手指下往上找还能朝该方向滚的容器,找不到才拦;横滑、双指、可滚列表不受影响 -->
|
||||
<script>
|
||||
(function () {
|
||||
var sx = 0, sy = 0;
|
||||
document.addEventListener('touchstart', function (e) {
|
||||
if (e.touches.length !== 1) return;
|
||||
sx = e.touches[0].clientX; sy = e.touches[0].clientY;
|
||||
}, { passive: true });
|
||||
document.addEventListener('touchmove', function (e) {
|
||||
if (e.touches.length !== 1) return;
|
||||
var dx = e.touches[0].clientX - sx, dy = e.touches[0].clientY - sy;
|
||||
if (Math.abs(dy) <= Math.abs(dx)) return;
|
||||
var el = e.target;
|
||||
while (el && el !== document.body && el !== document.documentElement) {
|
||||
if (el.nodeType === 1) {
|
||||
var oy = getComputedStyle(el).overflowY;
|
||||
if ((oy === 'auto' || oy === 'scroll') && el.scrollHeight > el.clientHeight + 1) {
|
||||
if (dy > 0 && el.scrollTop > 0) return;
|
||||
if (dy < 0 && el.scrollTop + el.clientHeight < el.scrollHeight - 1) return;
|
||||
}
|
||||
}
|
||||
el = el.parentNode;
|
||||
}
|
||||
if (e.cancelable) e.preventDefault();
|
||||
}, { passive: false });
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||
var VER = '26101011';
|
||||
var VER = '26101012';
|
||||
const $ = (s, c) => (c || document).querySelector(s);
|
||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||
|
||||
|
||||
@@ -96,6 +96,10 @@ button,a,input,textarea,select,summary,[tabindex]{transition:box-shadow .15s eas
|
||||
:focus{outline:none}
|
||||
:focus-visible{outline:3px solid rgba(244,89,60,.55);outline-offset:2px;border-radius:6px}
|
||||
.modal,.sheet,.search-layer,.scrim{overscroll-behavior:contain}
|
||||
/* 禁止下拉回弹(2026-10-11 统一规则):iOS 微信里滑到顶再下拉会把整页拖下来露出「网页由 … 提供」。
|
||||
外壳 .phone 固定一屏、滚动都在内部容器里,所以锁 html/body 不影响内容滚动;第二层触摸拦截在 index.html </body> 前。 */
|
||||
html,body{overflow:hidden;overscroll-behavior:none}
|
||||
.screen,.detail-body,.sheet-scroll,.modal,#appsGrid,.bx-reveal,.whp-scroll,.whd-panel,.fb-modal,.zd-modal{overscroll-behavior-y:contain}
|
||||
a.skip{position:absolute;left:-9999px;top:auto;z-index:2000;background:var(--brand);color:#fff;padding:10px 16px;border-radius:10px;font-weight:700}
|
||||
a.skip:focus{left:16px;top:16px}
|
||||
/* 橙渐变上的白字:加深对比 + 轻微投影提可读性 */
|
||||
|
||||
Reference in New Issue
Block a user