Skip to content

Commit 34bd2fb

Browse files
committed
Update CurrentTrack component for improved animation handling and styling
- Changed the progress bar container position to fixed and adjusted its height and width for better visual alignment. - Added a useEffect hook to log track changes when animations are enabled, enhancing debugging capabilities. - Moved the ProgressBar rendering to ensure it displays correctly during track transitions, improving user experience. - Implemented logic in CurrentTrackManager to handle track changes without animation when the player is stopped, streamlining state management.
1 parent 135ec82 commit 34bd2fb

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

src/components/OBS_Components/SoundRequest/CurrentTrack/CurrentTrack.module.scss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,13 @@
148148

149149
/* Прогресс-бар контейнер */
150150
.progressBarContainer {
151-
position: absolute;
152-
top: 0;
151+
position: fixed;
152+
top: 50%;
153+
transform: translateY(-50%);
153154
left: 0;
154155
right: 0;
155-
height: 100%;
156+
height: 90%;
157+
width: 100%;
156158
z-index: -1;
157159
background: linear-gradient(to right,
158160
rgba(110, 110, 110, 0.45) 0%,

src/components/OBS_Components/SoundRequest/CurrentTrack/CurrentTrack.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "./animation.scss";
22

3-
import { CSSProperties } from "react";
3+
import { CSSProperties, useEffect } from "react";
44

55
import { TunaMusicData } from "@/shared/api";
66

@@ -34,6 +34,12 @@ export default function CurrentTrack({
3434
swapChange,
3535
shouldAnimate = true,
3636
}: Props) {
37+
useEffect(() => {
38+
if (shouldAnimate) {
39+
console.log(oldTrack, track, swap, shouldAnimate);
40+
}
41+
}, [oldTrack, shouldAnimate, swap, track]);
42+
3743
return (
3844
<>
3945
<div
@@ -42,14 +48,14 @@ export default function CurrentTrack({
4248
...baseStyles,
4349
}}
4450
>
45-
<ProgressBar track={track} />
4651
<AnimationControl AnimationStart={shouldAnimate} swapTrack={swapChange}>
4752
{shouldAnimate && !swap && <CurrentTrackElement track={oldTrack} />}
4853
{(shouldAnimate && swap) || !shouldAnimate ? (
4954
<CurrentTrackElement track={track} />
5055
) : null}
5156
</AnimationControl>
5257
</div>
58+
<ProgressBar track={track} />
5359
</>
5460
);
5561
}

src/components/OBS_Components/SoundRequest/CurrentTrack/CurrentTrackManager.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ export function CurrentTrackManager() {
5454
};
5555
}
5656

57+
// Если плеер остановлен и приходит новый трек — просто меняем без анимации
58+
if (
59+
s.currentTrack.status === "stopped" &&
60+
key(a.data) !== key(s.currentTrack)
61+
) {
62+
return {
63+
...s,
64+
currentTrack: { ...a.data, isDefaultValue: false },
65+
incomingTrack: null,
66+
isAnimating: false,
67+
swap: false,
68+
};
69+
}
70+
5771
// Если уже идёт анимация — только обновляем incomingTrack
5872
if (s.isAnimating) {
5973
return {

0 commit comments

Comments
 (0)