-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from softeerbootcamp4th/feat/216
[Fix] 이미지 캐러셀 오류 수정
- Loading branch information
Showing
5 changed files
with
73 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useState, useEffect, RefObject } from 'react'; | ||
|
||
const useVideoMetadata = (videoRef: RefObject<HTMLVideoElement>) => { | ||
const [duration, setDuration] = useState(0); | ||
|
||
useEffect(() => { | ||
if (videoRef.current) { | ||
const handleLoadedMetadata = () => { | ||
setDuration(videoRef.current!.duration); | ||
}; | ||
|
||
const videoElement = videoRef.current; | ||
videoElement.addEventListener('loadedmetadata', handleLoadedMetadata); | ||
|
||
return () => { | ||
videoElement.removeEventListener( | ||
'loadedmetadata', | ||
handleLoadedMetadata | ||
); | ||
}; | ||
} | ||
}, [videoRef]); | ||
|
||
return duration; | ||
}; | ||
|
||
export default useVideoMetadata; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const getTransformClass = (id: number) => { | ||
switch (id) { | ||
case 1: | ||
return 'translate-x-custom-1'; | ||
case 2: | ||
return 'translate-x-custom-2'; | ||
case 3: | ||
return ''; | ||
case 4: | ||
return 'translate-x-custom-4'; | ||
case 5: | ||
return 'translate-x-custom-5'; | ||
default: | ||
return ''; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { CarInfoList } from '@/types/main/type'; | ||
|
||
export const getVisibleItems = ( | ||
currentIndex: number, | ||
carInfoList: CarInfoList[] | ||
): CarInfoList[] => { | ||
switch (currentIndex) { | ||
case 0: | ||
return [carInfoList[0], carInfoList[1], carInfoList[2]]; | ||
case 1: | ||
return [carInfoList[0], carInfoList[1], carInfoList[2], carInfoList[3]]; | ||
case 2: | ||
return carInfoList; | ||
case 3: | ||
return [carInfoList[1], carInfoList[2], carInfoList[3], carInfoList[4]]; | ||
case 4: | ||
return [carInfoList[2], carInfoList[3], carInfoList[4]]; | ||
default: | ||
return carInfoList; | ||
} | ||
}; |