Detect if an element is visible in the current viewport.
True if the element is in the current viewport but with an x and y offset. A positive offset will make the viewport smaller and vice versa.
True if the element is in or above the current viewport but with an x and y offset. A positive offset will make the viewport smaller and vice versa.
Keeps track of viewport position, viewport dimensions and element positions.
A message type for the state to update.
Update current viewport x and y offset. Use this function to update the viewport scroll position.
Subscribes to browser resize events and recalculates element positions.
Add elements you'd like to be able to detect after you've initialized the state.
True if the element is in the current viewport.