Skip to content

Commit

Permalink
fix: onSnapToItem not called if loop={false}
Browse files Browse the repository at this point in the history
  • Loading branch information
dohooo committed Oct 8, 2021
1 parent b33bb78 commit 1ce57f4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default function App() {
mode="parallax"
width={width}
data={data}
loop={false}
parallaxScrollingScale={0.8}
onSnapToItem={(index) => {
console.log('current index:', index);
Expand Down
3 changes: 2 additions & 1 deletion src/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ function Carousel<T extends unknown = any>(
i = i % 2;
break;
}
onSnapToItem && runOnJS(onSnapToItem)(i);
}

onSnapToItem && runOnJS(onSnapToItem)(i);
},
[onSnapToItem, loop, _data]
);
Expand Down

0 comments on commit 1ce57f4

Please sign in to comment.