Created
March 25, 2020 05:31
-
-
Save umkasanki/56296794f7180f13fbcd25b842604b4b to your computer and use it in GitHub Desktop.
Intersection Observer for check position of element
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
const checkVisability = target => { | |
const io = new IntersectionObserver((entries, observer) => { | |
console.log(entries) | |
entries.forEach(entry => { | |
if (entry.isIntersecting) { | |
console.log('visible'); | |
// observer.disconnect(); | |
} else { | |
console.log('unvisible'); | |
} | |
}); | |
}); | |
io.observe(target) | |
}; | |
checkVisability(quoteTable); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
source https://fireship.io/snippets/intersection-observer-lazy-load-images/