12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{_ as o}from"../../chunks/tslib.es6.js";import t from"../../Viewpoint.js";import e from"../../core/Error.js";import i from"../../core/Evented.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{GoToMixin as n}from"../support/GoTo.js";let l=class extends(n(i.EventedAccessor)){constructor(o){super(o),this._initialViewpoint=null,this._goingHomeController=null,this.go=this.go.bind(this)}destroy(){this._cancelGo(),this.view=null}get state(){return this.get("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.get("view.ready"))throw new e("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([r()],l.prototype,"_goingHomeController",void 0),o([r({readOnly:!0})],l.prototype,"state",null),o([r()],l.prototype,"view",null),o([r({type:t})],l.prototype,"viewpoint",null),o([r()],l.prototype,"go",null),o([r()],l.prototype,"cancelGo",null),l=o([s("esri.widgets.Home.HomeViewModel")],l);const p=l;export{p as default};
|