handled scroll and window resize, cleaned up event listeners