Skip to content

Commit ac11277

Browse files
committed
restored footer onMove and onEnd animations
1 parent 396bf73 commit ac11277

File tree

1 file changed

+26
-4
lines changed
  • core/src/components/modal/gestures

1 file changed

+26
-4
lines changed

core/src/components/modal/gestures/sheet.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ export const createSheetGesture = (
5454
onDismiss: () => void,
5555
onBreakpointChange: (breakpoint: number) => void
5656
) => {
57+
const contentEl = baseEl.querySelector('ion-content');
58+
const height = wrapperEl.clientHeight;
59+
const footerEl = baseEl.shadowRoot?.querySelector('ion-footer');
60+
const footerHeight = footerEl?.clientHeight ?? 0;
61+
const footerDismissalPercentage = parseFloat(( 1 - (footerHeight ? (footerHeight / height) : 0)).toFixed(2));
62+
5763
// Defaults for the sheet swipe animation
5864
const defaultBackdrop = [
5965
{ offset: 0, opacity: 'var(--backdrop-opacity)' },
@@ -75,11 +81,14 @@ export const createSheetGesture = (
7581
CONTENT_KEYFRAMES: [
7682
{ offset: 0, maxHeight: '100%' },
7783
{ offset: 1, maxHeight: '0%' },
78-
]
84+
],
85+
FOOTER_KEYFRAMES: [
86+
{ offset: 0, transform: 'translateY(0)' },
87+
{ offset: footerDismissalPercentage, transform: 'translateY(0)' },
88+
{ offset: 1, transform: `translateY(${footerHeight}px)` },
89+
],
7990
};
8091

81-
const contentEl = baseEl.querySelector('ion-content');
82-
const height = wrapperEl.clientHeight;
8392
let currentBreakpoint = initialBreakpoint;
8493
let offset = 0;
8594
let canDismissBlocksGesture = false;
@@ -89,7 +98,11 @@ export const createSheetGesture = (
8998
const wrapperAnimation = animation.childAnimations.find((ani) => ani.id === 'wrapperAnimation');
9099
const backdropAnimation = animation.childAnimations.find((ani) => ani.id === 'backdropAnimation');
91100
const contentAnimation = animation.childAnimations.find((ani) => ani.id === 'contentAnimation');
92-
animation.childAnimations.find((ani) => ani.id === 'footerAnimation')?.destroy();
101+
const footerAnimation = animation.childAnimations.find((ani) => ani.id === 'footerAnimation');
102+
103+
if (footerAnimation && footerEl) {
104+
// footerAnimation.addElement(footerEl);
105+
}
93106

94107
const enableBackdrop = () => {
95108
baseEl.style.setProperty('pointer-events', 'auto');
@@ -129,6 +142,7 @@ export const createSheetGesture = (
129142
wrapperAnimation.keyframes([...SheetDefaults.WRAPPER_KEYFRAMES]);
130143
backdropAnimation.keyframes([...SheetDefaults.BACKDROP_KEYFRAMES]);
131144
contentAnimation?.keyframes([...SheetDefaults.CONTENT_KEYFRAMES]);
145+
footerAnimation?.keyframes([...SheetDefaults.FOOTER_KEYFRAMES]);
132146

133147
animation.progressStart(true, 1 - currentBreakpoint);
134148

@@ -354,6 +368,13 @@ export const createSheetGesture = (
354368
]);
355369
}
356370

371+
if (footerAnimation) {
372+
footerAnimation.keyframes([
373+
{ offset: 0, transform: 'translateY(0)' },
374+
{ offset: 0.85, transform: 'translateY(0)' },
375+
{ offset: footerDismissalPercentage, transform: `translateY(${!shouldRemainOpen ? footerHeight : 0}px)` },
376+
])
377+
}
357378
animation.progressStep(0);
358379
}
359380

@@ -398,6 +419,7 @@ export const createSheetGesture = (
398419
wrapperAnimation.keyframes([...SheetDefaults.WRAPPER_KEYFRAMES]);
399420
backdropAnimation.keyframes([...SheetDefaults.BACKDROP_KEYFRAMES]);
400421
contentAnimation?.keyframes([...SheetDefaults.CONTENT_KEYFRAMES]);
422+
footerAnimation?.keyframes([...SheetDefaults.FOOTER_KEYFRAMES]);
401423
animation.progressStart(true, 1 - snapToBreakpoint);
402424
currentBreakpoint = snapToBreakpoint;
403425
onBreakpointChange(currentBreakpoint);

0 commit comments

Comments
 (0)