Skip to content

Commit

Permalink
fix onclose functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
kea-roy committed Nov 6, 2024
1 parent 5cbde28 commit f265bcb
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions frontend/src/components/PhotoCarousel/PhotoCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ const useStyles = makeStyles((theme) => ({
justifyContent: 'center',
flexDirection: 'column',
overflow: 'visible',
height: '90dvh',
[theme.breakpoints.down('lg')]: {
height: '80vh',
[theme.breakpoints.down('md')]: {
height: '60dvw',
},
cursor: 'pointer',
},
}));
const ImageBox = styled(Box)({
Expand All @@ -47,6 +48,7 @@ const ImageBox = styled(Box)({
objectFit: 'contain',
width: 'calc(69dvw - 96px)',
margin: 'auto',
cursor: 'default',
},
});

Expand All @@ -73,20 +75,35 @@ const PhotoCarousel = ({ photos, open, onClose, startIndex }: Props) => {
onClose={onClose}
fullWidth
maxWidth={false}
style={{ cursor: 'pointer' }}
PaperProps={{ className: modalBackground }}
>
<Container>
<Container
onClick={(e) => {
const target = e.target as HTMLElement;
if (
target.tagName !== 'IMG' &&
target.tagName !== 'BUTTON' &&
target.tagName !== 'svg' &&
target.tagName !== 'circle'
) {
console.log(target.tagName);
onClose?.();
}
}}
>
<Carousel
autoPlay={false}
className={carouselContainer}
navButtonsAlwaysVisible={true}
navButtonsProps={{ className: navButton }}
indicatorContainerProps={{ className: indicatorContainer }}
index={startIndex}
animation="fade"
>
{photos.map((src, index) => {
return (
<ImageBox key={index}>
<ImageBox key={index} style={{ backgroundColor: 'rgba(0, 0, 0, 0.05)' }}>
<CardMedia component="img" src={src} />
</ImageBox>
);
Expand Down

0 comments on commit f265bcb

Please sign in to comment.