question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: [modal] enterAnimation causes modal not rendered properly

See original GitHub issue

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

when giving param enterAnimation, the component attached will not be rendered.

a simple animation builder for instance below:

enterAnimation(baseEl) {
    return createAnimation()
      .addElement(baseEl)
      .duration(250)
      .fromTo('opacity', '0', '1');
}

However, with a custom leaveAnimation but without modifying enterAnimation, the modal can be rendered normally.

Expected Behavior

Component should be rendered when giving custom animations.

Steps to Reproduce

  • use modal controller
  • giving a simple animation as above to param enterAnimation
  • present the modal
  • the modal shows but without content

Code Reproduction URL

No response

Ionic Info

No response

Additional Information

We are using Angular 13.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
tsungweihsucommented, Jan 5, 2022

@sean-perkins Thanks Sean, the additional configurations from your example solved the problem. I had initially also an animation for the modal wrapper, but it did not work. I played around with your configurations and found that without beforeStyles or .shadowRoot, it will not work, which did work with previous version Ionic 5. Perhaps Ionic 6 makes these two configurations mandatory for the modal component.

@forOneWhoHasThisIssue So to make it work, it needs:

  • an animation for the modal wrapper
  • an animation setting for the wrapper, e.g. .beforeStyles() or .keyframes()
  • .shadowRoot after baseEl

Thanks again, I’ll close the issue accordingly.

2reactions
sean-perkinscommented, Jan 5, 2022

Animating the modal element is more complicated than just a single animation. If we take inspiration from the existing animations that ship with Ionic, we can see that we need to additionally animate the modal wrapper.

For example:

private enterAnimation(baseEl) {
    const wrapperAnimation = createAnimation()
      .beforeStyles({
        transform: 'translateY(0) scale(1)'
      })
      .addElement(baseEl.shadowRoot.querySelector('.modal-wrapper'));

    return createAnimation()
      .addElement(baseEl)
      .duration(250)
      .fromTo('opacity', '0', '1')
      .addAnimation([wrapperAnimation]);
  }

<video src="https://user-images.githubusercontent.com/13732623/148156704-1f94e6c0-c2f8-474d-b5e0-67b1971f0d3e.mp4"></video>

Let me know if this resolves your issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom animation for bootstrap modal not working on closing ...
I find that a display:none property is added inline at the parent div on the time of closing the modal. Does it is...
Read more >
ion-modal: Ionic Mobile App Custom Modal API Component
ion-modal is a dialog that appears on top of mobile app content, and must be dismissed before interaction resumes. Learn more about custom...
Read more >
Create a Custom Modal Page Transition Animation in Ionic
In this tutorial, we walk through how to create a custom page transition animation for modals in Ionic.
Read more >
Modal - OutSystems 11 Documentation
Blank - The animation goes from a small size to its rendered size (Entities.EnterAnimation.EnterScale). This is the default. Entities.
Read more >
Modal Animations - CodePen
Most of the time these slide in or fade in - just playing with other instantiation animations. All animations are class-driven, and are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found