Answers for "how to check when an element cross the viewport"

2

how to check element is in viewport

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

  return (
    (top > 0 || bottom > 0) &&
    top < vHeight
  );
}
Posted by: Guest on December-25-2020

Code answers related to "how to check when an element cross the viewport"

Code answers related to "Javascript"

Browse Popular Code Answers by Language