Added check for display = none at the top of isElementInView and isElementPartlyInView