@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 2.5 kB
JavaScript
import{_ as t}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.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 n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import{g as r}from"../../../../chunks/vec3.js";import{c as a,f as p}from"../../../../chunks/vec3f64.js";import{translateBy as c}from"../../viewpointUtils.js";import{PanPlanarMomentumEstimator as u}from"../../../navigation/PanPlanarMomentumEstimator.js";import h from"../../../../geometry/Point.js";let v=class extends o{constructor(t){super(t),this.animationTime=0,this.momentumEstimator=new u(500,6,.92),this.momentum=null,this.tmpMomentum=a(),this.momentumFinished=!1,this.viewpoint=new i({targetGeometry:new h,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=c(this.viewpoint,t.viewpoint,[o||0,e||0]),this._previousDrag=i}end(t,i){this.addToEstimator(i);const o=t.navigation.momentumEnabled;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),n=p(-i,o,0);this.momentumEstimator.add(e,n,.001*t.timestamp)}onAnimationUpdate(t){this.navigation.animationManager?.animateContinous(t.viewpoint,((i,o)=>{const{momentum:e,animationTime:s,tmpMomentum:n}=this,m=.001*o;if(!(this.momentumFinished=!e||e.isFinished(s))){const o=e.valueDelta(s,m);r(n,e.direction,o),c(i,i,n),t.constraints.constrainByGeometry(i)}this.animationTime+=m}))}stopMomentumNavigation(){this.momentum&&(this.momentumEstimator.reset(),this.momentum=null,this.navigation.stop())}};t([n()],v.prototype,"momentumFinished",void 0),t([n()],v.prototype,"viewpoint",void 0),t([n()],v.prototype,"navigation",void 0),v=t([m("esri.views.2d.navigation.actions.Pan")],v);const d=v;export{d as default};