From dad92ccbdcdeb087203b7c55f9687d6a77b9c2cf Mon Sep 17 00:00:00 2001 From: zxhd Date: Sat, 9 Sep 2023 18:18:11 +0800 Subject: [PATCH] Improved performance of swipe up --- app/src/protyle/util/onGet.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts index aadb82b7f23..c8094c83000 100644 --- a/app/src/protyle/util/onGet.ts +++ b/app/src/protyle/util/onGet.ts @@ -154,10 +154,15 @@ const setHTML = (options: { protyle.scroll.lastScrollTop = protyle.contentElement.scrollTop; // 动态加载移除 if (!protyle.wysiwyg.element.querySelector(".protyle-wysiwyg--select") && !protyle.scroll.keepLazyLoad) { - while (protyle.wysiwyg.element.childElementCount > 2 && protyle.contentElement.scrollHeight > REMOVED_OVER_HEIGHT && - protyle.wysiwyg.element.lastElementChild.getBoundingClientRect().top > window.innerHeight) { - protyle.wysiwyg.element.lastElementChild.remove(); + const removeElements:HTMLElement[] = [] + if (protyle.wysiwyg.element.childElementCount > 2 && protyle.contentElement.scrollHeight > REMOVED_OVER_HEIGHT){ + protyle.wysiwyg.element.childNodes.forEach((el)=>{ + if((el as HTMLElement).getBoundingClientRect().top > window.innerHeight * 2){ + removeElements.push((el as HTMLElement)) + } + }) } + removeElements.forEach((el)=>{el.remove()}) hideElements(["toolbar"], protyle); } } else {