1
0
Эх сурвалжийг харах

emulate the element is centered vertically or horizontally

Gildas 7 жил өмнө
parent
commit
c91c59349c

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

@@ -25,8 +25,8 @@
 	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 : 0;
-		const left = (boundingRect.left > 0 && boundingRect.left < screen.width) ? boundingRect.left : 0;
+		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 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 };