Skip to content

Commit

Permalink
more imageviewer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gkasdorf committed Aug 5, 2023
1 parent 3ea92f0 commit 80ea7e3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/components/common/ImageViewer/ImageViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ function ImageViewer({
const imageHeight = useSharedValue(0);
const imageWidth = useSharedValue(0);

const imageOpacity = useSharedValue(1);

const lastTap = useSharedValue(0);

const xCenter = useMemo(
Expand Down Expand Up @@ -244,6 +246,7 @@ function ImageViewer({

// Then we handle the fade
backgroundColor.value = withTiming("rgba(0, 0, 0, 1)", { duration: 200 });
imageOpacity.value = 0;

setExpanded(true);

Expand Down Expand Up @@ -283,6 +286,7 @@ function ImageViewer({

// Close the modal
setExpanded(false);
imageOpacity.value = 1;
}, 200);
}
};
Expand Down Expand Up @@ -498,6 +502,10 @@ function ImageViewer({
backgroundColor: backgroundColor.value,
}));

const imageStyle = useAnimatedStyle(() => ({
opacity: imageOpacity.value,
}));

// This handles our pinch to zoom styles
const scaleStyle = useAnimatedStyle(() => ({
transform: [{ scale: zoomScale.value }],
Expand Down Expand Up @@ -557,11 +565,10 @@ function ImageViewer({
onPress={onRequestOpenOrClose}
ref={nonViewerRef}
style={{
opacity: expanded ? 0 : 1,
borderRadius: compactMode ? 10 : 0,
}}
>
<View>
<Animated.View style={imageStyle}>
{(nsfw && blurNsfw && (
<View
style={[
Expand Down Expand Up @@ -625,7 +632,7 @@ function ImageViewer({
onLoad={onLoad}
/>
)}
</View>
</Animated.View>
</Pressable>
)}
<Modal
Expand Down

0 comments on commit 80ea7e3

Please sign in to comment.