Intersection Observer API
https://gyazo.com/949b327375035be35eb09e040451514d https://davidwalsh.name/intersection-observers?utm_source=Frontend+Weekly&utm_campaign=1a09b5556d-EMAIL_CAMPAIGN_2017_09_20&utm_medium=email&utm_term=0_9af01549dd-1a09b5556d-371908917
lazy load や不要な DOM の削除、無限スクロールとかにつかうやつ。
code:js
const observer = new IntersectionObserver((entries) = > {
entries.forEach(entry = > console.log(entry.target, entry.intersectionRatio));
});
observer.observe(node); // node が監視対象
intersectionRatio が 0 になる場合があるが、監視対象の Node が見えているかどうかの判断は isIntersecting で判別できる。
Polyfill との違いも書かれている。