Skip to content

Commit

Permalink
Allow snapping to the first snap point (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
suphon-t committed Jan 23, 2024
1 parent ff18830 commit 7f9b5d0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/use-snap-points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ export function useSnapPoints({

React.useEffect(() => {
if (activeSnapPointProp) {
const newIndex = snapPoints?.findIndex((snapPoint) => snapPoint === activeSnapPointProp) ?? null;
if (snapPointsOffset && newIndex && typeof snapPointsOffset[newIndex] === 'number') {
const newIndex = snapPoints?.findIndex((snapPoint) => snapPoint === activeSnapPointProp) ?? -1;
if (snapPointsOffset && newIndex !== -1 && typeof snapPointsOffset[newIndex] === 'number') {
snapToPoint(snapPointsOffset[newIndex] as number);
}
}
Expand Down

0 comments on commit 7f9b5d0

Please sign in to comment.