How to detect if an element is currently in the browser window