UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 1.54 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import s from"../../../../core/Collection.js";import{property as o,subclass as r}from"../../../../core/accessorSupport/decorators.js";let i=class extends t{constructor(){super(...arguments),this.measuredElement=null,this.managedElements=new s,this.availableLength=0,this.layout="horizontal",this._resizeObserver=new ResizeObserver(()=>{this._measure()})}get _sortedElements(){return[...this.managedElements].sort((e,t)=>t.priority-e.priority)}connect(e){this._resizeObserver.disconnect(),this.measuredElement=e,this._resizeObserver.observe(e),this._measure()}allocate(){const e=new Map,{availableLength:t,_sortedElements:s}=this;let o=0;for(const r of s){const t=r.lengthOptions[0];e.set(r,t),o+=t}for(const r of s)for(;o<t;){const s=e.get(r);if(!s)break;const i=r.lengthOptions.find(e=>e>s);if(!i)break;const n=o-s+i;if(n>t)break;e.set(r,i),o=n}for(const[r,i]of e)r.budgetedLength=i}_measure(){const e=this.measuredElement;this.availableLength=e?"horizontal"===this.layout?e.clientWidth??0:e.clientHeight??0:0,this.allocate()}destroy(){this._resizeObserver.disconnect()}};e([o()],i.prototype,"measuredElement",void 0),e([o()],i.prototype,"managedElements",void 0),e([o()],i.prototype,"_sortedElements",null),e([o()],i.prototype,"availableLength",void 0),e([o()],i.prototype,"layout",void 0),i=e([r("esri.widgets.Sketch.support.ResponsiveToolbar.ResponsiveToolbarManager")],i);export{i as default};