UNPKG

595 BJavaScriptView Raw
1"use strict";
2
3const {getIntersectionRatio, getIsIntersecting} = require("./intersectionCalc");
4
5module.exports = function FakeIntersectionObserverEntry(browser) {
6 return IntersectionObserverEntry;
7
8 function IntersectionObserverEntry(element, rootMargin) {
9 const boundingClientRect = element.getBoundingClientRect();
10 const intersectionRatio = getIntersectionRatio(boundingClientRect, browser.window.innerHeight, rootMargin);
11 const isIntersecting = getIsIntersecting(intersectionRatio);
12
13 return {target: element, boundingClientRect, intersectionRatio, isIntersecting};
14 }
15};