Skip to content

Commit 112929c

Browse files
committed
fix(modal): clarity around mobile/portrait terminology
1 parent 0deee3d commit 112929c

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

core/src/components/modal/animations/ios.enter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const iosEnterAnimation = (baseEl: HTMLElement, opts: ModalAnimationOptio
4848
}
4949

5050
if (presentingEl) {
51-
const isMobile = window.innerWidth < 768;
51+
const isPortrait = window.innerWidth < 768;
5252
const hasCardModal =
5353
presentingEl.tagName === 'ION-MODAL' && (presentingEl as HTMLIonModalElement).presentingElement !== undefined;
5454
const presentingElRoot = getElementRoot(presentingEl);
@@ -61,7 +61,7 @@ export const iosEnterAnimation = (baseEl: HTMLElement, opts: ModalAnimationOptio
6161

6262
const bodyEl = document.body;
6363

64-
if (isMobile) {
64+
if (isPortrait) {
6565
/**
6666
* Fallback for browsers that does not support `max()` (ex: Firefox)
6767
* No need to worry about statusbar padding since engines like Gecko

core/src/components/modal/animations/ios.leave.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const iosLeaveAnimation = (baseEl: HTMLElement, opts: ModalAnimationOptio
3535
.addAnimation(wrapperAnimation);
3636

3737
if (presentingEl) {
38-
const isMobile = window.innerWidth < 768;
38+
const isPortrait = window.innerWidth < 768;
3939
const hasCardModal =
4040
presentingEl.tagName === 'ION-MODAL' && (presentingEl as HTMLIonModalElement).presentingElement !== undefined;
4141
const presentingElRoot = getElementRoot(presentingEl);
@@ -61,7 +61,7 @@ export const iosLeaveAnimation = (baseEl: HTMLElement, opts: ModalAnimationOptio
6161

6262
const bodyEl = document.body;
6363

64-
if (isMobile) {
64+
if (isPortrait) {
6565
const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
6666
const modalTransform = hasCardModal ? '-10px' : transformOffset;
6767
const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;

core/src/components/modal/animations/ios.transition.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { SwipeToCloseDefaults } from '../gestures/swipe-to-close';
66
import type { ModalAnimationOptions } from '../modal-interface';
77

88
/**
9-
* Transition animation from mobile view to portrait view
10-
* This handles the case where a card modal is open in mobile view
11-
* and the user switches to portrait view
9+
* Transition animation from portrait view to landscape view
10+
* This handles the case where a card modal is open in portrait view
11+
* and the user switches to landscape view
1212
*/
13-
export const mobileToPortraitTransition = (
13+
export const portraitToLandscapeTransition = (
1414
baseEl: HTMLElement,
1515
opts: ModalAnimationOptions,
1616
duration = 300
@@ -19,36 +19,36 @@ export const mobileToPortraitTransition = (
1919

2020
if (!presentingEl) {
2121
// No transition needed for non-card modals
22-
return createAnimation('mobile-to-portrait-transition');
22+
return createAnimation('portrait-to-landscape-transition');
2323
}
2424

2525
const hasCardModal =
2626
presentingEl.tagName === 'ION-MODAL' && (presentingEl as HTMLIonModalElement).presentingElement !== undefined;
2727
const presentingElRoot = getElementRoot(presentingEl);
2828
const bodyEl = document.body;
2929

30-
const baseAnimation = createAnimation('mobile-to-portrait-transition')
30+
const baseAnimation = createAnimation('portrait-to-landscape-transition')
3131
.addElement(baseEl)
3232
.easing('cubic-bezier(0.32,0.72,0,1)')
3333
.duration(duration);
3434

3535
const presentingAnimation = createAnimation();
3636

3737
if (!hasCardModal) {
38-
// Non-card modal: transition from mobile state to portrait state
39-
// Mobile: presentingEl has transform and body has black background
40-
// Portrait: no transform, no body background, modal wrapper opacity changes
38+
// Non-card modal: transition from portrait state to landscape state
39+
// Portrait: presentingEl has transform and body has black background
40+
// Landscape: no transform, no body background, modal wrapper opacity changes
4141

4242
const root = getElementRoot(baseEl);
4343
const wrapperAnimation = createAnimation()
4444
.addElement(root.querySelectorAll('.modal-wrapper, .modal-shadow')!)
45-
.fromTo('opacity', '1', '1'); // Keep wrapper visible in portrait
45+
.fromTo('opacity', '1', '1'); // Keep wrapper visible in landscape
4646

4747
const backdropAnimation = createAnimation()
4848
.addElement(root.querySelector('ion-backdrop')!)
4949
.fromTo('opacity', 'var(--backdrop-opacity)', 'var(--backdrop-opacity)'); // Keep backdrop visible
5050

51-
// Animate presentingEl from mobile state back to normal
51+
// Animate presentingEl from portrait state back to normal
5252
const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
5353
const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;
5454
const fromTransform = `translateY(${transformOffset}) scale(${toPresentingScale})`;
@@ -62,7 +62,7 @@ export const mobileToPortraitTransition = (
6262

6363
baseAnimation.addAnimation([presentingAnimation, wrapperAnimation, backdropAnimation]);
6464
} else {
65-
// Card modal: transition from mobile card state to portrait card state
65+
// Card modal: transition from portrait card state to landscape card state
6666
const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;
6767
const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
6868
const fromTransform = `translateY(${transformOffset}) scale(${toPresentingScale})`;
@@ -75,7 +75,7 @@ export const mobileToPortraitTransition = (
7575

7676
const shadowAnimation = createAnimation()
7777
.addElement(presentingElRoot.querySelector('.modal-shadow')!)
78-
.fromTo('opacity', '0', '0') // Shadow stays hidden in portrait for card modals
78+
.fromTo('opacity', '0', '0') // Shadow stays hidden in landscape for card modals
7979
.fromTo('transform', fromTransform, toTransform);
8080

8181
baseAnimation.addAnimation([presentingAnimation, shadowAnimation]);
@@ -85,11 +85,11 @@ export const mobileToPortraitTransition = (
8585
};
8686

8787
/**
88-
* Transition animation from portrait view to mobile view
89-
* This handles the case where a card modal is open in portrait view
90-
* and the user switches to mobile view
88+
* Transition animation from landscape view to portrait view
89+
* This handles the case where a card modal is open in landscape view
90+
* and the user switches to portrait view
9191
*/
92-
export const portraitToMobileTransition = (
92+
export const landscapeToPortraitTransition = (
9393
baseEl: HTMLElement,
9494
opts: ModalAnimationOptions,
9595
duration = 300
@@ -98,23 +98,23 @@ export const portraitToMobileTransition = (
9898

9999
if (!presentingEl) {
100100
// No transition needed for non-card modals
101-
return createAnimation('portrait-to-mobile-transition');
101+
return createAnimation('landscape-to-portrait-transition');
102102
}
103103

104104
const hasCardModal =
105105
presentingEl.tagName === 'ION-MODAL' && (presentingEl as HTMLIonModalElement).presentingElement !== undefined;
106106
const presentingElRoot = getElementRoot(presentingEl);
107107
const bodyEl = document.body;
108108

109-
const baseAnimation = createAnimation('portrait-to-mobile-transition')
109+
const baseAnimation = createAnimation('landscape-to-portrait-transition')
110110
.addElement(baseEl)
111111
.easing('cubic-bezier(0.32,0.72,0,1)')
112112
.duration(duration);
113113

114114
const presentingAnimation = createAnimation();
115115

116116
if (!hasCardModal) {
117-
// Non-card modal: transition from portrait state to mobile state
117+
// Non-card modal: transition from landscape state to portrait state
118118
const root = getElementRoot(baseEl);
119119
const wrapperAnimation = createAnimation()
120120
.addElement(root.querySelectorAll('.modal-wrapper, .modal-shadow')!)
@@ -124,7 +124,7 @@ export const portraitToMobileTransition = (
124124
.addElement(root.querySelector('ion-backdrop')!)
125125
.fromTo('opacity', 'var(--backdrop-opacity)', 'var(--backdrop-opacity)'); // Keep backdrop visible
126126

127-
// Animate presentingEl from normal state to mobile state
127+
// Animate presentingEl from normal state to portrait state
128128
const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
129129
const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;
130130
const toTransform = `translateY(${transformOffset}) scale(${toPresentingScale})`;
@@ -138,7 +138,7 @@ export const portraitToMobileTransition = (
138138

139139
baseAnimation.addAnimation([presentingAnimation, wrapperAnimation, backdropAnimation]);
140140
} else {
141-
// Card modal: transition from portrait card state to mobile card state
141+
// Card modal: transition from landscape card state to portrait card state
142142
const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;
143143
const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
144144
const fromTransform = `translateY(-10px) scale(${toPresentingScale})`;

core/src/components/modal/modal.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import type { OverlayEventDetail } from '../../utils/overlays-interface';
3737

3838
import { iosEnterAnimation } from './animations/ios.enter';
3939
import { iosLeaveAnimation } from './animations/ios.leave';
40-
import { mobileToPortraitTransition, portraitToMobileTransition } from './animations/ios.transition';
40+
import { portraitToLandscapeTransition, landscapeToPortraitTransition } from './animations/ios.transition';
4141
import { mdEnterAnimation } from './animations/md.enter';
4242
import { mdLeaveAnimation } from './animations/md.leave';
4343
import type { MoveSheetToBreakpointOptions } from './gestures/sheet';
@@ -91,9 +91,9 @@ export class Modal implements ComponentInterface, OverlayInterface {
9191
// Whether or not modal is being dismissed via gesture
9292
private gestureAnimationDismissing = false;
9393

94-
// View transition properties for handling mobile/portrait switches
94+
// View transition properties for handling portrait/landscape switches
9595
private resizeListener?: () => void;
96-
private currentViewIsMobile?: boolean;
96+
private currentViewIsPortrait?: boolean;
9797
private viewTransitionAnimation?: Animation;
9898

9999
lastFocus?: HTMLElement;
@@ -981,7 +981,7 @@ export class Modal implements ComponentInterface, OverlayInterface {
981981
}
982982

983983
// Set initial view state
984-
this.currentViewIsMobile = window.innerWidth < 768;
984+
this.currentViewIsPortrait = window.innerWidth < 768;
985985

986986
// Create debounced resize handler
987987
let resizeTimeout: any;
@@ -996,10 +996,10 @@ export class Modal implements ComponentInterface, OverlayInterface {
996996
}
997997

998998
private handleViewTransition() {
999-
const isMobile = window.innerWidth < 768;
999+
const isPortrait = window.innerWidth < 768;
10001000

10011001
// Only transition if view state actually changed
1002-
if (this.currentViewIsMobile === isMobile) {
1002+
if (this.currentViewIsPortrait === isPortrait) {
10031003
return;
10041004
}
10051005

@@ -1016,17 +1016,17 @@ export class Modal implements ComponentInterface, OverlayInterface {
10161016

10171017
// Create transition animation
10181018
let transitionAnimation: Animation;
1019-
if (this.currentViewIsMobile && !isMobile) {
1020-
// Mobile to portrait transition
1021-
transitionAnimation = mobileToPortraitTransition(this.el, {
1019+
if (this.currentViewIsPortrait && !isPortrait) {
1020+
// Portrait to landscape transition
1021+
transitionAnimation = portraitToLandscapeTransition(this.el, {
10221022
presentingEl: presentingElement,
10231023
currentBreakpoint: this.currentBreakpoint,
10241024
backdropBreakpoint: this.backdropBreakpoint,
10251025
expandToScroll: this.expandToScroll,
10261026
});
10271027
} else {
1028-
// Portrait to mobile transition
1029-
transitionAnimation = portraitToMobileTransition(this.el, {
1028+
// Landscape to portrait transition
1029+
transitionAnimation = landscapeToPortraitTransition(this.el, {
10301030
presentingEl: presentingElement,
10311031
currentBreakpoint: this.currentBreakpoint,
10321032
backdropBreakpoint: this.backdropBreakpoint,
@@ -1035,7 +1035,7 @@ export class Modal implements ComponentInterface, OverlayInterface {
10351035
}
10361036

10371037
// Update state and play animation
1038-
this.currentViewIsMobile = isMobile;
1038+
this.currentViewIsPortrait = isPortrait;
10391039
this.viewTransitionAnimation = transitionAnimation;
10401040

10411041
transitionAnimation.play().then(() => {

0 commit comments

Comments
 (0)