-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/#479 킬링파트 등록 시 구간 선택을 토글 형식으로 변경 #482
Changes from 1 commit
a7c7a78
5cda5c3
35843b1
a45c321
a1e960e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import type { PropsWithChildren } from 'react'; | |
|
||
interface VoteInterfaceContextProps extends VoteInterfaceProviderProps { | ||
partStartTime: number; | ||
interval: KillingPartInterval; | ||
interval: KillingPartInterval | null; | ||
// NOTE: Why both setState and eventHandler have same naming convention? | ||
updatePartStartTime: (timeUnit: string, value: number) => void; | ||
updateKillingPartInterval: React.MouseEventHandler<HTMLButtonElement>; | ||
|
@@ -25,12 +25,17 @@ export const VoteInterfaceProvider = ({ | |
songId, | ||
songVideoId, | ||
}: PropsWithChildren<VoteInterfaceProviderProps>) => { | ||
const [interval, setInterval] = useState<KillingPartInterval>(10); | ||
const [interval, setInterval] = useState<KillingPartInterval | null>(10); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const [partStartTime, setPartStartTime] = useState(0); | ||
const { videoPlayer } = useVideoPlayerContext(); | ||
|
||
const updateKillingPartInterval: React.MouseEventHandler<HTMLButtonElement> = (e) => { | ||
const newInterval = Number(e.currentTarget.dataset['interval']) as KillingPartInterval; | ||
if (newInterval === interval) { | ||
setInterval(null); | ||
return; | ||
} | ||
|
||
const partEndTime = partStartTime + newInterval; | ||
|
||
if (partEndTime > videoLength) { | ||
|
@@ -62,6 +67,7 @@ export const VoteInterfaceProvider = ({ | |
}; | ||
|
||
useEffect(() => { | ||
if (!interval) return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💬 개행좀 부탁드려도 될까요?😭 |
||
const timer = window.setInterval(() => { | ||
videoPlayer.current?.seekTo(partStartTime, true); | ||
}, interval * 1000); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,12 @@ const VideoSlider = () => { | |
const { interval, partStartTime, videoLength, updatePartStartTime } = useVoteInterfaceContext(); | ||
const { videoPlayer } = useVideoPlayerContext(); | ||
|
||
const partEndTime = partStartTime + interval; | ||
const partStartTimeText = toMinSecText(partStartTime); | ||
const partEndTimeText = toMinSecText(partEndTime); | ||
const partStartTimeText = interval ? toMinSecText(partStartTime) : toMinSecText(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
const partEndTimeText = interval | ||
? toMinSecText(partStartTime + interval) | ||
: toMinSecText(videoLength); | ||
|
||
const maxPlayingTime = interval ? videoLength - interval : videoLength; | ||
|
||
const changeTime: ChangeEventHandler<HTMLInputElement> = ({ | ||
currentTarget: { valueAsNumber: currentSelectedTime }, | ||
|
@@ -40,7 +43,7 @@ const VideoSlider = () => { | |
onTouchEnd={seekToTime} | ||
onMouseUp={seekToTime} | ||
min={0} | ||
max={videoLength - interval} | ||
max={maxPlayingTime} | ||
step={1} | ||
interval={interval} | ||
/> | ||
|
@@ -86,7 +89,7 @@ export const PartEndTime = styled.span` | |
font-weight: 700; | ||
`; | ||
|
||
const Slider = styled.input<{ interval: number }>` | ||
const Slider = styled.input<{ interval: number | null }>` | ||
cursor: pointer; | ||
|
||
width: 100%; | ||
|
@@ -99,7 +102,7 @@ const Slider = styled.input<{ interval: number }>` | |
position: relative; | ||
top: -4px; | ||
|
||
width: ${({ interval }) => interval * 6}px; | ||
width: ${({ interval }) => (interval ? interval * 6 : 6)}px; | ||
height: 16px; | ||
|
||
-webkit-appearance: none; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 개행좀 부탁드려도 될까요?😭 22