Skip to content

Commit

Permalink
fix: changing swipe causes re-render and adjust sensitivity (#823)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkasdorf authored Jul 23, 2023
1 parent 29d7622 commit 4ac8297
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/components/common/Navigation/ScreenGestureHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ function ScreenGestureHandler({ children }: IProps) {

const onPanEnd = useCallback(
(event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {
if (event.translationX < 20 || Math.abs(event.translationY) >= 10) return;
if (swipeToVote) return;

if (event.translationX < 10 || Math.abs(event.translationY) >= 30) return;

navigation.pop();
},
[]
[swipeToVote]
);

if (swipeToVote) return children;

const panGesture = Gesture.Pan()
.maxPointers(1)
.activeOffsetX([-20, 20])
.cancelsTouchesInView(true)
.onEnd(onPanEnd);

return <GestureDetector gesture={panGesture}>{children}</GestureDetector>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function GeneralSettingsScreen() {
/>
<CCell
cellStyle="Basic"
title="Swipe to Vote"
title={t("settings.swipeToVote")}
backgroundColor={theme.colors.app.fg}
titleTextColor={theme.colors.app.textPrimary}
rightDetailColor={theme.colors.app.textSecondary}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"removedByMod": "Kommentar wurde von Moderatoren gelöscht :("
},
"settings": {
"swipeToVote": "Mit Wisch hoch-/runterwählen",
"haptics": {
"Off": "Keine",
"Light": "Schwach",
Expand Down
1 change: 1 addition & 0 deletions src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"removedByMod": "Comment removed by moderator :("
},
"settings": {
"swipeToVote": "Swipe to Vote",
"haptics": {
"Off": "Off",
"Light": "Light",
Expand Down

0 comments on commit 4ac8297

Please sign in to comment.