diff --git a/files/assets/events/homoween/js/haunt.js b/files/assets/events/homoween/js/haunt.js index fab199007..964b4383d 100644 --- a/files/assets/events/homoween/js/haunt.js +++ b/files/assets/events/homoween/js/haunt.js @@ -15,7 +15,7 @@ window.onload = function() { lightningStrike("normal") } -setInterval(function() { +const lightningInternval = setInterval(function() { if (Math.floor(Math.random()*3) > 1) { lightningStrike("haunted") } else { @@ -28,15 +28,19 @@ function lightningStrike(strike) { if (strike == "haunted") { stylesheet_haunted.disabled = false - if (thunder1) + if (thunder1) { thunder2.play() + prepare_to_pause(thunder2) + } setTimeout(function() { stylesheet_haunted.disabled = true }, 700) } - if (thunder1) + if (thunder1) { thunder1.play() + prepare_to_pause(thunder1) + } setTimeout(function() { div.style.animation = "none" }, 1000) diff --git a/files/assets/js/core.js b/files/assets/js/core.js index 5f7e0a2dd..8a290382f 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -280,12 +280,14 @@ function prepare_to_pause(audio) { if (e == audio) continue e.addEventListener('play', () => { if (!audio.paused) audio.pause(); + if (lightningInternval) clearInterval(lightningInternval) }); } document.addEventListener('click', (e) => { if ((e.target.tagName.toLowerCase() == "lite-youtube" || e.target.classList.contains('lty-playbtn')) && !audio.paused) { audio.pause(); + if (lightningInternval) clearInterval(lightningInternval) } }); }