diff --git a/external/Control.MiniMap.css b/external/Control.MiniMap.css index 9b2d65a82..666047c16 100644 --- a/external/Control.MiniMap.css +++ b/external/Control.MiniMap.css @@ -38,14 +38,14 @@ } .leaflet-control-minimap-toggle-display{ - background-image: url(@@INCLUDEIMAGE:images/minimap-toggle.png@@); + background-image: url("images/toggle.svg"); background-size: cover; position: absolute; border-radius: 3px 0px 0px 0px; } .leaflet-oldie .leaflet-control-minimap-toggle-display{ - background-image: url(@@INCLUDEIMAGE:images/minimap-toggle.png@@); + background-image: url("images/toggle.png"); } .leaflet-control-minimap-toggle-display-bottomright { diff --git a/external/Control.MiniMap.js b/external/Control.MiniMap.js index f897c2fb2..810eec40c 100644 --- a/external/Control.MiniMap.js +++ b/external/Control.MiniMap.js @@ -20,6 +20,9 @@ }(function (L) { var MiniMap = L.Control.extend({ + + includes: L.Evented ? L.Evented.prototype : L.Mixin.Events, + options: { position: 'bottomright', toggleDisplay: false, @@ -190,6 +193,7 @@ this._container.style.display = 'none'; } this._minimized = true; + this._onToggle(); }, _restore: function () { @@ -203,6 +207,7 @@ this._container.style.display = 'block'; } this._minimized = false; + this._onToggle(); }, _onMainMapMoved: function (e) { @@ -313,6 +318,22 @@ _isDefined: function (value) { return typeof value !== 'undefined'; + }, + + _onToggle: function () { + L.Util.requestAnimFrame(function () { + L.DomEvent.on(this._container, 'transitionend', this._fireToggleEvents, this); + if (!L.Browser.any3d) { + L.Util.requestAnimFrame(this._fireToggleEvents, this); + } + }, this); + }, + + _fireToggleEvents: function () { + L.DomEvent.off(this._container, 'transitionend', this._fireToggleEvents, this); + var data = { minimized: this._minimized }; + this.fire(this._minimized ? 'minimize' : 'restore', data); + this.fire('toggle', data); } }); diff --git a/images/minimap-toggle.png b/images/minimap-toggle.png deleted file mode 100644 index 026d4c8bb..000000000 Binary files a/images/minimap-toggle.png and /dev/null differ diff --git a/images/toggle.png b/images/toggle.png new file mode 100644 index 000000000..7a55db43c Binary files /dev/null and b/images/toggle.png differ diff --git a/images/minimap-toggle.svg b/images/toggle.svg similarity index 100% rename from images/minimap-toggle.svg rename to images/toggle.svg diff --git a/plugins/minimap.user.js b/plugins/minimap.user.js index d8c613c2f..1244aee21 100644 --- a/plugins/minimap.user.js +++ b/plugins/minimap.user.js @@ -2,7 +2,7 @@ // @id iitc-plugin-minimap@breunigs // @name IITC plugin: Mini map // @category Controls -// @version 0.2.0.@@DATETIMEVERSION@@ +// @version 0.3.0.@@DATETIMEVERSION@@ // @description [@@BUILDNAME@@-@@BUILDDATE@@] Show a mini map on the corner of the map. @@METAINFO@@ // ==/UserScript== @@ -32,7 +32,7 @@ window.plugin.miniMap.setup = function() { new L.Control.MiniMap(L.gridLayer.googleMutant('ROADMAP',{maxZoom:21}), {toggleDisplay: true, position: position}).addTo(window.map); }, 0); - $('head').append(''); + $('head').append(''); }; var setup = window.plugin.miniMap.setup;