@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 2.59 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */
import{__decorate as t}from"tslib";import i from"../../../../Viewpoint.js";import{prefersReducedMotion as o}from"../../../../core/a11yUtils.js";import e from"../../../../core/Accessor.js";import{when as m}from"../../../../core/reactiveUtils.js";import{createScreenPointArray as n}from"../../../../core/screenUtils.js";import{Seconds as s,secondsFromMilliseconds as a}from"../../../../core/time.js";import{property as r,subclass as p}from"../../../../core/accessorSupport/decorators.js";import{scale as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u,fromValues as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import d from"../../../../geometry/Point.js";import{translateBy as v}from"../../viewpointUtils.js";import{PanPlanarMomentumEstimator as l}from"../../../navigation/PanPlanarMomentumEstimator.js";let g=class extends e{constructor(t){super(t),this.animationTime=s(0),this.momentumEstimator=new l(500,6,.92),this.momentum=null,this.tmpMomentum=u(),this.momentumFinished=!1,this.viewpoint=new i({targetGeometry:new d,scale:0,rotation:0}),this._previousDrag=null,this.addHandles(m(()=>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 m=this._previousDrag;o=m?m.center.x-o:-o,e=m?e-m.center.y:e,t.viewpoint=v(this.viewpoint,t.viewpoint,[o||0,e||0]),this._previousDrag=i}end(t,i){this.addToEstimator(i);const e=t.navigation.momentumEnabled&&!o();this.momentum=e?this.momentumEstimator.evaluateMomentum():null,this.animationTime=s(0),this.momentum&&this.onAnimationUpdate(t),this._previousDrag=null,this.navigation.end()}addToEstimator(t){const i=t.center.x,o=t.center.y,e=n(-i,o),m=c(-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:m,tmpMomentum:n}=this,r=this.momentumFinished=!e||e.isFinished(m),p=a(o);if(!r){const o=e.valueDelta(m,p);h(n,e.direction,o),v(i,i,n),t.constraints.constrainByGeometry(i)}this.animationTime=s(this.animationTime+p)})}stopMomentumNavigation(){this.momentum&&(this.momentumEstimator.reset(),this.momentum=null,this.navigation.stop())}};t([r()],g.prototype,"momentumFinished",void 0),t([r()],g.prototype,"viewpoint",void 0),t([r()],g.prototype,"navigation",void 0),g=t([p("esri.views.2d.navigation.actions.Pan")],g);export{g as default};