UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.26 kB
import{_ as e}from"../../../chunks/tslib.es6.js";import o from"../../../core/Accessor.js";import t from"../../../core/Collection.js";import{applySome as r}from"../../../core/maybe.js";import{watch as s,syncAndInitial as i}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{getConfig as d}from"./constants.js";import a from"../../support/AnchorElementViewModel.js";let p=class extends o{constructor(e){super(e),this._hoveredPoints=new t}initialize(){this.addHandles(s((()=>this._hoveredPoints.toArray().map((({anchor:e,element:o})=>({screenLocation:e.screenLocation,element:o})))),(e=>{for(const{screenLocation:o,element:t}of e)r(o,(({x:e,y:o})=>{t.style.transform=`translate(${e}px, ${o}px)`}))}),i))}destroy(){this._hoveredPoints.drain((e=>this._destroyHoveredPoint(e)))}update(e){const o=this.view,t=this._hoveredPoints,r=e.length;for(;this._hoveredPoints.length>r;)this._destroyHoveredPoint(this._hoveredPoints.pop());for(;this._hoveredPoints.length<r;){const e=this._makeHoveredPoint();t.push(e),o.surface?.appendChild(e.element)}for(let s=0;s<r;++s){const o=t.getItemAt(r-1-s),i=e[s];this._updateHoveredPoint(o,i)}}_makeHoveredPoint(){const{size:e,borderStyle:o,borderColor:t,borderWidth:r,boxShadow:s}=d().hoveredPointsStyle,i=this.view,n=new a({view:i,screenLocationEnabled:!0}),c=document.createElement("div"),p=c.style;return p.position="absolute",p.top="0",p.left="0",p.contain="strict",p.boxSizing="border-box",p.width=`${e}px`,p.height=`${e}px`,p.marginTop=`-${e/2}px`,p.marginLeft=`-${e/2}px`,p.border=`${o} ${r}px ${t}`,p.borderRadius=`${e}px`,p.boxShadow=s,{anchor:n,element:c}}_updateHoveredPoint({anchor:e,element:o},t){e.screenLocationEnabled=!0,e.location=t.hoveredPoint;const r=o.style;r.display="block",r.background=t.color.toCss()}_destroyHoveredPoint({anchor:e,element:o}){e.destroy(),this.view.surface?.removeChild(o)}};e([n()],p.prototype,"view",void 0),e([n()],p.prototype,"_hoveredPoints",void 0),p=e([c("esri.widgets.ElevationProfile.support.HoveredPoints")],p);export{p as HoveredPoints};