Created
December 1, 2019 14:30
-
-
Save ampersanda/8520a5c77e046518d31b20e3df0e1527 to your computer and use it in GitHub Desktop.
Simple and Modern LazyLoad
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
// https://twitter.com/samccone/status/1200967148580921344?s=20 | |
this.obs = new IntersectionObserver(onHit, { | |
rootMargin: '0px', | |
threshold: 0.2 | |
}); | |
this.obs.observe(elms); | |
onHit(entries) { | |
for (const e of entries) { | |
if (e.isIntersecting) { // GO } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment