mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-05 21:58:56 +08:00
优化歌词滚动位置
This commit is contained in:
parent
c921f08560
commit
bf4977906b
@ -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 {}
|
||||
}
|
||||
|
@ -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 {}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user