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:
@@ -61,12 +61,12 @@ function createFriday13(container) {
|
||||
cat.parentNode.removeChild(cat);
|
||||
}
|
||||
// Respawn with random delay between 5 to 25 seconds
|
||||
setTimeout(spawnCat, Math.random() * 20000 + 5000);
|
||||
setTimeout(() => { if (document.body.contains(container)) spawnCat(); }, Math.random() * 20000 + 5000);
|
||||
}, (catWalkDurationSeconds * 1000) + 500); // Wait for duration + 500ms safety margin
|
||||
}
|
||||
|
||||
// Initial spawn with random delay
|
||||
setTimeout(spawnCat, Math.random() * 5000);
|
||||
setTimeout(() => { if (document.body.contains(container)) spawnCat(); }, Math.random() * 5000);
|
||||
}
|
||||
|
||||
function initializeFriday13() {
|
||||
|
||||
Reference in New Issue
Block a user