Skip to content

Commit 7686118

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

File tree

3 files changed

+8
-58
lines changed

3 files changed

+8
-58
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: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -145,61 +145,9 @@
145145
>
146146
Backdrop is inactive
147147
</button>
148-
<ion-button id="open-footer-test-modal" expand="block">Present Sheet Modal (footer test)</ion-button>
149-
<ion-modal class="footer-test-modal" mode="ios" trigger="open-footer-test-modal" initial-breakpoint="0.25" expand-to-scroll="false"
150-
>
151-
<ion-content>
152-
<ion-text>
153-
<p>This is a modal!!</p>
154-
</ion-text>
155-
<ion-list>
156-
<ion-item>Item</ion-item>
157-
<ion-item>Item</ion-item>
158-
<ion-item>Item</ion-item>
159-
<ion-item>Item</ion-item>
160-
<ion-item>Item</ion-item>
161-
<ion-item>Item</ion-item>
162-
<ion-item>Item</ion-item>
163-
<ion-item>Item</ion-item>
164-
<ion-item>Item</ion-item>
165-
<ion-item>Item</ion-item>
166-
<ion-item>Item</ion-item>
167-
<ion-item>Item</ion-item>
168-
<ion-item>Item</ion-item>
169-
<ion-item>Item</ion-item>
170-
<ion-item>Item</ion-item>
171-
<ion-item>Item</ion-item>
172-
<ion-item>Item</ion-item>
173-
<ion-item>Item</ion-item>
174-
<ion-item>Item</ion-item>
175-
<ion-item>Item</ion-item>
176-
<ion-item>Item</ion-item>
177-
<ion-item>Item</ion-item>
178-
<ion-item>Item</ion-item>
179-
<ion-item>Item</ion-item>
180-
<ion-item>Item</ion-item>
181-
<ion-item>Item</ion-item>
182-
<ion-item>Item</ion-item>
183-
<ion-item>Item</ion-item>
184-
<ion-item>Item</ion-item>
185-
<ion-item>Item</ion-item>
186-
<ion-item>Item</ion-item>
187-
</ion-list>
188-
The end!
189-
</ion-content>
190-
<ion-footer slot="footer">
191-
<ion-toolbar>
192-
Hello world!
193-
<ion-textarea placeholder="This is a textarea" />
194-
</ion-toolbar>
195-
</ion-footer>
196-
</ion-modal>
197-
<script>
198-
var footerTestModal = document.getElementsByClassName('footer-test-modal')[0];
199-
footerTestModal.breakpoints = [0, 0.25, 0.5, 0.75, 1];
200-
</script>
201148

202-
< <div class="grid-item red"></div>
149+
<div class="grid">
150+
<div class="grid-item red"></div>
203151
<div class="grid-item green"></div>
204152
<div class="grid-item blue"></div>
205153
<div class="grid-item yellow"></div>

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)