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:
CodeDevMLH
2026-02-27 04:07:29 +01:00
parent 3c1bd01373
commit bd8088c52b
10 changed files with 20 additions and 15 deletions

View File

@@ -295,7 +295,7 @@ function createBird(container) {
wrapper.addEventListener('animationend', (e) => {
if (e.animationName.includes('fly-')) {
wrapper.remove();
createBird(container);
if (document.body.contains(container)) createBird(container);
}
});
@@ -338,7 +338,7 @@ function createButterfly(container) {
wrapper.addEventListener('animationend', (e) => {
if (e.animationName.includes('fly-')) {
wrapper.remove();
createButterfly(container);
if (document.body.contains(container)) createButterfly(container);
}
});
@@ -385,7 +385,7 @@ function createBee(container) {
wrapper.addEventListener('animationend', (e) => {
if (e.animationName.includes('fly-')) {
wrapper.remove();
createBee(container);
if (document.body.contains(container)) createBee(container);
}
});
@@ -428,7 +428,7 @@ function createLadybugGif(container) {
wrapper.addEventListener('animationend', (e) => {
if (e.animationName.includes('walk-')) {
wrapper.remove();
createLadybugGif(container);
if (document.body.contains(container)) createLadybugGif(container);
}
});