From e108473c0992a962b0e5ce0a57b6553dde9925e4 Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Tue, 12 Jul 2022 12:00:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=B9=E8=BF=9B=20md-virtual=20?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vuepress/components/md/virtual.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/.vuepress/components/md/virtual.vue b/docs/.vuepress/components/md/virtual.vue index 384249348..866bb9132 100644 --- a/docs/.vuepress/components/md/virtual.vue +++ b/docs/.vuepress/components/md/virtual.vue @@ -20,10 +20,12 @@ [...contentChildren].forEach((child, index) => { if (child.nodeName === 'UL') { const ulHeight = child.clientHeight; - const isVisible = visibleHeight + window.scrollY > child.offsetTop - 500; + const ulOffsetTop = child.offsetTop; + const isVisible = visibleHeight + window.scrollY > ulOffsetTop - 500; + const isOver = window.scrollY > ulOffsetTop + ulHeight child.style.height = `${ulHeight}px`; - if (!isVisible) { + if (!isVisible || isOver) { const _ul = document.createDocumentFragment(); [...child.children].forEach(item => _ul.appendChild(item)); (!this.contentFrame[index] || !this.contentFrame[index].children.length) && -- GitLab