I'm trying to get the position of the webpage and use it as a condition to run some command if the condition is met.
const getScroll = () => {
const check = window.scrollY; // If I set the type here to HTMLElement the condition below here becomes invalid because check can't be compared to a number.
if (check >= 100) {
setScroll(true);
} else {
setScroll(false);
}
};
window.addEventListener("scroll", getScroll);
const getScroll = () => {
const check = window.scrollY; // If I set the type here to HTMLElement the condition below here becomes invalid because check can't be compared to a number.