I am working on a section marked with the class 'concert-landing-synopsis' and I need to add a class to a different element when this section comes into focus during scrolling. Despite exploring various solutions, the focused variable always seems to be false.
let activateElement = document.getElementsByClassName("concert-landing-synopsis");
if (activateElement.length > 0) {
window.onscroll = _ => {
let isFocused = (document.activeElement === activateElement[0]);
if (isFocused) {
console.log("On focus");
}
};
}
This is how the view looks like:
<section class="concert-landing-details">
<div></div>
<div></div>
<div></div>
<div></div>
</section>