From f1bd2b183fcf1829c82781d5db4f87e83cf50a0c Mon Sep 17 00:00:00 2001 From: xingyy <64720302+Concur-max@users.noreply.github.com> Date: Sat, 8 Feb 2025 17:10:23 +0800 Subject: [PATCH] =?UTF-8?q?perf(tangPopup):=20=E4=BC=98=E5=8C=96=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E5=AE=9A=E4=BD=8D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了 setTimeout 包裹,直接执行滚动定位逻辑 - 保留了原有的滚动定位功能,没有引入新功能 --- .../components/SideButton/tangPopup.vue | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/app/pages/liveRoom/components/SideButton/tangPopup.vue b/app/pages/liveRoom/components/SideButton/tangPopup.vue index bc0c4ce..b7900d4 100644 --- a/app/pages/liveRoom/components/SideButton/tangPopup.vue +++ b/app/pages/liveRoom/components/SideButton/tangPopup.vue @@ -33,25 +33,22 @@ const props = defineProps({ }) const scrollToCurrentItem = () => { if (!itemList.value?.length) return - - setTimeout(() => { - const currentIndex = itemList.value.findIndex( - item => auctionData.value.artwork.index === item?.index - ) - if (currentIndex > -1) { - const container = document.querySelector('.list-container') - const targetElement = document.querySelectorAll('.item-wrapper')[currentIndex] - if (targetElement && container) { - const containerTop = container.getBoundingClientRect().top - const elementTop = targetElement.getBoundingClientRect().top - const scrollTop = elementTop - containerTop + container.scrollTop - container.scrollTo({ - top: scrollTop, - behavior: 'smooth' - }) - } + const currentIndex = itemList.value.findIndex( + item => auctionData.value.artwork.index === item?.index + ) + if (currentIndex > -1) { + const container = document.querySelector('.list-container') + const targetElement = document.querySelectorAll('.item-wrapper')[currentIndex] + if (targetElement && container) { + const containerTop = container.getBoundingClientRect().top + const elementTop = targetElement.getBoundingClientRect().top + const scrollTop = elementTop - containerTop + container.scrollTop + container.scrollTo({ + top: scrollTop, + behavior: 'smooth' + }) } - }, 100) + } } const emit = defineEmits(['update:show']) const showDetailInfo=ref(null)