Skip to content

Commit f2f11b1

Browse files
fix(mobile): tall image scrolling (#25649)
Add cross-axis gesture detection in PhotoView so vertical scrolling works on tall images that don't fill the screen width (have black bars)
1 parent 141be5c commit f2f11b1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

mobile/lib/widgets/photo_view/src/core/photo_view_gesture_detector.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,13 @@ class PhotoViewGestureRecognizer extends ScaleGestureRecognizer {
203203

204204
void _decideIfWeAcceptEvent(PointerEvent event) {
205205
final move = _initialFocalPoint! - _currentFocalPoint!;
206-
final bool shouldMove = validateAxis == Axis.vertical
207-
? hitDetector!.shouldMove(move, Axis.vertical)
208-
: hitDetector!.shouldMove(move, Axis.horizontal);
206+
207+
// Accept gesture if movement is possible in the direction the user is swiping
208+
final bool isHorizontalGesture = move.dx.abs() > move.dy.abs();
209+
final bool shouldMove = isHorizontalGesture
210+
? hitDetector!.shouldMove(move, Axis.horizontal)
211+
: hitDetector!.shouldMove(move, Axis.vertical);
212+
209213
if (shouldMove || _pointerLocations.keys.length > 1) {
210214
final double spanDelta = (_currentSpan! - _initialSpan!).abs();
211215
final double focalPointDelta = (_currentFocalPoint! - _initialFocalPoint!).distance;

0 commit comments

Comments
 (0)