isitthere

Simple function that takes in an element and returns % visible in viewport along with boolens for topVisible and bottomVisible.

Usage no npm install needed!

<script type="module">
  import isitthere from 'https://cdn.skypack.dev/isitthere';
</script>

README

IsItThere?

Simple function that takes in an element and returns how much of it is visible in the viewport along with information about the top and bottom being visible

import isItThere from "isitthere";

const elm = document.getElementById("iAmADOMElement");
const results = isItThere(elm);

console.log(results);
// {
//    topVisible: True,
//    bottomVisible: False,
//    percentVisible: 0.55,
// }