Skip to content

Commit

Permalink
fix: carousel crashes when swiping in the opposite direction
Browse files Browse the repository at this point in the history
fix #215
  • Loading branch information
dohooo committed Jun 28, 2022
1 parent c76d759 commit b5fc081
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/ScrollViewGesture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ const IScrollViewGesture: React.FC<Props> = (props) => {
return;
}

const direction =
-scrollEndTranslation.value /
Math.abs(scrollEndTranslation.value);
const direction = -(scrollEndTranslation.value >= 0 ? 1 : -1);
const computed = direction < 0 ? Math.ceil : Math.floor;
const page = computed(-translation.value / size);
let finalPage = page + direction;
Expand Down

0 comments on commit b5fc081

Please sign in to comment.