The viewport library can be used to check the state of the current viewport during scrolling and window resizing.