在外窗高度位置计数div

你知道是否有一种方法在jquery / JavaScript中计数窗口屏幕高度之外的div?

像图片一样, 在绿色区域

在这里输入图像描述

先谢谢你


我已经创建了示例片段作为参考如何检查Mojo在评论中是否提供了屏幕外的元素

jQuery.expr.filters.offscreen = function(el) {
  var rect = el.getBoundingClientRect();
  return (
           (rect.x + rect.width) < 0 
             || (rect.y + rect.height) < 0
             || (rect.x > window.innerWidth || rect.y > window.innerHeight)
         );
};


function checkOutsideDiv(){
	var allEl = $('.common-class');
  allEl.each(function(i, el){
  	console.log($(el).is(':offscreen'));
  });
}
.wrap{
  padding:20px;
  border:dotted 2px red;
  width:100%;
  float:left;
}

.common-class{
  width:40%;
  height:200px;
  line-height:200px;
  border:1px dashed green;
  float:left;
  margin:5px;
  text-align:center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<button type="button" onclick="checkOutsideDiv()">
Check
</button>

<div class="wrap">
  <div class="common-class"> 1  </div>
  <div class="common-class"> 2  </div>
  <div class="common-class"> 2  </div>
  <div class="common-class"> 4  </div>
  <div class="common-class"> 5  </div>
  <div class="common-class"> 6  </div>
  <div class="common-class"> 7  </div>
  <div class="common-class"> 8  </div>
  <div class="common-class"> 9  </div>
  <div class="common-class"> 10  </div>
  <div class="common-class"> 11  </div>
  <div class="common-class"> 12  </div>
  <div class="common-class"> 13  </div>
  <div class="common-class"> 14  </div>
  <div class="common-class"> 15  </div>
</div>
链接地址: http://www.djcxy.com/p/14639.html

上一篇: Count divs in outside window height position

下一篇: How to check if div is visible to user or not?