Browse Source

be less aggressive with positions

Gildas 7 years ago
parent
commit
2d411659e4
1 changed files with 4 additions and 2 deletions
  1. 4 2
      lib/single-file/lazy-loader-before.js

+ 4 - 2
lib/single-file/lazy-loader-before.js

@@ -25,8 +25,10 @@
 	window._singleFile_getBoundingClientRect = Element.prototype.getBoundingClientRect;
 	Element.prototype.getBoundingClientRect = function () {
 		const boundingRect = window._singleFile_getBoundingClientRect.call(this);
-		const top = (boundingRect.top > 0 && boundingRect.top < screen.height) ? boundingRect.top : Math.floor(screen.height / 2);
-		const left = (boundingRect.left > 0 && boundingRect.left < screen.width) ? boundingRect.left : Math.floor(screen.width / 2);
+		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 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 };