Conditionally disable / enable modal leave animation

I have a use case where I would like to disable & enable the modal leave animation (swipe to close) adhoc based on a condition.

For ex.

  • Open modal with enter animation
  • Condition hits so disable the leave animation (swipe to close)
  • Re-enable the leave animation
  • User can now swipe to close the modal

How can this be possible?

With the current API, the modal is told how to behave at creation time. So if you want to change that , you need to let the modal peek/poke into its internals or that of the modal controller to change that based on the condition. I dont think there is an out of the box API to support this, but it should be doable through some plain vanilla JS way. You would have to deep dive in the source code of the modal and the modal controller as published on github. Or even make your own custom version.

Besides the discussion whether this is desirable UI. (which also is the reason why there is no API, imho)