Reputation: 106
I want to trigger an if statement when the intersectionObserver API toggles a class in the DOM Element. I am just not sure what exactly is the boolean value returned by this expression: - entry.target.classlist.toggle.valueof; or entry.target.classlist.toggle.valueof();
let intersect = new IntersectionObserver ((entries) => {
entries.forEach((entry) => {
if (entry.target.classList.toggle("fix", entry.isIntersecting).valueOf) {
fixHeader();
}
else unFixHeader();
});
}, {
rootMargin: "-1%",
threshold: 1
});
Upvotes: 0
Views: 40