Skip to content

Commit a6bc27d

Browse files
authored
DialogDismissibleView - fix bug with delayed insets (#1209)
1 parent 778fdbe commit a6bc27d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/components/dialog/DialogDismissibleView.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ interface LocationProps {
5555
}
5656

5757
const DEFAULT_DIRECTION = PanningProvider.Directions.DOWN;
58-
const TOP_INSET = Constants.isIphoneX ? Constants.getSafeAreaInsets().top : Constants.isIOS ? 20 : 0;
59-
const BOTTOM_INSET = Constants.isIphoneX ? Constants.getSafeAreaInsets().bottom : Constants.isIOS ? 20 : 0;
6058

6159
const DialogDismissibleView = (props: Props) => {
6260
const {direction = DEFAULT_DIRECTION, visible: propsVisible, containerStyle, style, children, onDismiss} = props;
@@ -65,6 +63,8 @@ const DialogDismissibleView = (props: Props) => {
6563

6664
const width = useRef<number>(Constants.screenWidth);
6765
const height = useRef<number>(Constants.screenHeight);
66+
const TOP_INSET = useRef<number>(Constants.isIphoneX ? Constants.getSafeAreaInsets().top : Constants.isIOS ? 20 : 0);
67+
const BOTTOM_INSET = useRef<number>(Constants.isIphoneX ? Constants.getSafeAreaInsets().bottom : Constants.isIOS ? 20 : 0);
6868
const thresholdX = useRef<number>(0);
6969
const thresholdY = useRef<number>(0);
7070
const dragsCounter = useRef<number>(0);
@@ -85,11 +85,11 @@ const DialogDismissibleView = (props: Props) => {
8585
result.left = Constants.screenWidth - left;
8686
break;
8787
case PanningProvider.Directions.UP:
88-
result.top = -top - height.current - TOP_INSET;
88+
result.top = -top - height.current - TOP_INSET.current;
8989
break;
9090
case PanningProvider.Directions.DOWN:
9191
default:
92-
result.top = Constants.screenHeight - top + BOTTOM_INSET;
92+
result.top = Constants.screenHeight - top + BOTTOM_INSET.current;
9393
break;
9494
}
9595

0 commit comments

Comments
 (0)