diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aa56b8..6e39d0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +v0.5.0 +--- + +- Added `reAdd` method + v0.4.0 --- diff --git a/README.md b/README.md index 62b3084..612c8bd 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,9 @@ compare.on('slideend', (e) => { //Remove - this will remove the compare control from the DOM and stop synchronizing the two maps. compare.remove(); + +//Re-add - this will re-add the compare control to the DOM and return synchronizing the two maps. +compare.reAdd(); ``` Demo: https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-compare/ diff --git a/dist/mapbox-gl-compare.js b/dist/mapbox-gl-compare.js index fb72b1b..5556822 100644 --- a/dist/mapbox-gl-compare.js +++ b/dist/mapbox-gl-compare.js @@ -1 +1 @@ -!function r(s,h,u){function a(t,e){if(!h[t]){if(!s[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(c)return c(t,!0);var i=new Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}var o=h[t]={exports:{}};s[t][0].call(o.exports,function(e){return a(s[t][1][e]||e)},o,o.exports,r,s,h,u)}return h[t].exports}for(var c="function"==typeof require&&require,e=0;ethis._bounds.width&&(t=this._bounds.width),t},_getY:function(e){var t=(e=e.touches?e.touches[0]:e).clientY-this._bounds.top;return t<0&&(t=0),t>this._bounds.height&&(t=this._bounds.height),t},setSlider:function(e){this._setPosition(e)},on:function(e,t){return this._ev.on(e,t),this},fire:function(e,t){return this._ev.emit(e,t),this},off:function(e,t){return this._ev.removeListener(e,t),this},remove:function(){this._clearSync(),this._mapB.off("resize",this._onResize);var e=this._mapA.getContainer();e&&(e.style.clip=null,e.removeEventListener("mousemove",this._onMove));var t=this._mapB.getContainer();t&&(t.style.clip=null,t.removeEventListener("mousemove",this._onMove)),this._swiper.removeEventListener("mousedown",this._onDown),this._swiper.removeEventListener("touchstart",this._onDown),this._controlContainer.remove()}},window.mapboxgl?mapboxgl.Compare=i:void 0!==t&&(t.exports=i)},{"@mapbox/mapbox-gl-sync-move":2,events:3}],2:[function(e,t,n){t.exports=function(){var t,e=arguments.length;if(1===e)t=arguments[0];else{t=[];for(var n=0;no){s.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+s.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=s.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",h.name,h.message)}}else s=r[t]=n,++e._eventsCount;return e}function f(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;tthis._bounds.width&&(e=this._bounds.width),e},_getY:function(t){var e=(t=t.touches?t.touches[0]:t).clientY-this._bounds.top;return e<0&&(e=0),e>this._bounds.height&&(e=this._bounds.height),e},_setMousemove:function(){this.options&&this.options.mousemove&&(this._getMapAContainer().addEventListener("mousemove",this._onMove),this._getMapBContainer().addEventListener("mousemove",this._onMove))},setSlider:function(t){this._setPosition(t)},on:function(t,e){return this._ev.on(t,e),this},fire:function(t,e){return this._ev.emit(t,e),this},off:function(t,e){return this._ev.removeListener(t,e),this},reAdd:function(){var t=this._getMapAContainer(),e=this._getMapBContainer();t.style.clip&&e.style.clip||(this._createControlContainer(),this._setPosition(this._getSwiperPosition()),this._setMousemove(),this._swiper.addEventListener("mousedown",this._onDown),this._swiper.addEventListener("touchstart",this._onDown),this._clearSync=o(this._mapA,this._mapB),this._mapB.on("resize",this._onResize))},remove:function(){this._clearSync(),this._mapB.off("resize",this._onResize);var t=this._mapA.getContainer();t&&(t.style.clip=null,t.removeEventListener("mousemove",this._onMove));var e=this._mapB.getContainer();e&&(e.style.clip=null,e.removeEventListener("mousemove",this._onMove)),this._swiper.removeEventListener("mousedown",this._onDown),this._swiper.removeEventListener("touchstart",this._onDown),this._controlContainer.remove()}},window.mapboxgl?mapboxgl.Compare=i:void 0!==e&&(e.exports=i)},{"@mapbox/mapbox-gl-sync-move":2,events:3}],2:[function(t,e,n){e.exports=function(){var e,t=arguments.length;if(1===t)e=arguments[0];else{e=[];for(var n=0;no){s.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+s.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');h.name="MaxListenersExceededWarning",h.emitter=t,h.type=e,h.count=s.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",h.name,h.message)}}else s=r[e]=n,++t._eventsCount;return t}function f(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e