PaddedViewState.js 2.2 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.25/esri/copyright.txt for details.
  4. */
  5. import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{watch as i,sync as o}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import{s as p,a,c as n}from"../../chunks/vec2.js";import{a as d}from"../../chunks/vec2f64.js";import{addPadding as c}from"./viewpointUtils.js";import h from"./ViewState.js";var l,m;let w=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()],w.prototype,"left",void 0),t([s()],w.prototype,"top",void 0),t([s()],w.prototype,"right",void 0),t([s()],w.prototype,"bottom",void 0),w=l=t([r("esri.views.2d.PaddedViewState.Padding")],w);let u=m=class extends h{constructor(...t){super(...t),this.paddedViewState=new h,this._updateContent=(()=>{const t=d();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),a(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 w,this.size=[0,0]}set padding(t){this._set("padding",t||new w)}set viewpoint(t){if(t){const e=t.clone();this.paddedViewState.viewpoint=t,c(e,t,this._get("size"),this._get("padding"));const i=this._viewpoint2D,o=e.targetGeometry;i.center[0]=o.x,i.center[1]=o.y,i.rotation=e.rotation,i.scale=e.scale,i.spatialReference=o.spatialReference,this._update()}}clone(){return new m({padding:this.padding.clone(),size:this.size.slice(),viewpoint:this.paddedViewState.viewpoint.clone(),pixelRatio:this.pixelRatio})}};t([s()],u.prototype,"paddedViewState",void 0),t([s({type:w})],u.prototype,"padding",null),t([s()],u.prototype,"viewpoint",null),u=m=t([r("esri.views.2d.PaddedViewState")],u);const f=u;export{f as default};