mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-26 16:21:55 +08:00
fix(modal): consider scrollable content while dragging when expandToScroll is false (#30257)
Issue number: internal --------- ## What is the current behavior? Changes introduced by #30235 caused two major issues: - Animations were not being played when increasing breakpoints. - When the scrollable content was at the top, and a big scroll to the bottom of the list was made, the modal would jump to a higher breakpoint. ## What is the new behavior? - When `expandToScroll` is false, the swipe gesture is allowed unless it's a pull down within scrollable content. - When `expandToScroll` is false, we cancel the `moveSheetToBreakpoint` when a scroll to top is being done within the scrollable content ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information | Before | After | |--------|-------| | <video src="https://github.com/user-attachments/assets/e1c22f48-f990-45cf-a6c4-1aec0d019c6d"> | <video src="https://github.com/user-attachments/assets/f01e0480-748f-40af-ac11-94f790f0e197"> |
This commit is contained in:

committed by
GitHub

parent
d36283e8c9
commit
68be8e915c
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -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.
|
||||
|
Reference in New Issue
Block a user