()
| 1192 | } |
| 1193 | |
| 1194 | private handleViewTransition() { |
| 1195 | // Only run view transitions when the modal is presented |
| 1196 | if (!this.presented) { |
| 1197 | return; |
| 1198 | } |
| 1199 | |
| 1200 | const isPortrait = window.innerWidth < 768; |
| 1201 | |
| 1202 | // Only transition if view state actually changed |
| 1203 | if (this.currentViewIsPortrait === isPortrait) { |
| 1204 | return; |
| 1205 | } |
| 1206 | |
| 1207 | // Cancel any ongoing transition animation |
| 1208 | if (this.viewTransitionAnimation) { |
| 1209 | this.viewTransitionAnimation.destroy(); |
| 1210 | this.viewTransitionAnimation = undefined; |
| 1211 | } |
| 1212 | |
| 1213 | const { presentingElement } = this; |
| 1214 | if (!presentingElement) { |
| 1215 | return; |
| 1216 | } |
| 1217 | |
| 1218 | // Create transition animation |
| 1219 | let transitionAnimation: Animation; |
| 1220 | if (this.currentViewIsPortrait && !isPortrait) { |
| 1221 | // Portrait to landscape transition |
| 1222 | transitionAnimation = portraitToLandscapeTransition(this.el, { |
| 1223 | presentingEl: presentingElement, |
| 1224 | currentBreakpoint: this.currentBreakpoint, |
| 1225 | backdropBreakpoint: this.backdropBreakpoint, |
| 1226 | expandToScroll: this.expandToScroll, |
| 1227 | }); |
| 1228 | } else { |
| 1229 | // Landscape to portrait transition |
| 1230 | transitionAnimation = landscapeToPortraitTransition(this.el, { |
| 1231 | presentingEl: presentingElement, |
| 1232 | currentBreakpoint: this.currentBreakpoint, |
| 1233 | backdropBreakpoint: this.backdropBreakpoint, |
| 1234 | expandToScroll: this.expandToScroll, |
| 1235 | }); |
| 1236 | } |
| 1237 | |
| 1238 | // Update state and play animation |
| 1239 | this.currentViewIsPortrait = isPortrait; |
| 1240 | this.viewTransitionAnimation = transitionAnimation; |
| 1241 | |
| 1242 | transitionAnimation.play().then(() => { |
| 1243 | this.viewTransitionAnimation = undefined; |
| 1244 | |
| 1245 | // Wait for a layout pass after the transition so getBoundingClientRect() |
| 1246 | // in getPositionBasedSafeAreaConfig() reflects the new dimensions. |
| 1247 | raf(() => this.updateSafeAreaOverrides()); |
| 1248 | |
| 1249 | // After orientation transition, recreate the swipe-to-close gesture |
| 1250 | // with updated animation that reflects the new presenting element state |
| 1251 | this.reinitSwipeToClose(); |
no test coverage detected