Created
June 11, 2023 06:43
-
-
Save ceane/306e3da0bb50cd54fbac04b9142e33c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Intersection Observer API</title> | |
</head> | |
<body> | |
<main> | |
<div class="observed"> | |
</div> | |
</main> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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