Skip to content
24 changes: 21 additions & 3 deletions core/src/components/modal/gestures/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,16 @@ export const createSheetGesture = (

const onMove = (detail: GestureDetail) => {
/**
* If `expandToScroll` is disabled, we should not allow the swipe gesture
* to continue if the gesture is not pulling down.
* If `expandToScroll` is disabled, and an upwards swipe gesture is done within
* the scrollable content, we should not allow the swipe gesture to continue.
*/
if (!expandToScroll && detail.deltaY <= 0) {
return;
const contentEl = findClosestIonContent(detail.event.target! as HTMLElement);
const scrollEl =
contentEl && isIonContent(contentEl) ? getElementRoot(contentEl).querySelector('.inner-scroll') : contentEl;
if (scrollEl) {
return;
}
}

/**
Expand Down Expand Up @@ -324,6 +329,19 @@ export const createSheetGesture = (
};

const onEnd = (detail: GestureDetail) => {
/**
* If expandToScroll is disabled, we should not allow the moveSheetToBreakpoint
* function to be called if the user is trying to swipe content upwards and the content
* is not scrolled to the top.
*/
if (!expandToScroll && detail.deltaY <= 0 && findClosestIonContent(detail.event.target! as HTMLElement)) {
const contentEl = findClosestIonContent(detail.event.target! as HTMLElement)!;
const scrollEl = isIonContent(contentEl) ? getElementRoot(contentEl).querySelector('.inner-scroll') : contentEl;
if (scrollEl!.scrollTop > 0) {
return;
}
}

/**
* When the gesture releases, we need to determine
* the closest breakpoint to snap to.
Expand Down
Loading