|
|
@@ -39,6 +39,7 @@ this.hooksFrame = this.hooksFrame || (() => {
|
|
|
|
|
|
function hook() {
|
|
|
const NEW_FONT_FACE_EVENT = "single-file-new-font-face";
|
|
|
+ const LOAD_OBSERVED_ELEMENTS_EVENT = "single-file-load-observed-elements";
|
|
|
const FONT_STYLE_PROPERTIES = {
|
|
|
family: "font-family",
|
|
|
style: "font-style",
|
|
|
@@ -69,8 +70,6 @@ this.hooksFrame = this.hooksFrame || (() => {
|
|
|
}));
|
|
|
|
|
|
if (window.IntersectionObserver) {
|
|
|
- const LOAD_OBSERVED_ELEMENTS_EVENT = "single-file-load-observed-elements";
|
|
|
-
|
|
|
const IntersectionObserver = window.IntersectionObserver;
|
|
|
const observeIntersection = IntersectionObserver.prototype.observe;
|
|
|
const unobserveIntersection = IntersectionObserver.prototype.unobserve;
|
|
|
@@ -112,15 +111,16 @@ this.hooksFrame = this.hooksFrame || (() => {
|
|
|
}));
|
|
|
window.__defineSetter__("IntersectionObserver", () => { });
|
|
|
addEventListener(LOAD_OBSERVED_ELEMENTS_EVENT, () => {
|
|
|
+ const docBoundingRect = document.documentElement.getBoundingClientRect();
|
|
|
Array.from(observers).forEach(([intersectionObserver, observer]) => {
|
|
|
+ const rootBoundingRect = observer.options.root.getBoundingClientRect();
|
|
|
observer.callback(observedElements.get(intersectionObserver).map(target => {
|
|
|
const boundingClientRect = target.getBoundingClientRect();
|
|
|
- const intersectionRect = target.getBoundingClientRect();
|
|
|
const isIntersecting = true;
|
|
|
const intersectionRatio = 1;
|
|
|
- const rootBounds = observer.options && observer.options.root ? observer.options.root.getBoundingClientRect() : document.documentElement.getBoundingClientRect();
|
|
|
+ const rootBounds = observer.options && observer.options.root ? rootBoundingRect : docBoundingRect;
|
|
|
const time = 0;
|
|
|
- return { target, intersectionRatio, boundingClientRect, intersectionRect, isIntersecting, rootBounds, time };
|
|
|
+ return { target, intersectionRatio, boundingClientRect, intersectionRect: boundingClientRect, isIntersecting, rootBounds, time };
|
|
|
}), intersectionObserver);
|
|
|
});
|
|
|
}, false);
|