@ionic/core 8.6.3-dev.11750971489.140836b0 → 8.6.3-dev.11751305829.1112929c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -587,7 +587,7 @@ const iosEnterAnimation = (baseEl, opts) => {
587
587
  baseAnimation.addAnimation(contentAnimation);
588
588
  }
589
589
  if (presentingEl) {
590
- const isMobile = window.innerWidth < 768;
590
+ const isPortrait = window.innerWidth < 768;
591
591
  const hasCardModal = presentingEl.tagName === 'ION-MODAL' && presentingEl.presentingElement !== undefined;
592
592
  const presentingElRoot = getElementRoot(presentingEl);
593
593
  const presentingAnimation = createAnimation().beforeStyles({
@@ -596,7 +596,7 @@ const iosEnterAnimation = (baseEl, opts) => {
596
596
  overflow: 'hidden',
597
597
  });
598
598
  const bodyEl = document.body;
599
- if (isMobile) {
599
+ if (isPortrait) {
600
600
  /**
601
601
  * Fallback for browsers that does not support `max()` (ex: Firefox)
602
602
  * No need to worry about statusbar padding since engines like Gecko
@@ -674,7 +674,7 @@ const iosLeaveAnimation = (baseEl, opts, duration = 500) => {
674
674
  .duration(duration)
675
675
  .addAnimation(wrapperAnimation);
676
676
  if (presentingEl) {
677
- const isMobile = window.innerWidth < 768;
677
+ const isPortrait = window.innerWidth < 768;
678
678
  const hasCardModal = presentingEl.tagName === 'ION-MODAL' && presentingEl.presentingElement !== undefined;
679
679
  const presentingElRoot = getElementRoot(presentingEl);
680
680
  const presentingAnimation = createAnimation()
@@ -692,7 +692,7 @@ const iosLeaveAnimation = (baseEl, opts, duration = 500) => {
692
692
  }
693
693
  });
694
694
  const bodyEl = document.body;
695
- if (isMobile) {
695
+ if (isPortrait) {
696
696
  const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
697
697
  const modalTransform = hasCardModal ? '-10px' : transformOffset;
698
698
  const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;
@@ -739,6 +739,125 @@ const iosLeaveAnimation = (baseEl, opts, duration = 500) => {
739
739
  return baseAnimation;
740
740
  };
741
741
 
742
+ /**
743
+ * Transition animation from portrait view to landscape view
744
+ * This handles the case where a card modal is open in portrait view
745
+ * and the user switches to landscape view
746
+ */
747
+ const portraitToLandscapeTransition = (baseEl, opts, duration = 300) => {
748
+ const { presentingEl } = opts;
749
+ if (!presentingEl) {
750
+ // No transition needed for non-card modals
751
+ return createAnimation('portrait-to-landscape-transition');
752
+ }
753
+ const hasCardModal = presentingEl.tagName === 'ION-MODAL' && presentingEl.presentingElement !== undefined;
754
+ const presentingElRoot = getElementRoot(presentingEl);
755
+ const bodyEl = document.body;
756
+ const baseAnimation = createAnimation('portrait-to-landscape-transition')
757
+ .addElement(baseEl)
758
+ .easing('cubic-bezier(0.32,0.72,0,1)')
759
+ .duration(duration);
760
+ const presentingAnimation = createAnimation();
761
+ if (!hasCardModal) {
762
+ // Non-card modal: transition from portrait state to landscape state
763
+ // Portrait: presentingEl has transform and body has black background
764
+ // Landscape: no transform, no body background, modal wrapper opacity changes
765
+ const root = getElementRoot(baseEl);
766
+ const wrapperAnimation = createAnimation()
767
+ .addElement(root.querySelectorAll('.modal-wrapper, .modal-shadow'))
768
+ .fromTo('opacity', '1', '1'); // Keep wrapper visible in landscape
769
+ const backdropAnimation = createAnimation()
770
+ .addElement(root.querySelector('ion-backdrop'))
771
+ .fromTo('opacity', 'var(--backdrop-opacity)', 'var(--backdrop-opacity)'); // Keep backdrop visible
772
+ // Animate presentingEl from portrait state back to normal
773
+ const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
774
+ const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;
775
+ const fromTransform = `translateY(${transformOffset}) scale(${toPresentingScale})`;
776
+ presentingAnimation
777
+ .addElement(presentingEl)
778
+ .beforeAddWrite(() => bodyEl.style.setProperty('background-color', ''))
779
+ .fromTo('transform', fromTransform, 'translateY(0px) scale(1)')
780
+ .fromTo('filter', 'contrast(0.85)', 'contrast(1)')
781
+ .fromTo('border-radius', '10px 10px 0 0', '0px');
782
+ baseAnimation.addAnimation([presentingAnimation, wrapperAnimation, backdropAnimation]);
783
+ }
784
+ else {
785
+ // Card modal: transition from portrait card state to landscape card state
786
+ const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;
787
+ const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
788
+ const fromTransform = `translateY(${transformOffset}) scale(${toPresentingScale})`;
789
+ const toTransform = `translateY(-10px) scale(${toPresentingScale})`;
790
+ presentingAnimation
791
+ .addElement(presentingElRoot.querySelector('.modal-wrapper'))
792
+ .fromTo('transform', fromTransform, toTransform)
793
+ .fromTo('filter', 'contrast(0.85)', 'contrast(0.85)'); // Keep same contrast for card
794
+ const shadowAnimation = createAnimation()
795
+ .addElement(presentingElRoot.querySelector('.modal-shadow'))
796
+ .fromTo('opacity', '0', '0') // Shadow stays hidden in landscape for card modals
797
+ .fromTo('transform', fromTransform, toTransform);
798
+ baseAnimation.addAnimation([presentingAnimation, shadowAnimation]);
799
+ }
800
+ return baseAnimation;
801
+ };
802
+ /**
803
+ * Transition animation from landscape view to portrait view
804
+ * This handles the case where a card modal is open in landscape view
805
+ * and the user switches to portrait view
806
+ */
807
+ const landscapeToPortraitTransition = (baseEl, opts, duration = 300) => {
808
+ const { presentingEl } = opts;
809
+ if (!presentingEl) {
810
+ // No transition needed for non-card modals
811
+ return createAnimation('landscape-to-portrait-transition');
812
+ }
813
+ const hasCardModal = presentingEl.tagName === 'ION-MODAL' && presentingEl.presentingElement !== undefined;
814
+ const presentingElRoot = getElementRoot(presentingEl);
815
+ const bodyEl = document.body;
816
+ const baseAnimation = createAnimation('landscape-to-portrait-transition')
817
+ .addElement(baseEl)
818
+ .easing('cubic-bezier(0.32,0.72,0,1)')
819
+ .duration(duration);
820
+ const presentingAnimation = createAnimation();
821
+ if (!hasCardModal) {
822
+ // Non-card modal: transition from landscape state to portrait state
823
+ const root = getElementRoot(baseEl);
824
+ const wrapperAnimation = createAnimation()
825
+ .addElement(root.querySelectorAll('.modal-wrapper, .modal-shadow'))
826
+ .fromTo('opacity', '1', '1'); // Keep wrapper visible
827
+ const backdropAnimation = createAnimation()
828
+ .addElement(root.querySelector('ion-backdrop'))
829
+ .fromTo('opacity', 'var(--backdrop-opacity)', 'var(--backdrop-opacity)'); // Keep backdrop visible
830
+ // Animate presentingEl from normal state to portrait state
831
+ const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
832
+ const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;
833
+ const toTransform = `translateY(${transformOffset}) scale(${toPresentingScale})`;
834
+ presentingAnimation
835
+ .addElement(presentingEl)
836
+ .beforeAddWrite(() => bodyEl.style.setProperty('background-color', 'black'))
837
+ .fromTo('transform', 'translateY(0px) scale(1)', toTransform)
838
+ .fromTo('filter', 'contrast(1)', 'contrast(0.85)')
839
+ .fromTo('border-radius', '0px', '10px 10px 0 0');
840
+ baseAnimation.addAnimation([presentingAnimation, wrapperAnimation, backdropAnimation]);
841
+ }
842
+ else {
843
+ // Card modal: transition from landscape card state to portrait card state
844
+ const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;
845
+ const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
846
+ const fromTransform = `translateY(-10px) scale(${toPresentingScale})`;
847
+ const toTransform = `translateY(${transformOffset}) scale(${toPresentingScale})`;
848
+ presentingAnimation
849
+ .addElement(presentingElRoot.querySelector('.modal-wrapper'))
850
+ .fromTo('transform', fromTransform, toTransform)
851
+ .fromTo('filter', 'contrast(0.85)', 'contrast(0.85)'); // Keep same contrast for card
852
+ const shadowAnimation = createAnimation()
853
+ .addElement(presentingElRoot.querySelector('.modal-shadow'))
854
+ .fromTo('opacity', '0', '0') // Shadow stays hidden
855
+ .fromTo('transform', fromTransform, toTransform);
856
+ baseAnimation.addAnimation([presentingAnimation, shadowAnimation]);
857
+ }
858
+ return baseAnimation;
859
+ };
860
+
742
861
  const createEnterAnimation = () => {
743
862
  const backdropAnimation = createAnimation()
744
863
  .fromTo('opacity', 0.01, 'var(--backdrop-opacity)')
@@ -1522,6 +1641,7 @@ const Modal = /*@__PURE__*/ proxyCustomElement(class Modal extends HTMLElement {
1522
1641
  }
1523
1642
  disconnectedCallback() {
1524
1643
  this.triggerController.removeClickListener();
1644
+ this.cleanupViewTransitionListener();
1525
1645
  }
1526
1646
  componentWillLoad() {
1527
1647
  var _a;
@@ -1732,6 +1852,8 @@ const Modal = /*@__PURE__*/ proxyCustomElement(class Modal extends HTMLElement {
1732
1852
  else if (hasCardModal) {
1733
1853
  this.initSwipeToClose();
1734
1854
  }
1855
+ // Initialize view transition listener for iOS card modals
1856
+ this.initViewTransitionListener();
1735
1857
  unlock();
1736
1858
  }
1737
1859
  initSwipeToClose() {
@@ -1885,6 +2007,7 @@ const Modal = /*@__PURE__*/ proxyCustomElement(class Modal extends HTMLElement {
1885
2007
  if (this.gesture) {
1886
2008
  this.gesture.destroy();
1887
2009
  }
2010
+ this.cleanupViewTransitionListener();
1888
2011
  }
1889
2012
  this.currentBreakpoint = undefined;
1890
2013
  this.animation = undefined;
@@ -1960,6 +2083,67 @@ const Modal = /*@__PURE__*/ proxyCustomElement(class Modal extends HTMLElement {
1960
2083
  await this.setCurrentBreakpoint(nextBreakpoint);
1961
2084
  return true;
1962
2085
  }
2086
+ initViewTransitionListener() {
2087
+ // Only enable for iOS card modals when no custom animations are provided
2088
+ if (getIonMode(this) !== 'ios' || !this.presentingElement || this.enterAnimation || this.leaveAnimation) {
2089
+ return;
2090
+ }
2091
+ // Set initial view state
2092
+ this.currentViewIsPortrait = window.innerWidth < 768;
2093
+ // Create debounced resize handler
2094
+ let resizeTimeout;
2095
+ this.resizeListener = () => {
2096
+ clearTimeout(resizeTimeout);
2097
+ resizeTimeout = setTimeout(() => {
2098
+ this.handleViewTransition();
2099
+ }, 100); // Debounce for 100ms to avoid excessive calls
2100
+ };
2101
+ window.addEventListener('resize', this.resizeListener);
2102
+ }
2103
+ handleViewTransition() {
2104
+ const isPortrait = window.innerWidth < 768;
2105
+ // Only transition if view state actually changed
2106
+ if (this.currentViewIsPortrait === isPortrait) {
2107
+ return;
2108
+ }
2109
+ // Cancel any ongoing transition animation
2110
+ if (this.viewTransitionAnimation) {
2111
+ this.viewTransitionAnimation.destroy();
2112
+ this.viewTransitionAnimation = undefined;
2113
+ }
2114
+ const { presentingElement } = this;
2115
+ if (!presentingElement) {
2116
+ return;
2117
+ }
2118
+ // Create transition animation
2119
+ let transitionAnimation;
2120
+ if (this.currentViewIsPortrait && !isPortrait) {
2121
+ // Portrait to landscape transition
2122
+ transitionAnimation = portraitToLandscapeTransition(this.el, {
2123
+ presentingEl: presentingElement});
2124
+ }
2125
+ else {
2126
+ // Landscape to portrait transition
2127
+ transitionAnimation = landscapeToPortraitTransition(this.el, {
2128
+ presentingEl: presentingElement});
2129
+ }
2130
+ // Update state and play animation
2131
+ this.currentViewIsPortrait = isPortrait;
2132
+ this.viewTransitionAnimation = transitionAnimation;
2133
+ transitionAnimation.play().then(() => {
2134
+ this.viewTransitionAnimation = undefined;
2135
+ });
2136
+ }
2137
+ cleanupViewTransitionListener() {
2138
+ if (this.resizeListener) {
2139
+ window.removeEventListener('resize', this.resizeListener);
2140
+ this.resizeListener = undefined;
2141
+ }
2142
+ if (this.viewTransitionAnimation) {
2143
+ this.viewTransitionAnimation.destroy();
2144
+ this.viewTransitionAnimation = undefined;
2145
+ }
2146
+ }
1963
2147
  render() {
1964
2148
  const { handle, isSheetModal, presentingElement, htmlAttributes, handleBehavior, inheritedAttributes, focusTrap, expandToScroll, } = this;
1965
2149
  const showHandle = handle !== false && isSheetModal;
@@ -1967,20 +2151,20 @@ const Modal = /*@__PURE__*/ proxyCustomElement(class Modal extends HTMLElement {
1967
2151
  const isCardModal = presentingElement !== undefined && mode === 'ios';
1968
2152
  const isHandleCycle = handleBehavior === 'cycle';
1969
2153
  const isSheetModalWithHandle = isSheetModal && showHandle;
1970
- return (h(Host, Object.assign({ key: '8add05bb43a2cdb5e3cf180147d31eb85a018fe0', "no-router": true,
2154
+ return (h(Host, Object.assign({ key: 'd5bcaa588471573e1bcbd99997b306c8ecdd124f', "no-router": true,
1971
2155
  // Allow the modal to be navigable when the handle is focusable
1972
2156
  tabIndex: isHandleCycle && isSheetModalWithHandle ? 0 : -1 }, htmlAttributes, { style: {
1973
2157
  zIndex: `${20000 + this.overlayIndex}`,
1974
- }, class: Object.assign({ [mode]: true, ['modal-default']: !isCardModal && !isSheetModal, [`modal-card`]: isCardModal, [`modal-sheet`]: isSheetModal, [`modal-no-expand-scroll`]: isSheetModal && !expandToScroll, 'overlay-hidden': true, [FOCUS_TRAP_DISABLE_CLASS]: focusTrap === false }, getClassMap(this.cssClass)), onIonBackdropTap: this.onBackdropTap, onIonModalDidPresent: this.onLifecycle, onIonModalWillPresent: this.onLifecycle, onIonModalWillDismiss: this.onLifecycle, onIonModalDidDismiss: this.onLifecycle, onFocus: this.onModalFocus }), h("ion-backdrop", { key: '90a6605a9564a699d6f66cf71cf6b506796a2963', ref: (el) => (this.backdropEl = el), visible: this.showBackdrop, tappable: this.backdropDismiss, part: "backdrop" }), mode === 'ios' && h("div", { key: 'a97d071395333bf803c0a9347bda000cf7500d8d', class: "modal-shadow" }), h("div", Object.assign({ key: 'e7b7985c7414a13e3ba8dcecf497b76e92edf53e',
2158
+ }, class: Object.assign({ [mode]: true, ['modal-default']: !isCardModal && !isSheetModal, [`modal-card`]: isCardModal, [`modal-sheet`]: isSheetModal, [`modal-no-expand-scroll`]: isSheetModal && !expandToScroll, 'overlay-hidden': true, [FOCUS_TRAP_DISABLE_CLASS]: focusTrap === false }, getClassMap(this.cssClass)), onIonBackdropTap: this.onBackdropTap, onIonModalDidPresent: this.onLifecycle, onIonModalWillPresent: this.onLifecycle, onIonModalWillDismiss: this.onLifecycle, onIonModalDidDismiss: this.onLifecycle, onFocus: this.onModalFocus }), h("ion-backdrop", { key: '78b954a1c50a0325eb51db04314e86701c66d840', ref: (el) => (this.backdropEl = el), visible: this.showBackdrop, tappable: this.backdropDismiss, part: "backdrop" }), mode === 'ios' && h("div", { key: '21887227c272f5eba1b3d164be3572bd710d415c', class: "modal-shadow" }), h("div", Object.assign({ key: 'a40472a9065c04ad12fb7b2b2a05e5021f077ad5',
1975
2159
  /*
1976
2160
  role and aria-modal must be used on the
1977
2161
  same element. They must also be set inside the
1978
2162
  shadow DOM otherwise ion-button will not be highlighted
1979
2163
  when using VoiceOver: https://bugs.webkit.org/show_bug.cgi?id=247134
1980
2164
  */
1981
- role: "dialog" }, inheritedAttributes, { "aria-modal": "true", class: "modal-wrapper ion-overlay-wrapper", part: "content", ref: (el) => (this.wrapperEl = el) }), showHandle && (h("button", { key: '8258b65570b11a8ee9c9df2537d6419cd2e34536', class: "modal-handle",
2165
+ role: "dialog" }, inheritedAttributes, { "aria-modal": "true", class: "modal-wrapper ion-overlay-wrapper", part: "content", ref: (el) => (this.wrapperEl = el) }), showHandle && (h("button", { key: 'a4973f66587546031d1cc0197e1ba7c2521a3fbc', class: "modal-handle",
1982
2166
  // Prevents the handle from receiving keyboard focus when it does not cycle
1983
- tabIndex: !isHandleCycle ? -1 : 0, "aria-label": "Activate to adjust the size of the dialog overlaying the screen", onClick: isHandleCycle ? this.onHandleClick : undefined, part: "handle", ref: (el) => (this.dragHandleEl = el) })), h("slot", { key: '394370d0ed03ee03152f8f8abae7ff7664ca5c13' }))));
2167
+ tabIndex: !isHandleCycle ? -1 : 0, "aria-label": "Activate to adjust the size of the dialog overlaying the screen", onClick: isHandleCycle ? this.onHandleClick : undefined, part: "handle", ref: (el) => (this.dragHandleEl = el) })), h("slot", { key: 'ee5e007e3a4e592d98f1b5a5d31ad55e6faa3bdb' }))));
1984
2168
  }
1985
2169
  get el() { return this; }
1986
2170
  static get watchers() { return {
@@ -589,7 +589,7 @@ const iosEnterAnimation = (baseEl, opts) => {
589
589
  baseAnimation.addAnimation(contentAnimation);
590
590
  }
591
591
  if (presentingEl) {
592
- const isMobile = window.innerWidth < 768;
592
+ const isPortrait = window.innerWidth < 768;
593
593
  const hasCardModal = presentingEl.tagName === 'ION-MODAL' && presentingEl.presentingElement !== undefined;
594
594
  const presentingElRoot = helpers.getElementRoot(presentingEl);
595
595
  const presentingAnimation = animation.createAnimation().beforeStyles({
@@ -598,7 +598,7 @@ const iosEnterAnimation = (baseEl, opts) => {
598
598
  overflow: 'hidden',
599
599
  });
600
600
  const bodyEl = document.body;
601
- if (isMobile) {
601
+ if (isPortrait) {
602
602
  /**
603
603
  * Fallback for browsers that does not support `max()` (ex: Firefox)
604
604
  * No need to worry about statusbar padding since engines like Gecko
@@ -676,7 +676,7 @@ const iosLeaveAnimation = (baseEl, opts, duration = 500) => {
676
676
  .duration(duration)
677
677
  .addAnimation(wrapperAnimation);
678
678
  if (presentingEl) {
679
- const isMobile = window.innerWidth < 768;
679
+ const isPortrait = window.innerWidth < 768;
680
680
  const hasCardModal = presentingEl.tagName === 'ION-MODAL' && presentingEl.presentingElement !== undefined;
681
681
  const presentingElRoot = helpers.getElementRoot(presentingEl);
682
682
  const presentingAnimation = animation.createAnimation()
@@ -694,7 +694,7 @@ const iosLeaveAnimation = (baseEl, opts, duration = 500) => {
694
694
  }
695
695
  });
696
696
  const bodyEl = document.body;
697
- if (isMobile) {
697
+ if (isPortrait) {
698
698
  const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
699
699
  const modalTransform = hasCardModal ? '-10px' : transformOffset;
700
700
  const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;
@@ -741,6 +741,125 @@ const iosLeaveAnimation = (baseEl, opts, duration = 500) => {
741
741
  return baseAnimation;
742
742
  };
743
743
 
744
+ /**
745
+ * Transition animation from portrait view to landscape view
746
+ * This handles the case where a card modal is open in portrait view
747
+ * and the user switches to landscape view
748
+ */
749
+ const portraitToLandscapeTransition = (baseEl, opts, duration = 300) => {
750
+ const { presentingEl } = opts;
751
+ if (!presentingEl) {
752
+ // No transition needed for non-card modals
753
+ return animation.createAnimation('portrait-to-landscape-transition');
754
+ }
755
+ const hasCardModal = presentingEl.tagName === 'ION-MODAL' && presentingEl.presentingElement !== undefined;
756
+ const presentingElRoot = helpers.getElementRoot(presentingEl);
757
+ const bodyEl = document.body;
758
+ const baseAnimation = animation.createAnimation('portrait-to-landscape-transition')
759
+ .addElement(baseEl)
760
+ .easing('cubic-bezier(0.32,0.72,0,1)')
761
+ .duration(duration);
762
+ const presentingAnimation = animation.createAnimation();
763
+ if (!hasCardModal) {
764
+ // Non-card modal: transition from portrait state to landscape state
765
+ // Portrait: presentingEl has transform and body has black background
766
+ // Landscape: no transform, no body background, modal wrapper opacity changes
767
+ const root = helpers.getElementRoot(baseEl);
768
+ const wrapperAnimation = animation.createAnimation()
769
+ .addElement(root.querySelectorAll('.modal-wrapper, .modal-shadow'))
770
+ .fromTo('opacity', '1', '1'); // Keep wrapper visible in landscape
771
+ const backdropAnimation = animation.createAnimation()
772
+ .addElement(root.querySelector('ion-backdrop'))
773
+ .fromTo('opacity', 'var(--backdrop-opacity)', 'var(--backdrop-opacity)'); // Keep backdrop visible
774
+ // Animate presentingEl from portrait state back to normal
775
+ const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
776
+ const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;
777
+ const fromTransform = `translateY(${transformOffset}) scale(${toPresentingScale})`;
778
+ presentingAnimation
779
+ .addElement(presentingEl)
780
+ .beforeAddWrite(() => bodyEl.style.setProperty('background-color', ''))
781
+ .fromTo('transform', fromTransform, 'translateY(0px) scale(1)')
782
+ .fromTo('filter', 'contrast(0.85)', 'contrast(1)')
783
+ .fromTo('border-radius', '10px 10px 0 0', '0px');
784
+ baseAnimation.addAnimation([presentingAnimation, wrapperAnimation, backdropAnimation]);
785
+ }
786
+ else {
787
+ // Card modal: transition from portrait card state to landscape card state
788
+ const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;
789
+ const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
790
+ const fromTransform = `translateY(${transformOffset}) scale(${toPresentingScale})`;
791
+ const toTransform = `translateY(-10px) scale(${toPresentingScale})`;
792
+ presentingAnimation
793
+ .addElement(presentingElRoot.querySelector('.modal-wrapper'))
794
+ .fromTo('transform', fromTransform, toTransform)
795
+ .fromTo('filter', 'contrast(0.85)', 'contrast(0.85)'); // Keep same contrast for card
796
+ const shadowAnimation = animation.createAnimation()
797
+ .addElement(presentingElRoot.querySelector('.modal-shadow'))
798
+ .fromTo('opacity', '0', '0') // Shadow stays hidden in landscape for card modals
799
+ .fromTo('transform', fromTransform, toTransform);
800
+ baseAnimation.addAnimation([presentingAnimation, shadowAnimation]);
801
+ }
802
+ return baseAnimation;
803
+ };
804
+ /**
805
+ * Transition animation from landscape view to portrait view
806
+ * This handles the case where a card modal is open in landscape view
807
+ * and the user switches to portrait view
808
+ */
809
+ const landscapeToPortraitTransition = (baseEl, opts, duration = 300) => {
810
+ const { presentingEl } = opts;
811
+ if (!presentingEl) {
812
+ // No transition needed for non-card modals
813
+ return animation.createAnimation('landscape-to-portrait-transition');
814
+ }
815
+ const hasCardModal = presentingEl.tagName === 'ION-MODAL' && presentingEl.presentingElement !== undefined;
816
+ const presentingElRoot = helpers.getElementRoot(presentingEl);
817
+ const bodyEl = document.body;
818
+ const baseAnimation = animation.createAnimation('landscape-to-portrait-transition')
819
+ .addElement(baseEl)
820
+ .easing('cubic-bezier(0.32,0.72,0,1)')
821
+ .duration(duration);
822
+ const presentingAnimation = animation.createAnimation();
823
+ if (!hasCardModal) {
824
+ // Non-card modal: transition from landscape state to portrait state
825
+ const root = helpers.getElementRoot(baseEl);
826
+ const wrapperAnimation = animation.createAnimation()
827
+ .addElement(root.querySelectorAll('.modal-wrapper, .modal-shadow'))
828
+ .fromTo('opacity', '1', '1'); // Keep wrapper visible
829
+ const backdropAnimation = animation.createAnimation()
830
+ .addElement(root.querySelector('ion-backdrop'))
831
+ .fromTo('opacity', 'var(--backdrop-opacity)', 'var(--backdrop-opacity)'); // Keep backdrop visible
832
+ // Animate presentingEl from normal state to portrait state
833
+ const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
834
+ const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;
835
+ const toTransform = `translateY(${transformOffset}) scale(${toPresentingScale})`;
836
+ presentingAnimation
837
+ .addElement(presentingEl)
838
+ .beforeAddWrite(() => bodyEl.style.setProperty('background-color', 'black'))
839
+ .fromTo('transform', 'translateY(0px) scale(1)', toTransform)
840
+ .fromTo('filter', 'contrast(1)', 'contrast(0.85)')
841
+ .fromTo('border-radius', '0px', '10px 10px 0 0');
842
+ baseAnimation.addAnimation([presentingAnimation, wrapperAnimation, backdropAnimation]);
843
+ }
844
+ else {
845
+ // Card modal: transition from landscape card state to portrait card state
846
+ const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;
847
+ const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
848
+ const fromTransform = `translateY(-10px) scale(${toPresentingScale})`;
849
+ const toTransform = `translateY(${transformOffset}) scale(${toPresentingScale})`;
850
+ presentingAnimation
851
+ .addElement(presentingElRoot.querySelector('.modal-wrapper'))
852
+ .fromTo('transform', fromTransform, toTransform)
853
+ .fromTo('filter', 'contrast(0.85)', 'contrast(0.85)'); // Keep same contrast for card
854
+ const shadowAnimation = animation.createAnimation()
855
+ .addElement(presentingElRoot.querySelector('.modal-shadow'))
856
+ .fromTo('opacity', '0', '0') // Shadow stays hidden
857
+ .fromTo('transform', fromTransform, toTransform);
858
+ baseAnimation.addAnimation([presentingAnimation, shadowAnimation]);
859
+ }
860
+ return baseAnimation;
861
+ };
862
+
744
863
  const createEnterAnimation = () => {
745
864
  const backdropAnimation = animation.createAnimation()
746
865
  .fromTo('opacity', 0.01, 'var(--backdrop-opacity)')
@@ -1522,6 +1641,7 @@ const Modal = class {
1522
1641
  }
1523
1642
  disconnectedCallback() {
1524
1643
  this.triggerController.removeClickListener();
1644
+ this.cleanupViewTransitionListener();
1525
1645
  }
1526
1646
  componentWillLoad() {
1527
1647
  var _a;
@@ -1732,6 +1852,8 @@ const Modal = class {
1732
1852
  else if (hasCardModal) {
1733
1853
  this.initSwipeToClose();
1734
1854
  }
1855
+ // Initialize view transition listener for iOS card modals
1856
+ this.initViewTransitionListener();
1735
1857
  unlock();
1736
1858
  }
1737
1859
  initSwipeToClose() {
@@ -1885,6 +2007,7 @@ const Modal = class {
1885
2007
  if (this.gesture) {
1886
2008
  this.gesture.destroy();
1887
2009
  }
2010
+ this.cleanupViewTransitionListener();
1888
2011
  }
1889
2012
  this.currentBreakpoint = undefined;
1890
2013
  this.animation = undefined;
@@ -1960,6 +2083,67 @@ const Modal = class {
1960
2083
  await this.setCurrentBreakpoint(nextBreakpoint);
1961
2084
  return true;
1962
2085
  }
2086
+ initViewTransitionListener() {
2087
+ // Only enable for iOS card modals when no custom animations are provided
2088
+ if (index$3.getIonMode(this) !== 'ios' || !this.presentingElement || this.enterAnimation || this.leaveAnimation) {
2089
+ return;
2090
+ }
2091
+ // Set initial view state
2092
+ this.currentViewIsPortrait = window.innerWidth < 768;
2093
+ // Create debounced resize handler
2094
+ let resizeTimeout;
2095
+ this.resizeListener = () => {
2096
+ clearTimeout(resizeTimeout);
2097
+ resizeTimeout = setTimeout(() => {
2098
+ this.handleViewTransition();
2099
+ }, 100); // Debounce for 100ms to avoid excessive calls
2100
+ };
2101
+ window.addEventListener('resize', this.resizeListener);
2102
+ }
2103
+ handleViewTransition() {
2104
+ const isPortrait = window.innerWidth < 768;
2105
+ // Only transition if view state actually changed
2106
+ if (this.currentViewIsPortrait === isPortrait) {
2107
+ return;
2108
+ }
2109
+ // Cancel any ongoing transition animation
2110
+ if (this.viewTransitionAnimation) {
2111
+ this.viewTransitionAnimation.destroy();
2112
+ this.viewTransitionAnimation = undefined;
2113
+ }
2114
+ const { presentingElement } = this;
2115
+ if (!presentingElement) {
2116
+ return;
2117
+ }
2118
+ // Create transition animation
2119
+ let transitionAnimation;
2120
+ if (this.currentViewIsPortrait && !isPortrait) {
2121
+ // Portrait to landscape transition
2122
+ transitionAnimation = portraitToLandscapeTransition(this.el, {
2123
+ presentingEl: presentingElement});
2124
+ }
2125
+ else {
2126
+ // Landscape to portrait transition
2127
+ transitionAnimation = landscapeToPortraitTransition(this.el, {
2128
+ presentingEl: presentingElement});
2129
+ }
2130
+ // Update state and play animation
2131
+ this.currentViewIsPortrait = isPortrait;
2132
+ this.viewTransitionAnimation = transitionAnimation;
2133
+ transitionAnimation.play().then(() => {
2134
+ this.viewTransitionAnimation = undefined;
2135
+ });
2136
+ }
2137
+ cleanupViewTransitionListener() {
2138
+ if (this.resizeListener) {
2139
+ window.removeEventListener('resize', this.resizeListener);
2140
+ this.resizeListener = undefined;
2141
+ }
2142
+ if (this.viewTransitionAnimation) {
2143
+ this.viewTransitionAnimation.destroy();
2144
+ this.viewTransitionAnimation = undefined;
2145
+ }
2146
+ }
1963
2147
  render() {
1964
2148
  const { handle, isSheetModal, presentingElement, htmlAttributes, handleBehavior, inheritedAttributes, focusTrap, expandToScroll, } = this;
1965
2149
  const showHandle = handle !== false && isSheetModal;
@@ -1967,20 +2151,20 @@ const Modal = class {
1967
2151
  const isCardModal = presentingElement !== undefined && mode === 'ios';
1968
2152
  const isHandleCycle = handleBehavior === 'cycle';
1969
2153
  const isSheetModalWithHandle = isSheetModal && showHandle;
1970
- return (index$3.h(index$3.Host, Object.assign({ key: '8add05bb43a2cdb5e3cf180147d31eb85a018fe0', "no-router": true,
2154
+ return (index$3.h(index$3.Host, Object.assign({ key: 'd5bcaa588471573e1bcbd99997b306c8ecdd124f', "no-router": true,
1971
2155
  // Allow the modal to be navigable when the handle is focusable
1972
2156
  tabIndex: isHandleCycle && isSheetModalWithHandle ? 0 : -1 }, htmlAttributes, { style: {
1973
2157
  zIndex: `${20000 + this.overlayIndex}`,
1974
- }, class: Object.assign({ [mode]: true, ['modal-default']: !isCardModal && !isSheetModal, [`modal-card`]: isCardModal, [`modal-sheet`]: isSheetModal, [`modal-no-expand-scroll`]: isSheetModal && !expandToScroll, 'overlay-hidden': true, [overlays.FOCUS_TRAP_DISABLE_CLASS]: focusTrap === false }, theme.getClassMap(this.cssClass)), onIonBackdropTap: this.onBackdropTap, onIonModalDidPresent: this.onLifecycle, onIonModalWillPresent: this.onLifecycle, onIonModalWillDismiss: this.onLifecycle, onIonModalDidDismiss: this.onLifecycle, onFocus: this.onModalFocus }), index$3.h("ion-backdrop", { key: '90a6605a9564a699d6f66cf71cf6b506796a2963', ref: (el) => (this.backdropEl = el), visible: this.showBackdrop, tappable: this.backdropDismiss, part: "backdrop" }), mode === 'ios' && index$3.h("div", { key: 'a97d071395333bf803c0a9347bda000cf7500d8d', class: "modal-shadow" }), index$3.h("div", Object.assign({ key: 'e7b7985c7414a13e3ba8dcecf497b76e92edf53e',
2158
+ }, class: Object.assign({ [mode]: true, ['modal-default']: !isCardModal && !isSheetModal, [`modal-card`]: isCardModal, [`modal-sheet`]: isSheetModal, [`modal-no-expand-scroll`]: isSheetModal && !expandToScroll, 'overlay-hidden': true, [overlays.FOCUS_TRAP_DISABLE_CLASS]: focusTrap === false }, theme.getClassMap(this.cssClass)), onIonBackdropTap: this.onBackdropTap, onIonModalDidPresent: this.onLifecycle, onIonModalWillPresent: this.onLifecycle, onIonModalWillDismiss: this.onLifecycle, onIonModalDidDismiss: this.onLifecycle, onFocus: this.onModalFocus }), index$3.h("ion-backdrop", { key: '78b954a1c50a0325eb51db04314e86701c66d840', ref: (el) => (this.backdropEl = el), visible: this.showBackdrop, tappable: this.backdropDismiss, part: "backdrop" }), mode === 'ios' && index$3.h("div", { key: '21887227c272f5eba1b3d164be3572bd710d415c', class: "modal-shadow" }), index$3.h("div", Object.assign({ key: 'a40472a9065c04ad12fb7b2b2a05e5021f077ad5',
1975
2159
  /*
1976
2160
  role and aria-modal must be used on the
1977
2161
  same element. They must also be set inside the
1978
2162
  shadow DOM otherwise ion-button will not be highlighted
1979
2163
  when using VoiceOver: https://bugs.webkit.org/show_bug.cgi?id=247134
1980
2164
  */
1981
- role: "dialog" }, inheritedAttributes, { "aria-modal": "true", class: "modal-wrapper ion-overlay-wrapper", part: "content", ref: (el) => (this.wrapperEl = el) }), showHandle && (index$3.h("button", { key: '8258b65570b11a8ee9c9df2537d6419cd2e34536', class: "modal-handle",
2165
+ role: "dialog" }, inheritedAttributes, { "aria-modal": "true", class: "modal-wrapper ion-overlay-wrapper", part: "content", ref: (el) => (this.wrapperEl = el) }), showHandle && (index$3.h("button", { key: 'a4973f66587546031d1cc0197e1ba7c2521a3fbc', class: "modal-handle",
1982
2166
  // Prevents the handle from receiving keyboard focus when it does not cycle
1983
- tabIndex: !isHandleCycle ? -1 : 0, "aria-label": "Activate to adjust the size of the dialog overlaying the screen", onClick: isHandleCycle ? this.onHandleClick : undefined, part: "handle", ref: (el) => (this.dragHandleEl = el) })), index$3.h("slot", { key: '394370d0ed03ee03152f8f8abae7ff7664ca5c13' }))));
2167
+ tabIndex: !isHandleCycle ? -1 : 0, "aria-label": "Activate to adjust the size of the dialog overlaying the screen", onClick: isHandleCycle ? this.onHandleClick : undefined, part: "handle", ref: (el) => (this.dragHandleEl = el) })), index$3.h("slot", { key: 'ee5e007e3a4e592d98f1b5a5d31ad55e6faa3bdb' }))));
1984
2168
  }
1985
2169
  get el() { return index$3.getElement(this); }
1986
2170
  static get watchers() { return {
@@ -36,7 +36,7 @@ export const iosEnterAnimation = (baseEl, opts) => {
36
36
  baseAnimation.addAnimation(contentAnimation);
37
37
  }
38
38
  if (presentingEl) {
39
- const isMobile = window.innerWidth < 768;
39
+ const isPortrait = window.innerWidth < 768;
40
40
  const hasCardModal = presentingEl.tagName === 'ION-MODAL' && presentingEl.presentingElement !== undefined;
41
41
  const presentingElRoot = getElementRoot(presentingEl);
42
42
  const presentingAnimation = createAnimation().beforeStyles({
@@ -45,7 +45,7 @@ export const iosEnterAnimation = (baseEl, opts) => {
45
45
  overflow: 'hidden',
46
46
  });
47
47
  const bodyEl = document.body;
48
- if (isMobile) {
48
+ if (isPortrait) {
49
49
  /**
50
50
  * Fallback for browsers that does not support `max()` (ex: Firefox)
51
51
  * No need to worry about statusbar padding since engines like Gecko
@@ -25,7 +25,7 @@ export const iosLeaveAnimation = (baseEl, opts, duration = 500) => {
25
25
  .duration(duration)
26
26
  .addAnimation(wrapperAnimation);
27
27
  if (presentingEl) {
28
- const isMobile = window.innerWidth < 768;
28
+ const isPortrait = window.innerWidth < 768;
29
29
  const hasCardModal = presentingEl.tagName === 'ION-MODAL' && presentingEl.presentingElement !== undefined;
30
30
  const presentingElRoot = getElementRoot(presentingEl);
31
31
  const presentingAnimation = createAnimation()
@@ -43,7 +43,7 @@ export const iosLeaveAnimation = (baseEl, opts, duration = 500) => {
43
43
  }
44
44
  });
45
45
  const bodyEl = document.body;
46
- if (isMobile) {
46
+ if (isPortrait) {
47
47
  const transformOffset = !CSS.supports('width', 'max(0px, 1px)') ? '30px' : 'max(30px, var(--ion-safe-area-top))';
48
48
  const modalTransform = hasCardModal ? '-10px' : transformOffset;
49
49
  const toPresentingScale = SwipeToCloseDefaults.MIN_PRESENTING_SCALE;