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

Method present

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

Source from the content-addressed store, hash-verified

596 */
597 @Method()
598 async present(): Promise<void> {
599 const unlock = await this.lockController.lock();
600
601 if (this.presented) {
602 unlock();
603 return;
604 }
605
606 const { presentingElement, el } = this;
607
608 /**
609 * If the modal is presented multiple times (inline modals), we
610 * need to reset the current breakpoint to the initial breakpoint.
611 */
612 this.currentBreakpoint = this.initialBreakpoint;
613
614 const { inline, delegate } = this.getDelegate(true);
615
616 /**
617 * Emit ionMount so JS Frameworks have an opportunity
618 * to add the child component to the DOM. The child
619 * component will be assigned to this.usersElement below.
620 */
621 this.ionMount.emit();
622
623 this.usersElement = await attachComponent(delegate, el, this.component, ['ion-page'], this.componentProps, inline);
624
625 /**
626 * When using the lazy loaded build of Stencil, we need to wait
627 * for every Stencil component instance to be ready before presenting
628 * otherwise there can be a flash of unstyled content. With the
629 * custom elements bundle we need to wait for the JS framework
630 * mount the inner contents of the overlay otherwise WebKit may
631 * get the transition incorrect.
632 */
633 if (hasLazyBuild(el)) {
634 await deepReady(this.usersElement);
635 /**
636 * If keepContentsMounted="true" then the
637 * JS Framework has already mounted the inner
638 * contents so there is no need to wait.
639 * Otherwise, we need to wait for the JS
640 * Framework to mount the inner contents
641 * of this component.
642 */
643 } else if (!this.keepContentsMounted) {
644 await waitForMount();
645 }
646
647 writeTask(() => this.el.classList.add('show-modal'));
648
649 // Recalculate isSheetModal before safe-area setup because framework
650 // bindings (e.g., Angular) may not have been applied when componentWillLoad ran.
651 this.isSheetModal = this.breakpoints !== undefined && this.initialBreakpoint !== undefined;
652
653 // Set initial safe-area overrides before animation
654 this.setInitialSafeAreaOverrides();
655

Callers 2

onIsOpenChangeMethod · 0.95
componentDidLoadMethod · 0.95

Calls 15

getDelegateMethod · 0.95
initSheetGestureMethod · 0.95
initSwipeToCloseMethod · 0.95
attachComponentFunction · 0.90
hasLazyBuildFunction · 0.90
deepReadyFunction · 0.90
waitForMountFunction · 0.90

Tested by

no test coverage detected