mirror of
https://github.com/morpheusthewhite/spicetify-themes.git
synced 2024-11-22 02:42:54 +01:00
fix(Turntable): correctly control the rotation of the turntable
This commit is contained in:
parent
9c1e5dc7d4
commit
5cb616a78c
@ -1,5 +1,4 @@
|
||||
window.addEventListener("load", () => {
|
||||
(function rotateTurntable() {
|
||||
window.addEventListener("load", rotateTurntable = () => {
|
||||
if (!Spicetify.Player.origin || !document.querySelector("#fad-art-image")) {
|
||||
setTimeout(rotateTurntable, 250);
|
||||
return;
|
||||
@ -7,24 +6,29 @@ window.addEventListener("load", () => {
|
||||
|
||||
const fullAppDisplay = document.querySelector("#full-app-display");
|
||||
|
||||
function handleRotate() {
|
||||
let playState;
|
||||
|
||||
function handleRotate(fromEvent) {
|
||||
const fadArt = document.querySelector("#fad-art-image");
|
||||
|
||||
Spicetify.Player.isPlaying()
|
||||
? fadArt.style.animationPlayState = "running"
|
||||
: fadArt.style.animationPlayState = "paused";
|
||||
if (!fromEvent && Spicetify.Player.isPlaying() || fromEvent && !playState) {
|
||||
fadArt.style.animationPlayState = "running";
|
||||
return playState = true;
|
||||
} else {
|
||||
fadArt.style.animationPlayState = "paused";
|
||||
return playState = false;
|
||||
}
|
||||
}
|
||||
|
||||
handleRotate();
|
||||
|
||||
Spicetify.Player.addEventListener("onplaypause", () => setTimeout(handleRotate));
|
||||
Spicetify.Player.addEventListener("onplaypause", () => handleRotate(true));
|
||||
|
||||
fullAppDisplay.addEventListener("contextmenu", () => {
|
||||
const configSwitchBtns = document.querySelectorAll("#popup-config-container button.switch");
|
||||
|
||||
for (const configSwitch of configSwitchBtns) {
|
||||
configSwitch.addEventListener("click", handleRotate);
|
||||
configSwitch.addEventListener("click", () => handleRotate());
|
||||
}
|
||||
});
|
||||
})();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user