jenkins-bot has submitted this change and it was merged.

Change subject: VE: Invisible map render fix
......................................................................


VE: Invisible map render fix

Leaflet tries to get the map dimensions from clientWidth/Height
properties, however these are not available when the maps isn't
visible, event we have explicitly set dimensions in CSS.

Work around this by forcefully setting the map._size property
using jQuery width/height when necessary.

Ideally the would be an API in Leaflet for manually specifying
dimensions.

This hack makes the hack in the CE node redundant.

Bug: T125263
Change-Id: I358d636edceb6b52f9b46e8a7cf37429246ad3fd
---
M modules/kartographer.js
M modules/ve-maps/ve.ce.MWMapsNode.js
2 files changed, 14 insertions(+), 12 deletions(-)

Approvals:
  Yurik: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/kartographer.js b/modules/kartographer.js
index 548cf01..3715127 100644
--- a/modules/kartographer.js
+++ b/modules/kartographer.js
@@ -48,11 +48,22 @@
         * @return {L.map} Map object
         */
        mw.kartographer.createMap = function ( container, data ) {
-               var dataLayer, geoJson,
+               var dataLayer, geoJson, map,
                        style = data.style || mw.config.get( 
'wgKartographerDfltStyle' ),
-                       mapData = mw.config.get( 'wgKartographerLiveData' ) || 
{},
-                       map = L.map( container ).setView( [ data.latitude, 
data.longitude ], data.zoom );
+                       mapData = mw.config.get( 'wgKartographerLiveData' ) || 
{};
 
+               map = L.map( container );
+               if ( !container.clientWidth ) {
+                       // HACK: If the container is not naturally measureable, 
try jQuery
+                       // which will pick up CSS dimensions. T125263
+                       /*jscs:disable disallowDanglingUnderscores */
+                       map._size = new L.Point(
+                               $( container ).width(),
+                               $( container ).height()
+                       );
+                       /*jscs:enable disallowDanglingUnderscores */
+               }
+               map.setView( [ data.latitude, data.longitude ], data.zoom );
                map.attributionControl.setPrefix( '' );
                L.tileLayer( mapServer + '/' + style + urlFormat, {
                        maxZoom: 18,
diff --git a/modules/ve-maps/ve.ce.MWMapsNode.js 
b/modules/ve-maps/ve.ce.MWMapsNode.js
index 0c21b28..6f1003f 100644
--- a/modules/ve-maps/ve.ce.MWMapsNode.js
+++ b/modules/ve-maps/ve.ce.MWMapsNode.js
@@ -120,7 +120,6 @@
  */
 ve.ce.MWMapsNode.prototype.setupMap = function () {
        var geoJson,
-               node = this,
                mwData = this.model.getAttribute( 'mw' ),
                mwAttrs = mwData && mwData.attrs,
                latitude = +mwAttrs.latitude,
@@ -138,14 +137,6 @@
                // TODO: Support style editing
                geoJson: geoJson
        } );
-
-       // The surface is hidden on first load in MW, so wait until first
-       // focus when we know the surface is visible
-       if ( !this.$element.is( ':visible' ) ) {
-               this.getRoot().getSurface().once( 'focus', function () {
-                       node.map.invalidateSize();
-               } );
-       }
 };
 
 /**

-- 
To view, visit https://gerrit.wikimedia.org/r/268837
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I358d636edceb6b52f9b46e8a7cf37429246ad3fd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Kartographer
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Yurik <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to