@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.26 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{_ as i}from"../chunks/tslib.es6.js";import{after as e}from"../core/promiseUtils.js";import{watch as t}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";import r from"./Widget.js";import n from"./Spinner/SpinnerViewModel.js";import"./support/widgetUtils.js";import{tsx as l}from"./support/jsxFactory.js";const a="esri-spinner",c={base:a,spinnerStart:`${a}--start`,spinnerFinish:`${a}--finish`};let p=class extends r{constructor(i,e){super(i,e),this._animationDelay=500,this._animationPromise=null,this.viewModel=new n}initialize(){this.addHandles(t((()=>this.visible),(i=>this._visibleChange(i))))}destroy(){this._animationPromise=null}get location(){return this.viewModel.location}set location(i){this.viewModel.location=i}get view(){return this.viewModel.view}set view(i){this.viewModel.view=i}get visible(){return this.viewModel.visible}set visible(i){this.viewModel.visible=i}show(i){const{location:e,promise:t}=i??{};e&&(this.viewModel.location=e),this.visible=!0;const s=()=>this.hide();t&&t.catch((()=>{})).then(s)}hide(){this.visible=!1}render(){const{visible:i}=this,{screenLocation:e}=this.viewModel,t=!!e,s=i&&t,o=!i&&t,r={[c.spinnerStart]:s,[c.spinnerFinish]:o},n=this._getPositionStyles();return l("div",{class:this.classes(c.base,r),styles:n})}_visibleChange(i){if(i)return void(this.viewModel.screenLocationEnabled=!0);const t=e(this._animationDelay);this._animationPromise=t,t.catch((()=>{})).then((()=>{this._animationPromise===t&&(this.viewModel.screenLocationEnabled=!1,this._animationPromise=null)}))}_getPositionStyles(){const{screenLocation:i,view:e}=this.viewModel;if(null==e||null==i)return{};const{padding:t}=e;return{left:i.x-t.left+"px",top:i.y-t.top+"px"}}};i([s()],p.prototype,"location",null),i([s()],p.prototype,"view",null),i([s({type:n})],p.prototype,"viewModel",void 0),i([s()],p.prototype,"visible",null),p=i([o("esri.widgets.Spinner")],p);export{p as default};