UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 1.95 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as o}from"tslib";import t from"../../Viewpoint.js";import{deprecateUnnecessaryViewModel as e}from"../../core/deprecate.js";import i from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import n from"../../core/Logger.js";import{property as s,subclass as l}from"../../core/accessorSupport/decorators.js";import{GoTo as p}from"../support/GoTo.js";let a=class extends(p(r)){constructor(o){super(o),this._initialViewpoint=null,this._goingHomeController=null,this.go=this.go.bind(this),o?.suppressDeprecationWarning||e(n.getLogger(this),"Home","arcgis-home",{version:"5.0"})}normalizeCtorArgs(o){const{suppressDeprecationWarning:t,...e}=o??{};return e}destroy(){this._cancelGo(),this.view=null}get state(){return this.view?.ready?this._goingHomeController?"going-home":"ready":"disabled"}set view(o){this._initialViewpoint=null,this._set("view",o),o&&o.when().then(()=>{this.view===o&&(this._initialViewpoint=o.viewpoint.clone(),this.notifyChange("viewpoint"))})}get viewpoint(){return this._get("viewpoint")||this._initialViewpoint}set viewpoint(o){this._set("viewpoint",o)}async go(){if(!this.view?.ready)throw new i("home:disabled-state","Cannot go when disabled.");this._cancelGo(),this.emit("go");const o=new AbortController;this._goingHomeController=o;try{await(this.view?.when()),await this.callGoTo({target:this.viewpoint,options:{signal:o.signal}})}catch(t){}this._goingHomeController=null}cancelGo(){this._cancelGo()}_cancelGo(){const{_goingHomeController:o}=this;o&&o.abort(),this._goingHomeController=null}};o([s()],a.prototype,"_goingHomeController",void 0),o([s({readOnly:!0})],a.prototype,"state",null),o([s()],a.prototype,"view",null),o([s({type:t})],a.prototype,"viewpoint",null),o([s()],a.prototype,"go",null),o([s()],a.prototype,"cancelGo",null),a=o([l("esri.widgets.Home.HomeViewModel")],a);const g=a;export{g as default};