Skip to content

Commit

Permalink
Prevent short swipes if starting a gesture on an internally scrolling…
Browse files Browse the repository at this point in the history
… element, mitigating accidental navigation while still allowing for intentional navigation gestures. (#3919)
  • Loading branch information
TomTirapani authored Feb 11, 2025
1 parent 072f825 commit ddf3979
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mobile/cmp/navigator/NavigatorModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export class NavigatorModel extends HoistModel {
// to propagate to scrollable elements within the page.
swiper.on('touchStart', (s, event: PointerEvent) => {
swiper.allowTouchMove = false;
swiper.params.shortSwipes = true;
this._touchStartX = event.pageX;
});

Expand All @@ -175,6 +176,12 @@ export class NavigatorModel extends HoistModel {
swiper.allowTouchMove =
swiper.progress < 1 || !isDraggableEl(scrollableParent, 'right');

// Disable short swipes to prevent accidental navigation when reaching the
// end of the scrollable parent.
if (!swiper.allowTouchMove) {
swiper.params.shortSwipes = false;
}

// During the swiper transition, undo the scrollable parent's internal scroll
// to keep it static.
if (swiper.progress < 1) {
Expand Down

0 comments on commit ddf3979

Please sign in to comment.