Skip to content

Commit

Permalink
fix(mobile): Improve vertical swipe detection in gallery viewer (#3486)
Browse files Browse the repository at this point in the history
* Improve vertical swipe detection in gallery viewer

* Use final
  • Loading branch information
mPyKen authored Jul 31, 2023
1 parent e0a3e5a commit a9cd360
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mobile/lib/modules/asset_viewer/views/gallery_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ class GalleryViewerPage extends HookConsumerWidget {
void handleSwipeUpDown(DragUpdateDetails details) {
int sensitivity = 15;
int dxThreshold = 50;
double ratioThreshold = 3.0;

if (isZoomed.value) {
return;
Expand All @@ -256,9 +257,10 @@ class GalleryViewerPage extends HookConsumerWidget {
return;
}

if (details.delta.dy > sensitivity) {
final ratio = d.dy / max(d.dx.abs(), 1);
if (d.dy > sensitivity && ratio > ratioThreshold) {
AutoRouter.of(context).pop();
} else if (details.delta.dy < -sensitivity) {
} else if (d.dy < -sensitivity && ratio < -ratioThreshold) {
showInfo();
}
}
Expand Down

0 comments on commit a9cd360

Please sign in to comment.