I have a few elements and detect if each of them is currently in the viewport. I'm using this answer for that: Answer
function isScrolledIntoView(elem)
{
  var $elem = $(elem);
  var $window = $(window);
  var docViewTop = $window.scrollTop();
  var docViewBottom = docViewTop + $window.height();
  var elemTop = $elem.offset().top;
  var elemBottom = elemTop + $elem.height();
  return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
The problem I have is now, as I'm using a collection of elements because there are a couple which have the same class .box, how can I tweak the snippet to actually return the current visible element out of a collection.
Thanks
Edit:
I tried to return
[((elemBottom <= docViewBottom) && (elemTop >= docViewTop)), $(elem, this)]
 
     
    