perf(tangPopup): 优化滚动定位逻辑
- 移除了 setTimeout 包裹,直接执行滚动定位逻辑 - 保留了原有的滚动定位功能,没有引入新功能
This commit is contained in:
parent
ad19345db6
commit
f1bd2b183f
@ -33,25 +33,22 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
const scrollToCurrentItem = () => {
|
const scrollToCurrentItem = () => {
|
||||||
if (!itemList.value?.length) return
|
if (!itemList.value?.length) return
|
||||||
|
const currentIndex = itemList.value.findIndex(
|
||||||
setTimeout(() => {
|
item => auctionData.value.artwork.index === item?.index
|
||||||
const currentIndex = itemList.value.findIndex(
|
)
|
||||||
item => auctionData.value.artwork.index === item?.index
|
if (currentIndex > -1) {
|
||||||
)
|
const container = document.querySelector('.list-container')
|
||||||
if (currentIndex > -1) {
|
const targetElement = document.querySelectorAll('.item-wrapper')[currentIndex]
|
||||||
const container = document.querySelector('.list-container')
|
if (targetElement && container) {
|
||||||
const targetElement = document.querySelectorAll('.item-wrapper')[currentIndex]
|
const containerTop = container.getBoundingClientRect().top
|
||||||
if (targetElement && container) {
|
const elementTop = targetElement.getBoundingClientRect().top
|
||||||
const containerTop = container.getBoundingClientRect().top
|
const scrollTop = elementTop - containerTop + container.scrollTop
|
||||||
const elementTop = targetElement.getBoundingClientRect().top
|
container.scrollTo({
|
||||||
const scrollTop = elementTop - containerTop + container.scrollTop
|
top: scrollTop,
|
||||||
container.scrollTo({
|
behavior: 'smooth'
|
||||||
top: scrollTop,
|
})
|
||||||
behavior: 'smooth'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, 100)
|
}
|
||||||
}
|
}
|
||||||
const emit = defineEmits(['update:show'])
|
const emit = defineEmits(['update:show'])
|
||||||
const showDetailInfo=ref(null)
|
const showDetailInfo=ref(null)
|
||||||
|
Loading…
Reference in New Issue
Block a user