feat: add heart animation when cat is pet :3

This commit is contained in:
2024-07-26 23:53:21 +01:00
parent 120130bea9
commit dca52b26c4
4 changed files with 64 additions and 25 deletions

View File

@@ -3,7 +3,8 @@ const CROSSFADE_INTERVAL_MS = 20;
const AUDIO_DURATION_MS = 60000;
const playBtn = document.getElementById("play-btn");
const catImg = document.getElementsByClassName("cat")[0];
const catImg = document.getElementById("cat");
const heartImg = document.getElementById("heart");
const volumeSlider = document.getElementById("volume-slider");
const currentVolumeLabel = document.getElementById("current-volume-label");
const clickAudio = document.getElementById("click-audio");
@@ -192,6 +193,15 @@ volumeSlider.oninput = () => {
};
volumeSlider.value = 100;
meowAudio.onplay = () => {
heartImg.style.display = "block";
heartImg.style.animation = "1s linear 0s heart-animation";
setTimeout(() => {
heartImg.style.display = "none";
heartImg.style.animation = "";
}, 900);
};
window.addEventListener("offline", () => {
ws = null;
});