Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(modal): backdrop animation when backdropBreakpoint is 1 #25430

Merged
merged 11 commits into from Jun 13, 2022
Merged

Conversation

sean-perkins
Copy link
Contributor

@sean-perkins sean-perkins commented Jun 8, 2022

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
    • Some docs updates need to be made in the ionic-docs repo, in a separate PR. See the contributing guide for details.
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

When the backdropBreakpoint on a sheet modal is 1, the calculation for the opacity keyframe animation will return an invalid result (NaN). This is due to the calculation evaluating to x * Infinity + -Infinity.

Issue URL: #25402

What is the new behavior?

  • Returns a backdrop value of 0 when the backdrop breakpoint is 1 (since the backdrop is invisible)
  • Backdrop animation does not flicker solid black when using backdropBreakpoint of 1 on a sheet modal and performing a dismiss swipe gesture

Does this introduce a breaking change?

  • Yes
  • No

Other information

Dev-build: 6.1.10-dev.11654886605.11e4eab6 馃煥

@sean-perkins sean-perkins requested a review from a team as a code owner June 8, 2022 15:52
@github-actions github-actions bot added the package: core @ionic/core package label Jun 8, 2022
Copy link
Contributor

@amandaejohnston amandaejohnston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes the animation to flicker with an off-center backdrop breakpoint, e.g. a modal with this config: { backdropBreakpoint: 0.3, initialBreakpoint: 0.3, breakpoints: [0.3, 0.5, 0.7, 1] } (You can see this with the "Backdrop breakpoint is off-center" button in the sheet test -- screencast.) If I log the slope for that config, it's about 1.4 without the Math.min applied.

@liamdebeasi
Copy link
Member

liamdebeasi commented Jun 9, 2022

Fixing this should be a matter of returning 0 early when backdropBreakpoint === 1.

When backdropBreakpoint is 1 you are dividing by zero here:

const slope = 1 / (1 - backdropBreakpoint);

This results in the bug reported in the issue thread.

@liamdebeasi
Copy link
Member

Alternatively, I think what Sean was trying to do was this:

const slope = 1 / (Math.min(1, 1 - backdropBreakpoint));

Might be worth trying that too.

@sean-perkins
Copy link
Contributor Author

Updated to check if the backdropBreakpoint is 1 and returning a value of 0 in that example. This resolves the flickering effect for the reported issue and maintains the expected transition behavior for the example values that Amanda provided.

I did experiment with the Math.min change, but that continued to produce irregular transitions of the backdrop with the values of Amanda's example.

New dev-build posted: 6.1.10-dev.11654886605.11e4eab6

Copy link
Contributor

@amandaejohnston amandaejohnston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me now 馃憤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants