📌  相关文章
📜  如何检查元素在视口中 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:29.708000             🧑  作者: Mango

代码示例2
function isVisible (ele) {
  const { top, bottom } = ele.getBoundingClientRect();
  const vHeight = (window.innerHeight || document.documentElement.clientHeight);

  return (
    (top > 0 || bottom > 0) &&
    top < vHeight
  );
}