const options = {
root: document.getElementById('some-id'), // leave blank for viewport
rootMargin: '0px',
threshold: 1.0,
};
const observer = new IntersectionObserver(observeTestamonialInViewPortCB, options);
const observeTestamonialInViewPortCB = (entries, observer) => {
entries.forEach((entry) => {
log(entry);
// to stop observer:
observer.unobserve();
});
};
const target = document.getElementById('target-element');
observer.observe(target);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter