|
|
@@ -49,19 +49,20 @@
|
|
|
let loadDeferredImages;
|
|
|
|
|
|
addEventListener(LOAD_DEFERRED_IMAGES_START_EVENT, () => {
|
|
|
- const clientHeight = document.documentElement.clientHeight;
|
|
|
- const clientWidth = document.documentElement.clientWidth;
|
|
|
- const scrollHeight = Math.max(document.documentElement.scrollHeight - (clientHeight * .5), clientHeight);
|
|
|
- const scrollWidth = Math.max(document.documentElement.scrollWidth - (clientWidth * .5), clientWidth);
|
|
|
- document.documentElement.__defineGetter__("clientHeight", () => scrollHeight);
|
|
|
- document.documentElement.__defineGetter__("clientWidth", () => scrollWidth);
|
|
|
+ const scrollingElement = document.scrollingElement || document.documentElement;
|
|
|
+ const clientHeight = scrollingElement.clientHeight;
|
|
|
+ const clientWidth = scrollingElement.clientWidth;
|
|
|
+ const scrollHeight = Math.max(scrollingElement.scrollHeight - (clientHeight * .5), clientHeight);
|
|
|
+ const scrollWidth = Math.max(scrollingElement.scrollWidth - (clientWidth * .5), clientWidth);
|
|
|
+ scrollingElement.__defineGetter__("clientHeight", () => scrollHeight);
|
|
|
+ scrollingElement.__defineGetter__("clientWidth", () => scrollWidth);
|
|
|
screen.__defineGetter__("height", () => scrollHeight);
|
|
|
screen.__defineGetter__("width", () => scrollWidth);
|
|
|
if (!window._singleFile_getBoundingClientRect) {
|
|
|
window._singleFile_getBoundingClientRect = Element.prototype.getBoundingClientRect;
|
|
|
Element.prototype.getBoundingClientRect = function () {
|
|
|
const boundingRect = window._singleFile_getBoundingClientRect.call(this);
|
|
|
- if (this == document.documentElement) {
|
|
|
+ if (this == scrollingElement) {
|
|
|
boundingRect.__defineGetter__("height", () => scrollHeight);
|
|
|
boundingRect.__defineGetter__("bottom", () => scrollHeight + boundingRect.top);
|
|
|
boundingRect.__defineGetter__("width", () => scrollWidth);
|
|
|
@@ -124,8 +125,9 @@
|
|
|
|
|
|
|
|
|
addEventListener(LOAD_DEFERRED_IMAGES_END_EVENT, () => {
|
|
|
- delete document.documentElement.clientHeight;
|
|
|
- delete document.documentElement.clientWidth;
|
|
|
+ const scrollingElement = document.scrollingElement || document.documentElement;
|
|
|
+ delete scrollingElement.clientHeight;
|
|
|
+ delete scrollingElement.clientWidth;
|
|
|
delete screen.height;
|
|
|
delete screen.width;
|
|
|
if (window._singleFile_getBoundingClientRect) {
|
|
|
@@ -177,7 +179,8 @@
|
|
|
|
|
|
addEventListener(LOAD_DEFERRED_IMAGES_START_EVENT, () => {
|
|
|
loadDeferredImages = true;
|
|
|
- const docBoundingRect = document.documentElement.getBoundingClientRect();
|
|
|
+ const scrollingElement = document.scrollingElement || document.documentElement;
|
|
|
+ const docBoundingRect = scrollingElement.getBoundingClientRect();
|
|
|
Array.from(observers, ([intersectionObserver, observer]) => {
|
|
|
const rootBoundingRect = observer.options.root && observer.options.root.getBoundingClientRect();
|
|
|
observer.callback(observedElements.get(intersectionObserver).map(target => {
|