Skip to content

Commit

Permalink
修复children变化时当前滚动到的索引位置大的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
luyongfang committed Jan 8, 2025
1 parent fd78078 commit 1875716
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,16 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
runOnJS(handleSwiperChange)(newIndex)
}
})

useEffect(() => {
if (childrenLength - 1 < currentIndex.value) {
pauseLoop()
currentIndex.value = 0
offset.value = getOffset(0, step.value)
resumeLoop()
}
},[childrenLength])

useEffect(() => {
if (!step.value) {
return
Expand Down

0 comments on commit 1875716

Please sign in to comment.