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’ll 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
13 changes: 13 additions & 0 deletions core/src/components/modal/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getBackdropValueForSheet } from './utils';

describe('getBackdropValueForSheet()', () => {
it('should return a valid integer when backdropBreakpoint is 1', () => {
/**
* Issue: https://github.com/ionic-team/ionic-framework/issues/25402
*/
const backdropBreakpoint = 1;
expect(getBackdropValueForSheet(1, backdropBreakpoint)).toBe(0);
expect(getBackdropValueForSheet(5, backdropBreakpoint)).toBe(4);
expect(getBackdropValueForSheet(10, backdropBreakpoint)).toBe(9);
});
});
5 changes: 4 additions & 1 deletion core/src/components/modal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ export const getBackdropValueForSheet = (x: number, backdropBreakpoint: number)
*
* This is simplified from:
* m = (1 - 0) / (maxBreakpoint - backdropBreakpoint)
*
* We prevent the slope from being greater than 1, since with a backdropBreakpoint
* value of 1, the slope would evaluate to Infinity.
*/
const slope = 1 / (1 - backdropBreakpoint);
const slope = Math.min(1 / (1 - backdropBreakpoint), 1);

/**
* From here, compute b which is
Expand Down