UNPKG

wise-map

Version:

一款基于WebGL技术实现的三维地球客户端开发平台 wise-map

1 lines 9 kB
(("undefined"!=typeof self?self:this).webpackJsonp_WebGis=("undefined"!=typeof self?self:this).webpackJsonp_WebGis||[]).push([[1],{"08a9":function(e,t,n){"use strict";n.r(t);var i=n("5530"),o=(n("a9e3"),n("99af"),n("b64b"),n("07ac"),n("b680"),n("526f")),a=n("8bbf"),s=n.n(a);let l=e=>{return e&&"[object Function]"==={}.toString.call(e)};"object"==typeof Int8Array||!s.a.prototype.$isServer&&document.childNodes;Object.prototype.hasOwnProperty;function r(e){let t=!1;return function(...n){t||(t=!0,window.requestAnimationFrame(i=>{e.apply(this,n),t=!1}))}}let c,d=!1,u=!1;const f=function(){if(s.a.prototype.$isServer)return;let e=m.modalDom;return e?d=!0:(d=!1,e=document.createElement("div"),m.modalDom=e,e.addEventListener("touchmove",function(e){e.preventDefault(),e.stopPropagation()}),e.addEventListener("click",function(){m.doOnModalClick&&m.doOnModalClick()})),e},h={},m={modalFade:!0,getInstance:function(e){return h[e]},register:function(e,t){e&&t&&(h[e]=t)},deregister:function(e){e&&(h[e]=null,delete h[e])},nextZIndex:function(){return m.zIndex++},modalStack:[],doOnModalClick:function(){const e=m.modalStack[m.modalStack.length-1];if(!e)return;const t=m.getInstance(e.id);t&&t.closeOnClickModal&&t.close()},openModal:function(e,t,n,i,a){if(s.a.prototype.$isServer)return;if(!e||void 0===t)return;this.modalFade=a;const l=this.modalStack;for(let t=0,n=l.length;t<n;t++){if(l[t].id===e)return}const r=f();if(Object(o.a)(r,"v-modal"),this.modalFade&&!d&&Object(o.a)(r,"v-modal-enter"),i){i.trim().split(/\s+/).forEach(e=>Object(o.a)(r,e))}setTimeout(()=>{Object(o.g)(r,"v-modal-enter")},200),n&&n.parentNode&&11!==n.parentNode.nodeType?n.parentNode.appendChild(r):document.body.appendChild(r),t&&(r.style.zIndex=t),r.tabIndex=0,r.style.display="",this.modalStack.push({id:e,zIndex:t,modalClass:i})},closeModal:function(e){const t=this.modalStack,n=f();if(t.length>0){const i=t[t.length-1];if(i.id===e){if(i.modalClass){i.modalClass.trim().split(/\s+/).forEach(e=>Object(o.g)(n,e))}t.pop(),t.length>0&&(n.style.zIndex=t[t.length-1].zIndex)}else for(let n=t.length-1;n>=0;n--)if(t[n].id===e){t.splice(n,1);break}}0===t.length&&(this.modalFade&&Object(o.a)(n,"v-modal-leave"),setTimeout(()=>{0===t.length&&(n.parentNode&&n.parentNode.removeChild(n),n.style.display="none",m.modalDom=void 0),Object(o.g)(n,"v-modal-leave")},200))}};Object.defineProperty(m,"zIndex",{configurable:!0,get:()=>(u||(c=c||(s.a.prototype.$ELEMENT||{}).zIndex||2e3,u=!0),c),set(e){c=e}});s.a.prototype.$isServer||window.addEventListener("keydown",function(e){if(27===e.keyCode){const e=function(){if(!s.a.prototype.$isServer&&m.modalStack.length>0){const e=m.modalStack[m.modalStack.length-1];if(!e)return;return m.getInstance(e.id)}}();e&&e.closeOnPressEscape&&(e.handleClose?e.handleClose():e.handleAction?e.handleAction("cancel"):e.close())}});var p=m;Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;var g={CONTAIN:{name:"contain",icon:"el-icon-full-screen"},ORIGINAL:{name:"original",icon:"el-icon-c-scale-to-original"}},v=!s.a.prototype.$isServer&&window.navigator.userAgent.match(/firefox/i)?"DOMMouseScroll":"mousewheel",b={name:"elImageViewer",props:{urlList:{type:Array,default:function(){return[]}},zIndex:{type:Number,default:2e3},onSwitch:{type:Function,default:function(){}},onClose:{type:Function,default:function(){}},initialIndex:{type:Number,default:0},appendToBody:{type:Boolean,default:!0},maskClosable:{type:Boolean,default:!0}},data:function(){return{index:this.initialIndex,isShow:!1,infinite:!0,loading:!1,mode:g.CONTAIN,transform:{scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}}},computed:{isSingle:function(){return this.urlList.length<=1},isFirst:function(){return 0===this.index},isLast:function(){return this.index===this.urlList.length-1},currentImg:function(){return this.urlList[this.index]},imgStyle:function(){var e=this.transform,t=e.scale,n=e.deg,i=e.offsetX,o=e.offsetY,a=e.enableTransition,s={transform:"scale(".concat(t,") rotate(").concat(n,"deg)"),transition:a?"transform .3s":"","margin-left":"".concat(i,"px"),"margin-top":"".concat(o,"px")};return this.mode===g.CONTAIN&&(s.maxWidth=s.maxHeight="100%"),s},viewerZIndex:function(){var e=p.nextZIndex();return this.zIndex>e?this.zIndex:e}},watch:{index:{handler:function(e){this.reset(),this.onSwitch(e)}},currentImg:function(e){var t=this;this.$nextTick(function(e){t.$refs.img[0].complete||(t.loading=!0)})}},methods:{hide:function(){this.deviceSupportUninstall(),this.onClose()},deviceSupportInstall:function(){var e=this;this._keyDownHandler=function(t){switch(t.stopPropagation(),t.keyCode){case 27:e.hide();break;case 32:e.toggleMode();break;case 37:e.prev();break;case 38:e.handleActions("zoomIn");break;case 39:e.next();break;case 40:e.handleActions("zoomOut")}},this._mouseWheelHandler=r(function(t){(t.wheelDelta?t.wheelDelta:-t.detail)>0?e.handleActions("zoomIn",{zoomRate:.015,enableTransition:!1}):e.handleActions("zoomOut",{zoomRate:.015,enableTransition:!1})}),Object(o.e)(document,"keydown",this._keyDownHandler),Object(o.e)(document,v,this._mouseWheelHandler)},deviceSupportUninstall:function(){Object(o.d)(document,"keydown",this._keyDownHandler),Object(o.d)(document,v,this._mouseWheelHandler),this._keyDownHandler=null,this._mouseWheelHandler=null},handleImgLoad:function(e){this.loading=!1},handleImgError:function(e){this.loading=!1,e.target.alt="加载失败"},handleMouseDown:function(e){var t=this;if(!this.loading&&0===e.button){var n=this.transform,i=n.offsetX,a=n.offsetY,s=e.pageX,l=e.pageY;this._dragHandler=r(function(e){t.transform.offsetX=i+e.pageX-s,t.transform.offsetY=a+e.pageY-l}),Object(o.e)(document,"mousemove",this._dragHandler),Object(o.e)(document,"mouseup",function(e){Object(o.d)(document,"mousemove",t._dragHandler)}),e.preventDefault()}},handleMaskClick:function(){this.maskClosable&&this.hide()},reset:function(){this.transform={scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}},toggleMode:function(){if(!this.loading){var e=Object.keys(g),t=(Object.values(g).indexOf(this.mode)+1)%e.length;this.mode=g[e[t]],this.reset()}},prev:function(){if(!this.isFirst||this.infinite){var e=this.urlList.length;this.index=(this.index-1+e)%e}},next:function(){if(!this.isLast||this.infinite){var e=this.urlList.length;this.index=(this.index+1)%e}},handleActions:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.loading){var n=Object(i.a)({zoomRate:.2,rotateDeg:90,enableTransition:!0},t),o=n.zoomRate,a=n.rotateDeg,s=n.enableTransition,l=this.transform;switch(e){case"zoomOut":l.scale>.2&&(l.scale=parseFloat((l.scale-o).toFixed(3)));break;case"zoomIn":l.scale=parseFloat((l.scale+o).toFixed(3));break;case"clocelise":l.deg+=a;break;case"anticlocelise":l.deg-=a}l.enableTransition=s}}},mounted:function(){this.deviceSupportInstall(),this.appendToBody&&document.body.appendChild(this.$el),this.$refs["el-image-viewer__wrapper"].focus()},destroyed:function(){this.appendToBody&&this.$el&&this.$el.parentNode&&this.$el.parentNode.removeChild(this.$el)}},_=n("2877"),w=Object(_.a)(b,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("transition",{attrs:{name:"viewer-fade"}},[n("div",{ref:"el-image-viewer__wrapper",staticClass:"el-image-viewer__wrapper",style:{"z-index":e.viewerZIndex},attrs:{tabindex:"-1"}},[n("div",{staticClass:"el-image-viewer__mask",on:{click:function(t){return t.target!==t.currentTarget?null:e.handleMaskClick.apply(null,arguments)}}}),n("span",{staticClass:"el-image-viewer__btn el-image-viewer__close",on:{click:e.hide}},[n("i",{staticClass:"el-icon-close"})]),e.isSingle?e._e():[n("span",{staticClass:"el-image-viewer__btn el-image-viewer__prev",class:{"is-disabled":!e.infinite&&e.isFirst},on:{click:e.prev}},[n("i",{staticClass:"el-icon-arrow-left"})]),n("span",{staticClass:"el-image-viewer__btn el-image-viewer__next",class:{"is-disabled":!e.infinite&&e.isLast},on:{click:e.next}},[n("i",{staticClass:"el-icon-arrow-right"})])],n("div",{staticClass:"el-image-viewer__btn el-image-viewer__actions"},[n("div",{staticClass:"el-image-viewer__actions__inner"},[n("i",{staticClass:"el-icon-zoom-out",on:{click:function(t){return e.handleActions("zoomOut")}}}),n("i",{staticClass:"el-icon-zoom-in",on:{click:function(t){return e.handleActions("zoomIn")}}}),n("i",{staticClass:"el-image-viewer__actions__divider"}),n("i",{class:e.mode.icon,on:{click:e.toggleMode}}),n("i",{staticClass:"el-image-viewer__actions__divider"}),n("i",{staticClass:"el-icon-refresh-left",on:{click:function(t){return e.handleActions("anticlocelise")}}}),n("i",{staticClass:"el-icon-refresh-right",on:{click:function(t){return e.handleActions("clocelise")}}})])]),n("div",{staticClass:"el-image-viewer__canvas"},e._l(e.urlList,function(t,i){return i===e.index?n("img",{key:t,ref:"img",refInFor:!0,staticClass:"el-image-viewer__img",style:e.imgStyle,attrs:{src:e.currentImg},on:{load:e.handleImgLoad,error:e.handleImgError,mousedown:e.handleMouseDown}}):e._e()}),0)],2)])},[],!1,null,null,null);t.default=w.exports}}]);