I have a problem where I have made my img rotate in a 360 continously but I want it to only do it when the music is playing. I am passing the value of isPlaying into the function but I do not know how to access the CSS value from React.
import React from "react";
const Song = ({ currentSong, isPlaying }: any) => {
return (
<div className="song-container">
<img id="image" alt={currentSong.name} src={currentSong.cover}></img>
<h2>{currentSong.name}</h2>
<h3>{currentSong.artist}</h3>
</div>
);
};
export default Song;
This is my CSS file:
.song-container {
min-height: 70vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
img {
width: 40%;
border-radius: 50%;
animation: spin 10s linear infinite;
animation-play-state: paused;
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
h2 {
padding: 3rem 1rem 1rem 1rem;
font-size: 3rem;
}
h3 {
font-size: 1.5rem;
}
}
I would just like to be able to stop it when the state is not playing and when it is playing I want the animation to play. I am also using typescript as I want to learn the language but if it is too hard to implement over I will just transition my website over to javascript.