Răsfoiți Sursa

Ticket #4507 - See More: Unstable work when only image is inlined.

AntonLV 3 ani în urmă
părinte
comite
42aed553a9
1 a modificat fișierele cu 7 adăugiri și 9 ștergeri
  1. 7 9
      inc/js/functions.js

+ 7 - 9
inc/js/functions.js

@@ -1011,15 +1011,13 @@ function bx_time(sLang, isAutoupdate, sRootSel) {
             if(oElement.hasClass(sClass) || oElement.css('overflow') != 'hidden')
             	return;
 
-            if(oElement.find('img').length > 0){
-                var oImg = oElement.find('img').first();
-                var iRelImgY = oImg.offset().top - oElement.offset().top;
-
-                const img = new Image();
-                img.src = oImg.prop('src');
-                img.onload = function() {
-                    if(iRelImgY < oElement.height() && iRelImgY + this.height > oElement.height())
-                        oElement.css('max-height', (iRelImgY + this.height) +  50 + 'px');
+            if(oElement.find('img').length > 0) {
+                oElement.find('img:first').get(0).onload = function() {
+                    var iHeightParent = oElement.height();
+                    var iHeightImg = this.clientHeight;
+                    var iOffsetTopImg = this.offsetTop;
+                    if(iOffsetTopImg < iHeightParent && iOffsetTopImg + iHeightImg > iHeightParent)
+                        oElement.css('max-height', (iOffsetTopImg + iHeightImg +  50) + 'px');
 
                     if(oElement.prop('scrollHeight') <= Math.ceil(oElement.height()))
                         return;