@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.67 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 t}from"../../../../chunks/tslib.es6.js";import i from"../../../../Viewpoint.js";import o from"../../../../core/Accessor.js";import{when as e}from"../../../../core/reactiveUtils.js";import{createScreenPointArray as s}from"../../../../core/screenUtils.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{g as r}from"../../../../chunks/vec32.js";import{create as a,fromValues as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import c from"../../../../geometry/Point.js";import{translateBy as u}from"../../viewpointUtils.js";import{PanPlanarMomentumEstimator as h}from"../../../navigation/PanPlanarMomentumEstimator.js";let v=class extends o{constructor(t){super(t),this.animationTime=0,this.momentumEstimator=new h(500,6,.92),this.momentum=null,this.tmpMomentum=a(),this.momentumFinished=!1,this.viewpoint=new i({targetGeometry:new c,scale:0,rotation:0}),this._previousDrag=null,e((()=>this.momentumFinished),(()=>this.navigation.stop()))}begin(t,i){this.navigation.begin(),this.momentumEstimator.reset(),this.addToEstimator(i),this._previousDrag=i}update(t,i){this.addToEstimator(i);let o=i.center.x,e=i.center.y;const s=this._previousDrag;o=s?s.center.x-o:-o,e=s?e-s.center.y:e,t.viewpoint=u(this.viewpoint,t.viewpoint,[o||0,e||0]),this._previousDrag=i}end(t,i){this.addToEstimator(i);const o=t.navigation.effectiveMomentumEnabled;this.momentum=o?this.momentumEstimator.evaluateMomentum():null,this.animationTime=0,this.momentum&&this.onAnimationUpdate(t),this._previousDrag=null,this.navigation.end()}addToEstimator(t){const i=t.center.x,o=t.center.y,e=s(-i,o),m=p(-i,o,0);this.momentumEstimator.add(e,m,.001*t.timestamp)}onAnimationUpdate(t){this.navigation.animationManager?.animateContinuous(t.viewpoint,((i,o)=>{const{momentum:e,animationTime:s,tmpMomentum:m}=this,n=.001*o;if(!(this.momentumFinished=!e||e.isFinished(s))){const o=e.valueDelta(s,n);r(m,e.direction,o),u(i,i,m),t.constraints.constrainByGeometry(i)}this.animationTime+=n}))}stopMomentumNavigation(){this.momentum&&(this.momentumEstimator.reset(),this.momentum=null,this.navigation.stop())}};t([m()],v.prototype,"momentumFinished",void 0),t([m()],v.prototype,"viewpoint",void 0),t([m()],v.prototype,"navigation",void 0),v=t([n("esri.views.2d.navigation.actions.Pan")],v);export{v as default};