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:
@@ -252,7 +252,8 @@ function createSpace() {
|
||||
// Swap to a random image from the pool every time it completes an orbit (disappears)
|
||||
if (imageArr.length > 1) {
|
||||
// The animation delay pushes the initial cycle, so we use setInterval matched to duration
|
||||
setInterval(() => {
|
||||
const intervalId = setInterval(() => {
|
||||
if (!document.body.contains(container)) { clearInterval(intervalId); return; }
|
||||
// Update only if currently out of bounds to avoid popping
|
||||
const rect = symbol.getBoundingClientRect();
|
||||
if (rect.right < 0 || rect.left > window.innerWidth) {
|
||||
|
||||
Reference in New Issue
Block a user