@@ -84,6 +84,7 @@ export const createSheetGesture = (
84
84
let offset = 0 ;
85
85
let canDismissBlocksGesture = false ;
86
86
let cachedScrollEl : HTMLElement | null = null ;
87
+ let cachedFooterEl : HTMLIonFooterElement | null = null ;
87
88
let cachedFooterYPosition : number | null = null ;
88
89
let currentFooterState : 'moving' | 'stationary' | null = null ;
89
90
const canDismissMaxStep = 0.95 ;
@@ -125,33 +126,44 @@ export const createSheetGesture = (
125
126
* @param footer Whether the footer is in a moving or stationary position.
126
127
*/
127
128
const swapFooterPosition = ( newPosition : 'moving' | 'stationary' ) => {
128
- const originalFooter = baseEl . querySelector ( 'ion-footer' ) as HTMLIonFooterElement | null ;
129
- if ( ! originalFooter ) {
130
- return ;
129
+ if ( ! cachedFooterEl ) {
130
+ cachedFooterEl = baseEl . querySelector ( 'ion-footer' ) as HTMLIonFooterElement | null ;
131
+ if ( ! cachedFooterEl ) {
132
+ return ;
133
+ }
131
134
}
132
135
136
+ const page = baseEl . querySelector ( '.ion-page' ) as HTMLElement | null ;
137
+
133
138
currentFooterState = newPosition ;
134
139
if ( newPosition === 'stationary' ) {
135
140
// Reset positioning styles to allow normal document flow
136
- originalFooter . style . removeProperty ( 'position' ) ;
137
- originalFooter . style . removeProperty ( 'bottom' ) ;
138
- originalFooter . parentElement ?. style . removeProperty ( 'padding-bottom' ) ;
141
+ cachedFooterEl . style . removeProperty ( 'position' ) ;
142
+ cachedFooterEl . style . removeProperty ( 'bottom' ) ;
143
+ page ?. style . removeProperty ( 'padding-bottom' ) ;
144
+
145
+ // Move to page
146
+ console . log ( 'Moving footer to page' ) ;
147
+ page ?. appendChild ( cachedFooterEl ) ;
139
148
} else {
140
149
// Add padding to the parent element to prevent content from being hidden
141
150
// when the footer is positioned absolutely. This has to be done before we
142
151
// make the footer absolutely positioned or we may accidentally cause the
143
152
// sheet to scroll.
144
- const footerHeight = originalFooter . clientHeight ;
145
- originalFooter . parentElement ?. style . setProperty ( 'padding-bottom' , `${ footerHeight } px` ) ;
153
+ const footerHeight = cachedFooterEl . clientHeight ;
154
+ page ?. style . setProperty ( 'padding-bottom' , `${ footerHeight } px` ) ;
146
155
147
156
// Apply positioning styles to keep footer at bottom
148
- originalFooter . style . setProperty ( 'position' , 'absolute' ) ;
149
- originalFooter . style . setProperty ( 'bottom' , '0' ) ;
157
+ cachedFooterEl . style . setProperty ( 'position' , 'absolute' ) ;
158
+ cachedFooterEl . style . setProperty ( 'bottom' , '0' ) ;
150
159
151
160
// Also cache the footer Y position, which we use to determine if the
152
161
// sheet has been moved below the footer. When that happens, we need to swap
153
162
// the position back so it will collapse correctly.
154
- cachedFooterYPosition = originalFooter . getBoundingClientRect ( ) . top + window . scrollY ;
163
+ cachedFooterYPosition = cachedFooterEl . getBoundingClientRect ( ) . top + window . scrollY ;
164
+
165
+ console . log ( 'Moving footer to body' ) ;
166
+ document . body . appendChild ( cachedFooterEl ) ;
155
167
}
156
168
} ;
157
169
0 commit comments