判断dom是否出现在可视区域

function isElementNotInViewport (el) {
    if (el) {
      let rect = el.getBoundingClientRect();
      return (
        rect.top >=
        (window.innerHeight || document.documentElement.clientHeight) ||
        rect.bottom <= 0
      );
    }
  }  
posted @ 2021-01-04 10:35  Ricardo_front  阅读(453)  评论(0编辑  收藏  举报