优化歌词滚动位置

This commit is contained in:
lyswhut 2023-09-03 16:16:19 +08:00
parent c921f08560
commit bf4977906b
2 changed files with 6 additions and 4 deletions

View File

@ -108,8 +108,9 @@ export default () => {
for (let line = 0; line < index; line++) {
offset += listLayoutInfoRef.current.lineHeights[line]
}
offset -= (listLayoutInfoRef.current.lineHeights[line] ?? 0) / 2
try {
scrollCancelRef.current = scrollTo(flatListRef.current, scrollInfoRef.current, offset - scrollInfoRef.current.layoutMeasurement.height * 0.36, 300, () => {
scrollCancelRef.current = scrollTo(flatListRef.current, scrollInfoRef.current, offset - scrollInfoRef.current.layoutMeasurement.height * 0.42, 300, () => {
scrollCancelRef.current = null
})
} catch {}
@ -122,7 +123,7 @@ export default () => {
flatListRef.current.scrollToIndex({
index,
animated: true,
viewPosition: 0.4,
viewPosition: 0.42,
})
} catch {}
}

View File

@ -148,8 +148,9 @@ export default () => {
for (let line = 0; line < index; line++) {
offset += listLayoutInfoRef.current.lineHeights[line]
}
offset += (listLayoutInfoRef.current.lineHeights[line] ?? 0) / 2
try {
scrollCancelRef.current = scrollTo(flatListRef.current, scrollInfoRef.current, offset - scrollInfoRef.current.layoutMeasurement.height * 0.36, 300, () => {
scrollCancelRef.current = scrollTo(flatListRef.current, scrollInfoRef.current, offset - scrollInfoRef.current.layoutMeasurement.height * 0.42, 300, () => {
scrollCancelRef.current = null
})
} catch {}
@ -162,7 +163,7 @@ export default () => {
flatListRef.current.scrollToIndex({
index,
animated: true,
viewPosition: 0.4,
viewPosition: 0.42,
})
} catch {}
}