From 6b5c9e11ec0d55466cf8e69aa0e757f09e2aa519 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Tue, 2 Apr 2024 22:36:51 -0400 Subject: [PATCH] fix(modal): remove enable scrolling delay with sheet modal --- core/src/components/modal/gestures/sheet.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/core/src/components/modal/gestures/sheet.ts b/core/src/components/modal/gestures/sheet.ts index 0e3fca6b8bb..3cdbe4cef9d 100644 --- a/core/src/components/modal/gestures/sheet.ts +++ b/core/src/components/modal/gestures/sheet.ts @@ -314,6 +314,17 @@ export const createSheetGesture = ( onDismiss(); } + /** + * If the sheet is going to be fully expanded then we should enable + * scrolling immediately. The sheet modal animation takes ~500ms to finish + * so if we wait until then there is a visible delay for when scrolling is + * re-enabled. Native iOS allows for scrolling on the sheet modal as soon + * as the gesture is released, so we align with that. + */ + if (contentEl && snapToBreakpoint === breakpoints[breakpoints.length - 1]) { + contentEl.scrollY = true; + } + return new Promise((resolve) => { animation .onFinish( @@ -334,14 +345,6 @@ export const createSheetGesture = ( currentBreakpoint = snapToBreakpoint; onBreakpointChange(currentBreakpoint); - /** - * If the sheet is fully expanded, we can safely - * enable scrolling again. - */ - if (contentEl && currentBreakpoint === breakpoints[breakpoints.length - 1]) { - contentEl.scrollY = true; - } - /** * Backdrop should become enabled * after the backdropBreakpoint value