Is there a way to change the state of my variable based on scroll position?

Is there any way to change the state of a variable when the user scrolls past a certain point instead of adding a ‘mouse enter’ and ‘mouse leave’ interaction?