Skip to content

Commit

Permalink
Merge pull request #451 from softeerbootcamp-2nd/feat/360-refactor
Browse files Browse the repository at this point in the history
[REFACTOR] 360 이미지 리팩토링
  • Loading branch information
kimdaye77 authored Aug 24, 2023
2 parents 8c9819b + afb5bbf commit 38ca280
Showing 1 changed file with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,6 @@ export default function OuterColorBannerContainer() {
[selectedItem, isLoaded]
);

const displayCar360Components = useCallback(() => {
return car360UrlsData?.map((url, idx) => {
const imgSrc = imgBlobUrl[url];
return <CarImg key={idx} src={imgSrc} $visible={imgState.visibleIdx === idx} />;
});
}, [car360UrlsData, imgBlobUrl, imgState]);

useEffect(() => {
if (!car360UrlsData || loading) return;
const abortController = new AbortController();
Expand All @@ -112,6 +105,8 @@ export default function OuterColorBannerContainer() {
};
}, [downloadAndSaveImages, car360UrlsData, loading]);

const imgSrc = car360UrlsData ? imgBlobUrl[car360UrlsData[imgState.visibleIdx]] : '';

return (
<>
<OuterColorBanner
Expand All @@ -124,7 +119,7 @@ export default function OuterColorBannerContainer() {
<CarShadow>
<DegreeCaption>360°</DegreeCaption>
</CarShadow>
{imgState.imgLoading ? <Loading /> : displayCar360Components()}
{imgState.imgLoading || !car360UrlsData ? <Loading /> : <CarImg src={imgSrc} />}
</ImgWrapper>
</FlexCenterWrapper>
</OuterColorBanner>
Expand All @@ -135,8 +130,7 @@ export default function OuterColorBannerContainer() {
const OuterColorBanner = styled(Banner)`
background: ${({ theme }) => theme.color.blueBg};
`;
const CarImg = styled.img<{ $visible: boolean }>`
display: ${({ $visible }) => ($visible ? 'block' : 'none')};
const CarImg = styled.img`
position: absolute;
right: 0;
width: 592px;
Expand Down

0 comments on commit 38ca280

Please sign in to comment.