Add checks for container presence in animation functions to prevent errors when elements are removed from the DOM [skip ci]
This commit is contained in:
@@ -56,9 +56,9 @@ function createOscar(container) {
|
||||
container.appendChild(carpet);
|
||||
container.appendChild(spotlights);
|
||||
|
||||
// Paparazzi flashes with randomized intervals
|
||||
function flashLoop() {
|
||||
if (!document.querySelector('.oscar-container')) {
|
||||
if (!document.body.contains(container)) return; // Kill the loop if container is removed
|
||||
if (container.style.display === 'none') {
|
||||
setTimeout(flashLoop, 1000); // Check again later if hidden
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user