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:
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user