JGirault has uploaded a new change for review. https://gerrit.wikimedia.org/r/297113
Change subject: Fix VE not updating map position on "done" ...................................................................... Fix VE not updating map position on "done" Bug: T139218 Change-Id: Iea64641a23d95e0658a925839c0d3ffe303522a3 --- M modules/ve-maps/ve.ce.MWMapsNode.js 1 file changed, 27 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Kartographer refs/changes/13/297113/1 diff --git a/modules/ve-maps/ve.ce.MWMapsNode.js b/modules/ve-maps/ve.ce.MWMapsNode.js index 7fe416c..6abe846 100644 --- a/modules/ve-maps/ve.ce.MWMapsNode.js +++ b/modules/ve-maps/ve.ce.MWMapsNode.js @@ -29,7 +29,9 @@ this.$imageLoader = null; this.geoJson = null; + this.mapData = {}; + this.updateMapPosition = $.debounce( 300, $.proxy( this.updateMapPosition, this ) ); this.updateGeoJson = $.debounce( 300, $.proxy( this.updateGeoJson, this ) ); // Events @@ -114,7 +116,7 @@ if ( !this.map && this.getRoot() ) { mw.loader.using( 'ext.kartographer.live' ).then( this.setupMap.bind( this ) ); } else if ( this.map ) { - this.map.invalidateSize(); + this.updateMapPosition(); this.updateGeoJson(); } } else { @@ -128,7 +130,8 @@ } this.$element .removeClass( 'floatleft center floatright' ) - .addClass( alignClasses[ align ] ); + .addClass( alignClasses[ align ] ) + .css( this.model.getCurrentDimensions() ); }; /** @@ -176,6 +179,28 @@ }; /** + * Update the GeoJSON layer from the current model state + */ +ve.ce.MWMapsNode.prototype.updateMapPosition = function () { + var mwData = this.model.getAttribute( 'mw' ), + mapData = this.mapData, + updatedData = mwData && mwData.attrs; + + if ( + mapData.latitude !== updatedData.latitude || + mapData.longitude !== updatedData.longitude || + mapData.zoom !== updatedData.zoom + ) { + this.map.setView( [ updatedData.latitude, updatedData.longitude ], updatedData.zoom ); + mapData.latitude = updatedData.latitude; + mapData.longitude = updatedData.longitude; + mapData.zoom = updatedData.zoom; + } else { + this.map.invalidateSize(); + } +}; + +/** * Update the static rendering */ ve.ce.MWMapsNode.prototype.updateStatic = function ( width, height ) { -- To view, visit https://gerrit.wikimedia.org/r/297113 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iea64641a23d95e0658a925839c0d3ffe303522a3 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Kartographer Gerrit-Branch: master Gerrit-Owner: JGirault <julien.inbox.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits