Utilities
elementVisibility
Checks that an element is in viewport or not.
Demo
Scroll
Visible: undefined
Utilities
Checks that an element is in viewport or not.
<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>