Bläddra i källkod

添加加载蒙层组件

tags/1.16.0
Caven Chen 4 år sedan
förälder
incheckning
975f337671
4 ändrade filer med 25 tillägg och 47 borttagningar
  1. 20
    41
      src/core/widget/LoadingMask.js
  2. 1
    1
      src/core/widget/index.js
  3. 1
    1
      src/themes/index.js
  4. 3
    4
      src/themes/loading-mask.scss

+ 20
- 41
src/core/widget/LoadingMask.js Visa fil

* @Author: Liquid * @Author: Liquid
* @Date: 2021-03-02 13:38:48 * @Date: 2021-03-02 13:38:48
*/ */

import { DomUtil } from '../utils' import { DomUtil } from '../utils'
import State from '../state/State' import State from '../state/State'
import Widget from './Widget' import Widget from './Widget'


class LoadlingModule extends Widget {
class LoadingMask extends Widget {
constructor() { constructor() {
super() super()
this._wrapper = DomUtil.create(
'div',
'loading-container'
)
this.type = Widget.getWidgetType('loadlingMask')
this._wrapper = DomUtil.create('div', 'dc-loading-container')
this.type = Widget.getWidgetType('loading_mask')
this._state = State.INITIALIZED this._state = State.INITIALIZED
this.addLoading()
} }


/** /**
* @private * @private
*/ */
_installHook() { _installHook() {
Object.defineProperty(this._viewer, 'loadlingMask', {
Object.defineProperty(this._viewer, 'loadingMask', {
value: this, value: this,
writable: false writable: false
}) })
} }


set enable(enable) {
if (this._enable === enable) {
return this
}
enable ? this.show() : this.hide()
this._enable = enable
this._state = this._enable ? State.ENABLED : State.DISABLED
this._enableHook && this._enableHook()
return this
}

_enableHook() {
!this._wrapper.parentNode &&
this._viewer &&
this._viewer.dcContainer.appendChild(this._wrapper)
}

addLoading() {
let htmlStr = `
<div class="loading">
/**
*
* @private
*/
_mountContent() {
let el = DomUtil.parseDom(
`
<span></span> <span></span>
<span></span> <span></span>
<span></span> <span></span>
<span></span> <span></span>
<span></span> <span></span>
</div>
`;
this._wrapper.innerHTML = htmlStr
}

show() {
this._wrapper.style.visibility = 'visible'
}

hide() {
this._wrapper.style.visibility = 'hidden'
`,
true,
'loading'
)
this._wrapper.appendChild(el)
this._ready = true
} }
} }


Widget.registerType('loadlingMask')
Widget.registerType('loading_mask')


export default LoadlingModule
export default LoadingMask

+ 1
- 1
src/core/widget/index.js Visa fil

compass: new Compass(), compass: new Compass(),
distanceLegend: new DistanceLegend(), distanceLegend: new DistanceLegend(),
zoomController: new ZoomController(), zoomController: new ZoomController(),
loadlingMask: new LoadingMask()
loadingMask: new LoadingMask()
} }
} }

+ 1
- 1
src/themes/index.js Visa fil

import './locationbar.scss' import './locationbar.scss'
import './distancelegend.scss' import './distancelegend.scss'
import './zoom-controller.scss' import './zoom-controller.scss'
import './loading.scss'
import './loading-mask.scss'

src/themes/loading.scss → src/themes/loading-mask.scss Visa fil

.loading-container {
.dc-loading-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
position: absolute; position: absolute;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
visibility: hidden;
background: rgba(181, 181, 181, 0.6);
background: rgba(0,0,0,0.6);


.loading { .loading {
width: 150px; width: 150px;
} }


.loading span:last-child { .loading span:last-child {
margin-right: 0px;
margin-right: 0;
} }


@-webkit-keyframes load { @-webkit-keyframes load {

Laddar…
Avbryt
Spara