@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.83 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import s from"../../../../core/Collection.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.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};