Newer
Older
KaiFengPC / public / static / libs / map / plugins / Compare.js
@zhangdeliang zhangdeliang on 23 May 14 KB 初始化项目
!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";!function(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&i.firstChild?i.insertBefore(o,i.firstChild):i.appendChild(o),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))}}(".lkmap-compare{background-color:#fff;position:absolute;width:2px;height:100%;z-index:1}.lkmap-compare .compare-swiper-vertical{background-color:#0037e4;border:2px solid #fff;display:inline-block;border-radius:50%;position:absolute;width:38px;height:38px;top:50%;left:-21px;margin:-20px 0 0 1px;color:#fff;cursor:ew-resize;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAACIElEQVRYR+2WPYwOURSGn9dPhGgoRGwkqtVqUChFtLq1ySKUu0ohiIgIQpR2S+InYTutiFKBRksrRBQ0QsTPK+czk3w/882du/vtZiVzq8nce8995j3nvHPFChtaYTy0QKmMtAq1CqUUSM1n15DtTcCcpMm64LYfAtOSvqQguuezgGwfAO4AY5Jq99o28B44LulpU6hGQLbXA9eBk/DPuxoCxdIAuwWckfQ9BZYEsr0buA/s7JG2mULdW94ARyS9qoMaCmR7DXAOuADEc8/IUKh73y/gMnBVUjwPjEog2+OFKnuGfc0CgcpwLwu13g58aP8L2zPADWBDrbT5KesP9w04LWm2sstsbwNuAwdThZdZ1KlwT4ATkj504nbawJ4IbwE2p3aX84tMWf8xnwvPmpftkGy6KcgSAZVh5wJoB/AI2JsDNWKF4ugXwOEyZWuBK8CpMo0puBEChXHeBM5L+tnT9rajoO8BW5YJ6BNwVFIUdmcM+JDtrcADYP8St/0zYErSx8q2735pexVwFrgErK4CW0TKfgMXgWuS/iSNsQ9sHxDXiO0DGxdmjO+ASUnPh6nf5Oca958wzEM90uYDPS4MsPZ+lAQqIWzH1SO6YV2mU/+I7pUUV5DkaAxUOPouYB4Yb1hD8fOckPQ6STKsy1IbbW8EZiUdq1tr+y4wI+lrKmayy3ICjHptVspGfXilnSzHITlntAql1GoV+u8U+gu/XMfUNEODnAAAAABJRU5ErkJggg==);background-size:18px 18px;background-repeat:no-repeat;background-position:50%}.lkmap-compare-horizontal{position:relative;width:100%;height:2px;display:none;}.lkmap-compare .compare-swiper-horizontal{background-color:#0037e4;border:2px solid #fff;display:inline-block;border-radius:50%;position:absolute;width:38px;height:38px;top:50%;left:50%;margin:-21px 0 0 -21px;color:#fff;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAACIElEQVRYR+2WPYwOURSGn9dPhGgoRGwkqtVqUChFtLq1ySKUu0ohiIgIQpR2S+InYTutiFKBRksrRBQ0QsTPK+czk3w/882du/vtZiVzq8nce8995j3nvHPFChtaYTy0QKmMtAq1CqUUSM1n15DtTcCcpMm64LYfAtOSvqQguuezgGwfAO4AY5Jq99o28B44LulpU6hGQLbXA9eBk/DPuxoCxdIAuwWckfQ9BZYEsr0buA/s7JG2mULdW94ARyS9qoMaCmR7DXAOuADEc8/IUKh73y/gMnBVUjwPjEog2+OFKnuGfc0CgcpwLwu13g58aP8L2zPADWBDrbT5KesP9w04LWm2sstsbwNuAwdThZdZ1KlwT4ATkj504nbawJ4IbwE2p3aX84tMWf8xnwvPmpftkGy6KcgSAZVh5wJoB/AI2JsDNWKF4ugXwOEyZWuBK8CpMo0puBEChXHeBM5L+tnT9rajoO8BW5YJ6BNwVFIUdmcM+JDtrcADYP8St/0zYErSx8q2735pexVwFrgErK4CW0TKfgMXgWuS/iSNsQ9sHxDXiO0DGxdmjO+ASUnPh6nf5Oca958wzEM90uYDPS4MsPZ+lAQqIWzH1SO6YV2mU/+I7pUUV5DkaAxUOPouYB4Yb1hD8fOckPQ6STKsy1IbbW8EZiUdq1tr+y4wI+lrKmayy3ICjHptVspGfXilnSzHITlntAql1GoV+u8U+gu/XMfUNEODnAAAAABJRU5ErkJggg==);background-size:18px 18px;background-repeat:no-repeat;background-position:50%;cursor:ns-resize;transform:rotate(90deg)}"),function t(e,n,i){function o(s,u){if(!n[s]){if(!e[s]){var h="function"==typeof require&&require;if(!u&&h)return h(s,!0);if(r)return r(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var c=n[s]={exports:{}};e[s][0].call(c.exports,(function(t){return o(e[s][1][t]||t)}),c,c.exports,t,e,n,i)}return n[s].exports}for(var r="function"==typeof require&&require,s=0;s<i.length;s++)o(i[s]);return o}({1:[function(t,e,n){var i=t("@mapbox/mapbox-gl-sync-move"),o=t("events").EventEmitter;function r(t,e,n,i){this.options=i||{},this._mapA=t,this._mapB=e,this._horizontal="horizontal"===this.options.orientation,this._onDown=this._onDown.bind(this),this._onMove=this._onMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._ev=new o;var r=this;this._mapB._loaded||this._mapA._loaded?r._init(t,e,n,i):(r._timeout=setTimeout((function(){clearInterval(r._interval)}),1e4),r._interval=setInterval((function(){(r._mapB._loaded||r._mapA._loaded)&&(clearInterval(r._interval),clearTimeout(r._timeout),r._init(t,e,n,i))}),10))}r.prototype={_init:function(t,e,n,o){if(this._swiper=document.createElement("div"),this._swiper.className=this._horizontal?"compare-swiper-horizontal":"compare-swiper-vertical",this._controlContainer=document.createElement("div"),this._controlContainer.className=this._horizontal?"lkmap-compare lkmap-compare-horizontal":"lkmap-compare",this._controlContainer.className=this._controlContainer.className,this._controlContainer.appendChild(this._swiper),"string"==typeof n&&document.body.querySelectorAll){var r=document.body.querySelectorAll(n)[0];if(!r)throw new Error("Cannot find element with specified container selector.");r.appendChild(this._controlContainer)}else{if(!(n instanceof Element&&n.appendChild))throw new Error("Invalid container specified. Must be CSS selector or HTML element.");n.appendChild(this._controlContainer)}this._bounds=e.getContainer().getBoundingClientRect(),"number"==typeof this.options.position?this.swiperPosition=this.options.position:this.swiperPosition=(this._horizontal?this._bounds.height:this._bounds.width)/2,this._setPosition(this.swiperPosition),this._clearSync=i(t,e),this._onResize=function(){this._bounds=e.getContainer().getBoundingClientRect(),this.currentPosition&&this._setPosition(this.currentPosition)}.bind(this),e.on("resize",this._onResize),this.options&&this.options.mousemove&&(t.getContainer().addEventListener("mousemove",this._onMove),e.getContainer().addEventListener("mousemove",this._onMove)),this._swiper.addEventListener("mousedown",this._onDown),this._swiper.addEventListener("touchstart",this._onDown)},_setPointerEvents:function(t){this._controlContainer.style.pointerEvents=t,this._swiper.style.pointerEvents=t},reset:function(){this._setPosition(this.swiperPosition)},_onDown:function(t){t.touches?(document.addEventListener("touchmove",this._onMove),document.addEventListener("touchend",this._onTouchEnd)):(document.addEventListener("mousemove",this._onMove),document.addEventListener("mouseup",this._onMouseUp))},_setPosition:function(t){t=Math.min(t,this._horizontal?this._bounds.height:this._bounds.width);var e=this._horizontal?"translate(0, "+t+"px)":"translate("+t+"px, 0)";this._controlContainer.style.transform=e,this._controlContainer.style.WebkitTransform=e;var n=this._horizontal?"rect(0, 999em, "+t+"px, 0)":"rect(0, "+t+"px, "+this._bounds.height+"px, 0)",i=this._horizontal?"rect("+t+"px, 999em, "+this._bounds.height+"px,0)":"rect(0, 999em, "+this._bounds.height+"px,"+t+"px)";this._mapA.getContainer().style.clip=n,this._mapB.getContainer().style.clip=i,this.currentPosition=t},getPosition:function(){return this.currentPosition},_onMove:function(t){this.options&&this.options.mousemove&&this._setPointerEvents(t.touches?"auto":"none"),this._horizontal?this._setPosition(this._getY(t)):this._setPosition(this._getX(t)),this.fire("slide",{currentPosition:this.currentPosition})},_onMouseUp:function(){document.removeEventListener("mousemove",this._onMove),document.removeEventListener("mouseup",this._onMouseUp),this.fire("slideend",{currentPosition:this.currentPosition})},_onTouchEnd:function(){document.removeEventListener("touchmove",this._onMove),document.removeEventListener("touchend",this._onTouchEnd),this.fire("slideend",{currentPosition:this.currentPosition})},_getX:function(t){var e=(t=t.touches?t.touches[0]:t).clientX-this._bounds.left;return e<0&&(e=0),e>this._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},setSlider:function(t){this._setPosition(t)},setPosition: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},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.LKMap?LKMap.Compare=r:void 0!==e&&(e.exports=r)},{"@mapbox/mapbox-gl-sync-move":2,events:3}],2:[function(t,e,n){e.exports=function(){var t,e=arguments,n=arguments.length;if(1===n)t=arguments[0];else{t=[];for(var i=0;i<n;i++)t.push(e[i])}var o=[];function r(){t.forEach((function(t,e){t.on("move",o[e])}))}function s(){t.forEach((function(t,e){t.off("move",o[e])}))}return t.forEach((function(e,n){o[n]=function(t,e){s(),function(t,e){var n=t.getCenter(),i=t.getZoom(),o=t.getBearing(),r=t.getPitch();e.forEach((function(t){t.jumpTo({center:n,zoom:i,bearing:o,pitch:r})}))}(t,e),r()}.bind(null,e,t.filter((function(t,e){return e!==n})))})),r(),function(){s(),o=[]}}},{}],3:[function(t,e,n){var i=Object.create||function(t){function e(){}return e.prototype=t,new e},o=Object.keys||function(t){var e,n=[];for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&n.push(e);return e},r=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=i(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}((e.exports=s).EventEmitter=s).prototype._events=void 0,s.prototype._maxListeners=void 0;var u,h=10;try{var a={};Object.defineProperty&&Object.defineProperty(a,"x",{value:0}),u=0===a.x}catch(t){u=!1}function c(t){return void 0===t._maxListeners?s.defaultMaxListeners:t._maxListeners}function l(t,e,n,o){var r,s,u,h;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');return(r=t._events)?(r.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),r=t._events),s=r[e]):(r=t._events=i(null),t._eventsCount=0),s?("function"==typeof s?s=r[e]=o?[n,s]:[s,n]:o?s.unshift(n):s.push(n),s.warned||(h=c(t))&&0<h&&s.length>h&&(s.warned=!0,(u=new Error("Possible EventEmitter memory leak detected. "+s.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.')).name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,"object"==typeof console&&console.warn)):(s=r[e]=n,++t._eventsCount),t}function p(){var t=arguments;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),n=0;n<e.length;++n)e[n]=t[n];this.listener.apply(this.target,e)}}function f(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},o=r.call(p,i);return o.listener=n,i.wrapFn=o}function d(t,e,n){var i=t._events;if(!i)return[];var o=i[e];return o?"function"==typeof o?n?[o.listener||o]:[o]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(o):v(o,o.length):[]}function m(t){var e=this._events;if(e){var n=e[t];if("function"==typeof n)return 1;if(n)return n.length}return 0}function v(t,e){for(var n=new Array(e),i=0;i<e;++i)n[i]=t[i];return n}u?Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return h},set:function(t){if("number"!=typeof t||t<0||t!=t)throw new TypeError('"defaultMaxListeners" must be a positive number');h=t}}):s.defaultMaxListeners=h,s.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},s.prototype.getMaxListeners=function(){return c(this)},s.prototype.emit=function(t,e,n,i){var o,r,s,u,h=arguments,a="error"===t,c=this._events;if(c)a=a&&null==c.error;else if(!a)return!1;if(a){if(1<arguments.length&&(o=e),o instanceof Error)throw o;var l=new Error('Unhandled "error" event. ('+o+")");throw l.context=o,l}if(!(r=c[t]))return!1;var p,f="function"==typeof r;switch(p=arguments.length){case 1:!function(t,e,n){if(e)t.call(n);else for(var i=t.length,o=v(t,i),r=0;r<i;++r)o[r].call(n)}(r,f,this);break;case 2:!function(t,e,n,i){if(e)t.call(n,i);else for(var o=t.length,r=v(t,o),s=0;s<o;++s)r[s].call(n,i)}(r,f,this,e);break;case 3:!function(t,e,n,i,o){if(e)t.call(n,i,o);else for(var r=t.length,s=v(t,r),u=0;u<r;++u)s[u].call(n,i,o)}(r,f,this,e,n);break;case 4:!function(t,e,n,i,o,r){if(e)t.call(n,i,o,r);else for(var s=t.length,u=v(t,s),h=0;h<s;++h)u[h].call(n,i,o,r)}(r,f,this,e,n,i);break;default:for(s=new Array(p-1),u=1;u<p;u++)s[u-1]=h[u];!function(t,e,n,i){if(e)t.apply(n,i);else for(var o=t.length,r=v(t,o),s=0;s<o;++s)r[s].apply(n,i)}(r,f,this,s)}return!0},s.prototype.on=s.prototype.addListener=function(t,e){return l(this,t,e,!1)},s.prototype.prependListener=function(t,e){return l(this,t,e,!0)},s.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.on(t,f(this,t,e)),this},s.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.prependListener(t,f(this,t,e)),this},s.prototype.removeListener=function(t,e){var n,o,r,s,u;if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');if(!(o=this._events))return this;if(!(n=o[t]))return this;if(n===e||n.listener===e)0==--this._eventsCount?this._events=i(null):(delete o[t],o.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(r=-1,s=n.length-1;0<=s;s--)if(n[s]===e||n[s].listener===e){u=n[s].listener,r=s;break}if(r<0)return this;0===r?n.shift():function(t,e){for(var n=e,i=n+1,o=t.length;i<o;n+=1,i+=1)t[n]=t[i];t.pop()}(n,r),1===n.length&&(o[t]=n[0]),o.removeListener&&this.emit("removeListener",t,u||e)}return this},s.prototype.removeAllListeners=function(t){var e,n=this._events;if(!n)return this;if(!n.removeListener)return 0===arguments.length?(this._events=i(null),this._eventsCount=0):n[t]&&(0==--this._eventsCount?this._events=i(null):delete n[t]),this;if(0===arguments.length){for(var r,s=o(n),u=0;u<s.length;++u)"removeListener"!==(r=s[u])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=i(null),this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(e)for(u=e.length-1;0<=u;u--)this.removeListener(t,e[u]);return this},s.prototype.listeners=function(t){return d(this,t,!0)},s.prototype.rawListeners=function(t){return d(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},s.prototype.listenerCount=m,s.prototype.eventNames=function(){return 0<this._eventsCount?Reflect.ownKeys(this._events):[]}},{}]},{},[1])}));