fix(Turntable): correctly close the Full App Display and the config popup window

Fix the Spicetify's bug:
- prevent close the Full App Display when quickly click the control button
- correctly close the popup window when switch config
This commit is contained in:
Grason Chan 2021-07-04 13:06:54 +08:00
parent 5cb616a78c
commit 8deecbb492

View File

@ -20,15 +20,33 @@ window.addEventListener("load", rotateTurntable = () => {
}
}
handleRotate();
function handleFadDblclick() {
const fadControlsBtns = document.querySelectorAll("#fad-controls button");
for (const fadControl of fadControlsBtns) {
fadControl.addEventListener("dblclick", event => event.stopPropagation());
}
}
function handleInitalStatus(genericModal) {
if (genericModal) {
genericModal.remove();
}
handleRotate();
handleFadDblclick();
}
handleInitalStatus();
Spicetify.Player.addEventListener("onplaypause", () => handleRotate(true));
fullAppDisplay.addEventListener("contextmenu", () => {
const genericModal = document.querySelector("generic-modal");
const configSwitchBtns = document.querySelectorAll("#popup-config-container button.switch");
for (const configSwitch of configSwitchBtns) {
configSwitch.addEventListener("click", () => handleRotate());
configSwitch.addEventListener("click", () => handleInitalStatus(genericModal));
}
});
});