UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 2.13 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import{watch as i,sync as o}from"../../core/reactiveUtils.js";import{property as s,subclass as r}from"../../core/accessorSupport/decorators.js";import{set as p,subtract as d,copy as n}from"../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{addPadding as c}from"./viewpointUtils.js";import h from"./ViewState.js";var l,g;let m=l=class extends e{constructor(){super(...arguments),this.left=0,this.top=0,this.right=0,this.bottom=0}clone(){return new l({left:this.left,top:this.top,right:this.right,bottom:this.bottom})}};t([s()],m.prototype,"left",void 0),t([s()],m.prototype,"top",void 0),t([s()],m.prototype,"right",void 0),t([s()],m.prototype,"bottom",void 0),m=l=t([r("esri.views.2d.PaddedViewState.Padding")],m);let w=g=class extends h{constructor(...t){super(...t),this.paddedViewState=new h,this._updateContent=(()=>{const t=a();return()=>{const e=this._get("size"),i=this._get("padding");if(!e||!i)return;const o=this.paddedViewState;p(t,i.left+i.right,i.top+i.bottom),d(t,e,t),n(o.size,t);const s=o.viewpoint;s&&(this.viewpoint=s)}})(),this.addHandles(i(()=>[this.size,this.padding],()=>this._updateContent(),o)),this.padding=new m,this.size=[0,0]}get padding(){return this._get("padding")}set padding(t){this._set("padding",t||new m)}set viewpoint(t){if(t){this.paddedViewState.viewpoint=t;let e=t;const i=this._get("padding");i&&(e=c(t.clone(),t,this._get("size"),i));const{targetGeometry:o,rotation:s,scale:r}=e,{x:p,y:d,spatialReference:n}=o,a=this._viewpoint2D;a.center[0]=p,a.center[1]=d,a.rotation=s,a.scale=r,a.spatialReference=n,this._update()}}clone(){return new g({padding:this.padding.clone(),size:this.size.slice(),viewpoint:this.paddedViewState.viewpoint.clone(),pixelRatio:this.pixelRatio})}};t([s()],w.prototype,"paddedViewState",void 0),t([s({type:m})],w.prototype,"padding",null),t([s()],w.prototype,"viewpoint",null),w=g=t([r("esri.views.2d.PaddedViewState")],w);const f=w;export{f as default};