12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import i from"../../Viewpoint.js";import s from"../../core/Accessor.js";import{addFrameTask as e}from"../../core/scheduling.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import a from"../ViewAnimation.js";import{easingFunctions as r,parse as h}from"./unitBezier.js";import{copy as p}from"./viewpointUtils.js";import c from"../../geometry/Point.js";class m{constructor(t,i,s,e){const o=t.targetGeometry,n=i.targetGeometry;e?"string"==typeof e&&(e=h(e)||r.ease):e=r.ease,this.easing=e,this.duration=s,this.sCenterX=o.x,this.sCenterY=o.y,this.sScale=t.scale,this.sRotation=t.rotation,this.tCenterX=n.x,this.tCenterY=n.y,this.tScale=i.scale,this.tRotation=i.rotation,this.dCenterX=this.tCenterX-this.sCenterX,this.dCenterY=this.tCenterY-this.sCenterY,this.dScale=this.tScale-this.sScale,this.dRotation=this.tRotation-this.sRotation,this.dRotation>180?this.dRotation-=360:this.dRotation<-180&&(this.dRotation+=360)}applyRatio(t,i){const s=this.easing(i);let e,o,n,a;i>=1?(e=this.tCenterX,o=this.tCenterY,n=this.tRotation,a=this.tScale):(e=this.sCenterX+s*this.dCenterX,o=this.sCenterY+s*this.dCenterY,n=this.sRotation+s*this.dRotation,a=this.sScale+s*this.dScale),t.targetGeometry.x=e,t.targetGeometry.y=o,t.scale=a,t.rotation=n}}let u=class extends s{constructor(t){super(t),this.duration=200,this.transition=null,this.easing=r.ease,this.view=null,this.viewpoint=null,this.viewpoint=new i({targetGeometry:new c,scale:0,rotation:0}),this._updateTask=e({postRender:this._postRender.bind(this)}),this._updateTask.pause()}destroy(){this._updateTask.remove(),this._updateTask=null}animate(t,i,s){this.stop();const e=this.viewpoint;p(e,i),this.transition=new m(this.viewpoint,t.target,s&&s.duration||this.duration,s&&s.easing||this.easing);const o=()=>{this.animation===t&&this._updateTask&&("finished"===t.state&&(this.transition.applyRatio(this.viewpoint,1),this.view.state&&(this.view.state.viewpoint=this.viewpoint.clone())),this.animation=null,this.updateFunction=null)};return t.when(o,o),this._startTime=performance.now(),this._updateTask.resume(),this.animation=t,t}animateContinous(t,i){this.stop(),this.updateFunction=i,this.viewpoint=t;const s=new a({target:t.clone()}),e=()=>{this.animation===s&&this._updateTask&&(this.animation=null,this.updateFunction=null)};return s.when(e,e),this._startTime=performance.now(),this._updateTask.resume(),this.animation=s,s}stop(){this.animation&&(this.animation.stop(),this.animation=null,this.updateFunction=null)}_postRender(t){const i=this.animation;if(i&&i.state!==a.State.STOPPED){if(this.updateFunction)this.updateFunction(this.viewpoint,t.deltaTime);else{const t=(performance.now()-this._startTime)/this.transition.duration,i=t>=1;this.transition.applyRatio(this.viewpoint,t),i&&this.animation.finish()}this.view.state&&(this.view.state.viewpoint=this.viewpoint.clone())}else this._updateTask.pause()}};t([o()],u.prototype,"animation",void 0),t([o()],u.prototype,"duration",void 0),t([o()],u.prototype,"transition",void 0),t([o()],u.prototype,"easing",void 0),t([o()],u.prototype,"view",void 0),t([o()],u.prototype,"viewpoint",void 0),u=t([n("esri.views.2d.AnimationManager")],u);const d=u;export{d as default};
|