Skip to content

Instantly share code, notes, and snippets.

@ceane
Created June 11, 2023 06:43
Show Gist options
  • Save ceane/306e3da0bb50cd54fbac04b9142e33c7 to your computer and use it in GitHub Desktop.
Save ceane/306e3da0bb50cd54fbac04b9142e33c7 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Intersection Observer API</title>
</head>
<body>
<main>
<div class="observed">
</div>
</main>
</body>
</html>
let handler = () => {}
// WARN use this API cautiously, lots of observers take up memory and polling is expensive
let observer = new IntersectionObserver(handler, {
root: document.querySelector('.observed'),
rootMargin: '3vw',
threshold: 1.0
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment