像这样给定IntersectionObserver:
const observeVisibility = intersectionMargin => {
const observer = new IntersectionObserver(
nodes => {
if (nodes[0].isIntersecting) {
/* is really in viewport? */
this.observer.disconnect();
}
},
{ rootMargin: intersectionMargin }
);
observer.observe(...);
};
如何检查节点本身是否实际上在视口中,或者只是导致观察者被调用的intersectionMargin?