Browse Source

avoid using screen object

Gildas 7 years ago
parent
commit
f082cfc6e7
1 changed files with 6 additions and 6 deletions
  1. 6 6
      lib/lazy/web-lazy-loader-before.js

+ 6 - 6
lib/lazy/web-lazy-loader-before.js

@@ -18,7 +18,7 @@
  *   along with SingleFile.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/* global window, screen, scrollBy, requestAnimationFrame, Element, document, dispatchEvent, UIEvent, setTimeout */
+/* global window, scrollBy, requestAnimationFrame, Element, document, dispatchEvent, UIEvent, setTimeout */
 
 (() => {
 
@@ -28,17 +28,17 @@
 	window._singleFile_getBoundingClientRect = Element.prototype.getBoundingClientRect;
 	Element.prototype.getBoundingClientRect = function () {
 		const boundingRect = window._singleFile_getBoundingClientRect.call(this);
-		const quarterLeft = Math.floor(screen.width / 4);
-		const quarterTop = Math.floor(screen.height / 4);
-		const top = (boundingRect.top > 0 && boundingRect.top < screen.height) ? boundingRect.top : boundingRect.top > screen.height ? screen.height - quarterTop : quarterTop;
-		const left = (boundingRect.left > 0 && boundingRect.left < screen.width) ? boundingRect.left : boundingRect.left > screen.width ? screen.width - quarterLeft : quarterLeft;
+		const quarterLeft = Math.floor(window.innerWidth / 4);
+		const quarterTop = Math.floor(window.innerHeight / 4);
+		const top = (boundingRect.top > 0 && boundingRect.top < window.innerHeight) ? boundingRect.top : boundingRect.top > window.innerHeight ? window.innerHeight - quarterTop : quarterTop;
+		const left = (boundingRect.left > 0 && boundingRect.left < window.innerHeight) ? boundingRect.left : boundingRect.left > window.innerHeight ? window.innerHeight - quarterLeft : quarterLeft;
 		const bottom = top + boundingRect.height;
 		const right = left + boundingRect.width;
 		return { x: boundingRect.x, y: boundingRect.y, top, bottom, left, right, width: boundingRect.width, height: boundingRect.height };
 	};
 	scrollBy(0, 1);
 	requestAnimationFrame(() => scrollBy(0, -1));
-	scroll(SCROLL_LENGTH, document.documentElement.scrollHeight - screen.height);
+	scroll(SCROLL_LENGTH, document.documentElement.scrollHeight - window.innerHeight);
 
 	function scroll(offsetY, maxOffsetY) {
 		document.documentElement.__defineGetter__("scrollTop", () => offsetY);