Add helper JS function for determining whether or not an element is in view.  Fixes #1292.