diff --git a/js/app.js b/js/app.js index 1317273..9c01436 100644 --- a/js/app.js +++ b/js/app.js @@ -297,7 +297,8 @@ let a = null, bd = 1e9; sc.querySelectorAll('[id]').forEach(el => { const r = el.getBoundingClientRect(); - if (r.height < 60 || r.bottom <= top) return; + if (r.height < 60 || r.height > sc.clientHeight * 4 || r.bottom <= top) return; + for (let x = el; x && x !== sc; x = x.parentElement) { const ps = getComputedStyle(x).position; if (ps === 'fixed' || ps === 'absolute' || ps === 'sticky') return; } /* 浮层 / 吸顶不跟着滚,不能当锚点 */ const d = Math.abs(r.top - top); if (d < bd) { bd = d; a = { id: el.id, off: r.top - top }; } });