fix: perfect search modal code

This commit is contained in:
chansee97 2024-05-11 22:55:13 +08:00
parent 35df1832f4
commit 3b3b964067

View File

@ -101,12 +101,7 @@ function handleArrowup() {
else else
selectedIndex.value-- selectedIndex.value--
nextTick(() => { handleScroll(selectedIndex.value)
const distance = selectedIndex.value * 70 > 350 ? selectedIndex.value * 70 - 350 : 0
scrollbarRef.value?.scrollTo({
top: distance,
})
})
} }
// //
@ -117,14 +112,19 @@ function handleArrowdown() {
else else
selectedIndex.value++ selectedIndex.value++
nextTick(() => { handleScroll(selectedIndex.value)
const distance = selectedIndex.value * 70 > 350 ? selectedIndex.value * 70 - 350 : 0
scrollbarRef.value?.scrollTo({
top: distance,
})
})
} }
function handleScroll(currentIndex: number) {
// 6,6
const keepIndex = 5
// gappadding
const elHeight = 70
const distance = currentIndex * elHeight > keepIndex * elHeight ? currentIndex * elHeight - keepIndex * elHeight : 0
scrollbarRef.value?.scrollTo({
top: distance,
})
}
// //
function handleEnter() { function handleEnter() {
const target = options.value[selectedIndex.value] const target = options.value[selectedIndex.value]