UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.98 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{createTask as o}from"../../core/asyncUtils.js";import{makeHandle as i}from"../../core/handleUtils.js";import"../../core/has.js";import{abortMaybe as s}from"../../core/maybe.js";import{throwIfAborted as a}from"../../core/promiseUtils.js";import{watch as r,syncAndInitial as n}from"../../core/reactiveUtils.js";import{createScreenPoint as d}from"../../core/screenUtils.js";import{throttle as c}from"../../core/throttle.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";var m;!function(t){t.PointerMove="pointer-move",t.Main="main"}(m||(m={}));const u=300;let p=class extends e{constructor(t){super(t),this._screenPoint=null,this._accumulatedShadowTime=null,this._shadowTimeTask=null,this._updateAccumulatedShadowTime=(t,e)=>{this._shadowTimeTask=s(this._shadowTimeTask),this._shadowTimeTask=o((async o=>{const{results:i,ground:s}=await t.hitTest(e);if(a(o),0===i.length&&!s.mapPoint)return void(this._accumulatedShadowTime=null);const r=await this.getDuration(e,o);this._accumulatedShadowTime=r}))},this._throttledUpdateAccumulatedShadowTime=c(this._updateAccumulatedShadowTime,u)}initialize(){this.addHandles(r((()=>({enabled:this.enabled,view:this.view})),(({enabled:t,view:e})=>{t&&null!=e?this._startTracking(e):this._stopTracking()}),n))}get screenPoint(){return this.enabled?this._screenPoint:null}get accumulatedShadowTime(){return this.enabled?this._accumulatedShadowTime:null}get testData(){}_startTracking(t){if(this.hasHandles(m.Main))return;const e=()=>{this.hasHandles(m.PointerMove)||this.addHandles(t.on("pointer-move",(e=>{const o=d(e.x,e.y);this._screenPoint=o,this._throttledUpdateAccumulatedShadowTime(t,o)})),m.PointerMove)},o=()=>{this.removeHandles(m.PointerMove),this._screenPoint=null,this._accumulatedShadowTime=null};this.addHandles([this._throttledUpdateAccumulatedShadowTime,t.on("pointer-enter",e),t.on("pointer-leave",o),t.on("pointer-down",o),t.on("pointer-drag",o),t.on("pointer-up",e),t.on("click",(e=>{const o=d(e.x,e.y);this._screenPoint=o,this._updateAccumulatedShadowTime(t,o)})),i((()=>{this._shadowTimeTask=s(this._shadowTimeTask)}))],m.Main),e()}_stopTracking(){this.removeHandles(m.Main)}};t([h()],p.prototype,"getDuration",void 0),t([h()],p.prototype,"view",void 0),t([h()],p.prototype,"enabled",void 0),t([h()],p.prototype,"screenPoint",null),t([h()],p.prototype,"accumulatedShadowTime",null),t([h()],p.prototype,"_screenPoint",void 0),t([h()],p.prototype,"_accumulatedShadowTime",void 0),t([h()],p.prototype,"_shadowTimeTask",void 0),p=t([l("esri.widgets.ShadowCast.ShadowTooltipViewModel")],p);export{p as ShadowTooltipViewModel};