fix(modal): sheet animation works correctly if breakpoints value does not include 1 (#23927)

This commit is contained in:
Liam DeBeasi
2021-09-14 15:27:59 -04:00
committed by GitHub
parent 497537ac73
commit 414f24685c
6 changed files with 14 additions and 12 deletions

View File

@ -6,7 +6,7 @@
* not begin to fade in until after
* the 0 breakpoint.
*/
export const getBackdropValueForSheet = (x: number, maxBreakpoint: number, backdropBreakpoint: number) => {
export const getBackdropValueForSheet = (x: number, backdropBreakpoint: number) => {
/**
* We will use these points:
@ -15,13 +15,17 @@ export const getBackdropValueForSheet = (x: number, maxBreakpoint: number, backd
* We know that at the beginning breakpoint,
* the backdrop will be hidden. We also
* know that at the maxBreakpoint, the backdrop
* must be fully visible.
* must be fully visible. maxBreakpoint should
* always be 1 even if the maximum value
* of the breakpoints array is not 1 since
* the animation runs from a progress of 0
* to a progress of 1.
* m = (y2 - y1) / (x2 - x1)
*
* This is simplified from:
* m = (1 - 0) / (maxBreakpoint - backdropBreakpoint)
*/
const slope = 1 / (maxBreakpoint - backdropBreakpoint);
const slope = 1 / (1 - backdropBreakpoint);
/**
* From here, compute b which is