Skip to content

Commit 011430e

Browse files
argyleinkRobbieTheWagner
authored andcommitted
adds particle effect to thumb
1 parent 99107c7 commit 011430e

3 files changed

Lines changed: 84 additions & 0 deletions

File tree

src/components/Player.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,24 @@ export default function Player() {
2424
const percentage =
2525
(audioPlayer.current.currentTime / audioPlayer.current.duration) * 100;
2626
setProgress(percentage);
27+
2728
const slider = document.querySelector('.slider');
29+
const particles = document.querySelector('.ship-particles');
30+
2831
if (slider) {
2932
(slider as HTMLElement).style.setProperty(
3033
'--seek-before-width',
3134
`${percentage}%`
3235
);
3336
}
37+
38+
if (particles && slider) {
39+
const pxOffset = slider.clientWidth * (percentage / 100);
40+
(particles as HTMLElement).style.setProperty(
41+
'--seek-particles-left',
42+
`${pxOffset}px`
43+
);
44+
}
3445
}
3546
progressRef.current = requestAnimationFrame(whilePlaying);
3647
}

src/components/player/Slider/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ export default function Slider({ audioPlayer, progress }: Props) {
5454
}
5555
}}
5656
/>
57+
<div className={"ship-particles absolute h-full -top-[1px] grid place-items-center place-content-center"}>
58+
<div className="w-1 h-1 rounded-full row-start-1 col-start-1 pointer-events-none"></div>
59+
<div className="w-1 h-1 rounded-full row-start-1 col-start-1 pointer-events-none"></div>
60+
<div className="w-1 h-1 rounded-full row-start-1 col-start-1 pointer-events-none"></div>
61+
<div className="w-1 h-1 rounded-full row-start-1 col-start-1 pointer-events-none"></div>
62+
<div className="w-1 h-1 rounded-full row-start-1 col-start-1 pointer-events-none"></div>
63+
</div>
5764
<span class="hidden text-nowrap text-sm tabular-nums md:inline-block">
5865
{formatTime(currentTime, totalTime)} / {formatTime(totalTime)}
5966
</span>

src/components/player/Slider/styles.css

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,70 @@
5555
@apply opacity-100;
5656
}
5757
}
58+
59+
&:not(:hover) ~ .ship-particles {
60+
display: none;
61+
}
62+
}
63+
64+
.ship-particles {
65+
left: calc(var(--seek-particles-left) - 15px);
66+
67+
> div {
68+
animation:
69+
ship-particles-x 1s ease infinite,
70+
ship-particles-y 1s ease infinite;
71+
animation-composition: add;
72+
background-color: #B0ECFF;
73+
74+
@media (prefers-color-scheme: light) {
75+
background-color: #906BFF;
76+
}
77+
78+
&:nth-child(1) {
79+
animation-delay: 0.4s;
80+
--y-offset: -10px;
81+
--x-offset: -20px;
82+
}
83+
&:nth-child(2) {
84+
animation-delay: 0.8s;
85+
--y-offset: -20px;
86+
--x-offset: -15px;
87+
}
88+
&:nth-child(3) {
89+
animation-delay: 0.1s;
90+
--y-offset: 15px;
91+
--x-offset: -25px;
92+
}
93+
&:nth-child(4) {
94+
animation-delay: 0.3s;
95+
--y-offset: 25px;
96+
--x-offset: -10px;
97+
}
98+
&:nth-child(5) {
99+
animation-delay: 0.7s;
100+
--y-offset: 17px;
101+
--x-offset: -15px;
102+
}
103+
}
104+
}
105+
106+
@keyframes ship-particles-x {
107+
0% {
108+
opacity: 1;
109+
transform: translateX(0) scale(1);
110+
}
111+
100% {
112+
opacity: 0;
113+
transform: translateX(var(--x-offset)) scale(.25) translateY(var(--y-offset));
114+
}
115+
}
116+
117+
@keyframes ship-particles-y {
118+
0%, 15% {
119+
transform: translateY(0);
120+
}
121+
100% {
122+
transform: translateY(var(--y-offset));
123+
}
58124
}

0 commit comments

Comments
 (0)