From 4fa1ffd4852c79cf380304bda7bfc9231c20e882 Mon Sep 17 00:00:00 2001 From: wan201809 Date: Thu, 28 Mar 2024 21:20:49 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"perf:=20=E4=BC=98=E5=8C=96=E9=95=BF?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=A4=BA=E4=BE=8B=E6=80=A7=E8=83=BD"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 3e0e5947479a70f9ab8e9cb1fcc10c1f3cce7797. --- .../custom-long-list/custom-list-view.uvue | 32 ++++++------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/pages/template/custom-long-list/custom-list-view.uvue b/pages/template/custom-long-list/custom-list-view.uvue index 4b8faf9c..d0438333 100644 --- a/pages/template/custom-long-list/custom-list-view.uvue +++ b/pages/template/custom-long-list/custom-list-view.uvue @@ -109,39 +109,25 @@ this.rearrangeQueue = [] as number[] }, rearrange(scrollTop : number) { - const offsetStart = this.offsetThreshold[0] = Math.max(scrollTop - this.scrollElementHeight * 5, 0) + this.offsetThreshold[0] = Math.max(scrollTop - this.scrollElementHeight * 5, 0) this.offsetThreshold[1] = Math.max(scrollTop - this.scrollElementHeight * 3, 0) this.offsetThreshold[2] = Math.min(scrollTop + this.scrollElementHeight * 4, this.placeholderHeight) - const offsetEnd =this.offsetThreshold[3] = Math.min(scrollTop + this.scrollElementHeight * 6, this.placeholderHeight) + this.offsetThreshold[3] = Math.min(scrollTop + this.scrollElementHeight * 6, this.placeholderHeight) const items = [] as any[] - const defaultItemSize = this.defaultItemSize - const cachedSize = this.cachedSize - const list = this.list let tempTotalHeight = 0 let containerTop = 0 - let start = false, end = false - for (let i = 0; i < list.length; i++) { - const item = list[i] - let itemSize = defaultItemSize - const cachedItemSize = cachedSize.get(item) + for (let i = 0; i < this.list.length; i++) { + const item = this.list[i] + let itemSize = this.defaultItemSize + const cachedItemSize = this.cachedSize.get(item) if (cachedItemSize != null) { itemSize = cachedItemSize } tempTotalHeight += itemSize - if (end) { - continue - } - if (tempTotalHeight < offsetStart) { - containerTop = tempTotalHeight - } else if (tempTotalHeight >= offsetStart && tempTotalHeight <= offsetEnd) { - if (start == false) { - start = true - } + if (tempTotalHeight >= this.offsetThreshold[0] && tempTotalHeight <= this.offsetThreshold[3]) { items.push(item) - } else { - if (!end) { - end = true - } + } else if (tempTotalHeight < this.offsetThreshold[0]) { + containerTop = tempTotalHeight } } this.placeholderHeight = tempTotalHeight -- GitLab