1. Utilities
  2. elementVisibility

Utilities

elementVisibility

Checks that an element is in viewport or not.

Demo

Scroll
Visible: undefined

Usage

        <script>
  import { useElementVisibility } from "sveltronics";
  import { onMount } from "svelte";

  let myEle;
  let isVisible;

  onMount(() => {
    isVisible = elementVisibility(myEle);
  })

</script>

<div>
  <div bind:this={myEle}>
    Visible
  </div>
  <div>Visible: {$isVisible}</div>
</div>