Skip to content

Commit 64a9ffb

Browse files
committed
feat(sheet): moving the footer of the sheet modal to the body while dragging to eliminate shaking
1 parent 662f216 commit 64a9ffb

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ export const createSheetGesture = (
138138
currentFooterState = newPosition;
139139
if (newPosition === 'stationary') {
140140
// Reset positioning styles to allow normal document flow
141+
cachedFooterEl.classList.remove('modal-footer-moving');
141142
cachedFooterEl.style.removeProperty('position');
142143
cachedFooterEl.style.removeProperty('bottom');
143144
page?.style.removeProperty('padding-bottom');
144145

145146
// Move to page
146-
console.log('Moving footer to page');
147147
page?.appendChild(cachedFooterEl);
148148
} else {
149149
// Add padding to the parent element to prevent content from being hidden
@@ -154,6 +154,7 @@ export const createSheetGesture = (
154154
page?.style.setProperty('padding-bottom', `${footerHeight}px`);
155155

156156
// Apply positioning styles to keep footer at bottom
157+
cachedFooterEl.classList.add('modal-footer-moving');
157158
cachedFooterEl.style.setProperty('position', 'absolute');
158159
cachedFooterEl.style.setProperty('bottom', '0');
159160

@@ -162,7 +163,6 @@ export const createSheetGesture = (
162163
// the position back so it will collapse correctly.
163164
cachedFooterYPosition = cachedFooterEl.getBoundingClientRect().top + window.scrollY;
164165

165-
console.log('Moving footer to body');
166166
document.body.appendChild(cachedFooterEl);
167167
}
168168
};

core/src/components/modal/test/sheet/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@
188188
The end!
189189
</ion-content>
190190
<ion-footer slot="footer">
191+
<ion-toolbar>
192+
<ion-buttons slot="start">
193+
<ion-back-button></ion-back-button>
194+
</ion-buttons>
195+
<ion-title>Back Button Example</ion-title>
196+
</ion-toolbar>
191197
<ion-toolbar>
192198
Hello world!
193199
<ion-textarea placeholder="This is a textarea" />

core/src/css/core.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ body.backdrop-no-scroll {
5555
*/
5656
html.ios ion-modal.modal-card ion-header ion-toolbar:first-of-type,
5757
html.ios ion-modal.modal-sheet ion-header ion-toolbar:first-of-type,
58-
html.ios ion-modal ion-footer ion-toolbar:first-of-type {
58+
html.ios ion-modal ion-footer ion-toolbar:first-of-type,
59+
html.ios ion-footer.modal-footer-moving ion-toolbar:first-of-type {
5960
padding-top: $modal-sheet-padding-top;
6061
}
6162

@@ -74,7 +75,8 @@ html.ios ion-modal.modal-sheet ion-header ion-toolbar:last-of-type {
7475
* of toolbars while accounting for
7576
* safe area values when in landscape.
7677
*/
77-
html.ios ion-modal ion-toolbar {
78+
html.ios ion-modal ion-toolbar,
79+
html.ios .modal-footer-moving ion-toolbar {
7880
padding-right: calc(var(--ion-safe-area-right) + 8px);
7981
padding-left: calc(var(--ion-safe-area-left) + 8px);
8082
}

0 commit comments

Comments
 (0)