diff options
author | Brian Kim <brian@tagg.id> | 2021-07-08 17:22:56 -0400 |
---|---|---|
committer | Brian Kim <brian@tagg.id> | 2021-07-08 17:22:56 -0400 |
commit | e62ba8ca223d92f662016445264030d28009288f (patch) | |
tree | 5df5b5e63e0d61f8de15ec16000cad52bacb8ba9 /src/screens/moments/TagFriendsScreen.tsx | |
parent | 8a7ce9dee2eb24f80d84831b1d596f28a0d5c07a (diff) |
Fixed boundaries
Diffstat (limited to 'src/screens/moments/TagFriendsScreen.tsx')
-rw-r--r-- | src/screens/moments/TagFriendsScreen.tsx | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/screens/moments/TagFriendsScreen.tsx b/src/screens/moments/TagFriendsScreen.tsx index 983b1be3..6c982936 100644 --- a/src/screens/moments/TagFriendsScreen.tsx +++ b/src/screens/moments/TagFriendsScreen.tsx @@ -38,6 +38,7 @@ const TagFriendsScreen: React.FC<TagFriendsScreenProps> = ({route}) => { const [imageWidth, setImageWidth] = useState<number>(0); const [imageHeight, setImageHeight] = useState<number>(0); const [bottomBound, setBottomBound] = useState<number>(0); + const [topHeight, setTopHeight] = useState<number>(0); const [topBound, setTopBound] = useState<number>(0); /* @@ -77,9 +78,10 @@ const TagFriendsScreen: React.FC<TagFriendsScreenProps> = ({route}) => { }; /* - * Calculate boundary (if any) for drag from bottom + * Calculate boundary (if any) for drag from bottom and top */ useEffect(() => { + // Bottom dead zone if (SCREEN_HEIGHT / 2 - imageHeight / 2 < SCREEN_HEIGHT * 0.15) { if (SCREEN_HEIGHT / 2 - imageHeight / 2 < 0) { setBottomBound(SCREEN_HEIGHT * 0.15); @@ -89,7 +91,16 @@ const TagFriendsScreen: React.FC<TagFriendsScreenProps> = ({route}) => { ); } } - }, [imageHeight, imageWidth]); + + // Top dead zone + if (SCREEN_HEIGHT / 2 - imageHeight / 2 < topHeight) { + if (SCREEN_HEIGHT / 2 - imageHeight / 2 < 0) { + setTopBound(topHeight + 15); + } else { + setTopBound(topHeight - (SCREEN_HEIGHT / 2 - imageHeight / 2) + 15); + } + } + }, [imageHeight, imageWidth, topHeight]); /* * Calculating image width and height with respect to it's enclosing view's dimensions. Only works for images. @@ -162,16 +173,7 @@ const TagFriendsScreen: React.FC<TagFriendsScreenProps> = ({route}) => { style={styles.titleContainer} onLayout={(event) => { const {y, height} = event.nativeEvent.layout; - const tempBound = y + height; - if (SCREEN_HEIGHT / 2 - imageHeight / 2 < tempBound) { - if (SCREEN_HEIGHT / 2 - imageHeight / 2 < 0) { - setTopBound(tempBound + 15); - } else { - setTopBound( - tempBound - (SCREEN_HEIGHT / 2 - imageHeight / 2) + 15, - ); - } - } + setTopHeight(y + height); }}> <TouchableOpacity onPress={() => { |