1010 <ion-button id="open-modal" expand="block">Open Card Modal</ion-button>
1111
1212 <ion-modal
13- ref="modal"
1413 trigger="open-modal"
1514 :presenting-element="presentingElement"
1615 @willPresent="onWillPresent()"
@@ -39,30 +38,29 @@ import { ref, onMounted } from 'vue';
3938import { IonPage, IonModal, IonHeader, IonToolbar, IonTitle, IonContent, IonButton, IonLabel } from '@ionic/vue';
4039import type { ModalDragEventDetail } from '@ionic/vue';
4140
42- const modal = ref();
43- const page = ref<HTMLDivElement | null>(null);
44- const presentingElement = ref<HTMLElement | null>(null);
41+ const page = ref<InstanceType<typeof IonPage>>();
42+ const presentingElement = ref<HTMLElement>();
4543
4644const DARKEST_PERCENT = 50;
4745const BRIGHTNESS_RANGE = 100 - DARKEST_PERCENT;
4846
4947onMounted(() => {
50- presentingElement.value = page.value.$el;
48+ presentingElement.value = page.value! .$el;
5149});
5250
5351/**
5452 * Sync the background dimming with the modal's entry animation.
5553 */
5654const onWillPresent = () => {
57- const appEl = page.value.$el;
55+ const appEl = page.value! .$el;
5856
5957 appEl.style.transition = 'filter 0.4s ease';
6058 // Set to max darkness immediately
6159 appEl.style.setProperty('filter', `brightness(${DARKEST_PERCENT}%)`, 'important');
6260};
6361
6462const onDragStart = () => {
65- const appEl = page.value.$el;
63+ const appEl = page.value! .$el;
6664
6765 // Ensure transitions are off during the active drag
6866 appEl.style.transition = 'none';
@@ -72,7 +70,7 @@ const onDragMove = (event: CustomEvent<ModalDragEventDetail>) => {
7270 // `progress` is a value from 1 (top) to 0 (bottom)
7371 const { progress } = event.detail;
7472
75- const appEl = page.value.$el;
73+ const appEl = page.value! .$el;
7674 /**
7775 * Calculate the current brightness based on how far the user has
7876 * dragged.
@@ -90,7 +88,7 @@ const onDragEnd = (event: CustomEvent<ModalDragEventDetail>) => {
9088 // `progress` is a value from 1 (top) to 0 (bottom)
9189 const { progress } = event.detail;
9290
93- const appEl = page.value.$el;
91+ const appEl = page.value! .$el;
9492 /**
9593 * Snap the background brightness based on the user's drag intent.
9694 * Progress > 0.4 implies an intent to open (snap dark),
@@ -106,7 +104,7 @@ const onDragEnd = (event: CustomEvent<ModalDragEventDetail>) => {
106104};
107105
108106const onWillDismiss = () => {
109- const appEl = page.value.$el;
107+ const appEl = page.value! .$el;
110108
111109 // Clean up styles when the modal is dismissed
112110 appEl.style.removeProperty('filter');
0 commit comments