Don't let the bird land on sticky things

This commit is contained in:
Idrees Hassan
2025-10-26 21:37:01 -04:00
parent 56a999a235
commit 0d1e63888d
5 changed files with 28 additions and 10 deletions

View File

@@ -897,7 +897,12 @@ Promise.all([
if (largeElements.length === 0) {
return;
}
const randomElement = largeElements[Math.floor(Math.random() * largeElements.length)];
// Ensure the bird doesn't land on fixed or sticky elements
const nonFixedElements = largeElements.filter((el) => {
const style = window.getComputedStyle(el);
return style.position !== "fixed" && style.position !== "sticky";
});
const randomElement = nonFixedElements[Math.floor(Math.random() * nonFixedElements.length)];
focusedElement = randomElement;
log("Focusing on element: ", focusedElement);
updateFocusedElementBounds();