Skip to content

Commit 1ce57f4

Browse files
committed
fix: onSnapToItem not called if loop={false}
1 parent b33bb78 commit 1ce57f4

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

example/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default function App() {
3434
mode="parallax"
3535
width={width}
3636
data={data}
37+
loop={false}
3738
parallaxScrollingScale={0.8}
3839
onSnapToItem={(index) => {
3940
console.log('current index:', index);

src/Carousel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ function Carousel<T extends unknown = any>(
193193
i = i % 2;
194194
break;
195195
}
196-
onSnapToItem && runOnJS(onSnapToItem)(i);
197196
}
197+
198+
onSnapToItem && runOnJS(onSnapToItem)(i);
198199
},
199200
[onSnapToItem, loop, _data]
200201
);

0 commit comments

Comments
 (0)