MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / handleViewTransition

Method handleViewTransition

core/src/components/modal/modal.tsx:1194–1253  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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();

Callers 1

onWindowResizeMethod · 0.95

Calls 7

reinitSwipeToCloseMethod · 0.95
rafFunction · 0.90
playMethod · 0.80
destroyMethod · 0.65

Tested by

no test coverage detected