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 e from"../../core/Accessor.js";import has from"../../core/has.js";import{clone as s}from"../../core/lang.js";import r from"../../core/Logger.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{parse as c}from"./parser.js";import{canInterpolateEffects as o,normalizeEffects as f}from"./utils.js";const l=-1;let a=class extends e{constructor(t){super(t),this._from=null,this._to=null,this._final=null,this._current=[],this._time=0,this.duration=has("mapview-transitions-duration"),this.effects=[]}set effect(t){if(this._get("effect")!==(t=t||"")){this._set("effect",t);try{this._transitionTo(h(t))}catch(e){this._transitionTo([]),r.getLogger(this.declaredClass).warn("Invalid Effect",{effect:t,error:e})}}}get hasEffects(){return this.transitioning||!!this.effects.length}set scale(t){this._updateForScale(t)}get transitioning(){return null!==this._to}canTransitionTo(t){try{return this.scale>0&&u(this._current,h(t),this.scale)}catch{return!1}}transitionStep(t,e){this._applyTimeTransition(t),this._updateForScale(e)}endTransitions(){this._applyTimeTransition(this.duration)}_transitionTo(t){this.scale>0&&u(this._current,t,this.scale)?(this._final=t,this._to=s(t),_(this._current,this._to,this.scale),this._from=s(this._current),this._time=0):(this._from=this._to=this._final=null,this._current=t),this._set("effects",this._current[0]?s(this._current[0].effects):[])}_applyTimeTransition(t){if(!(this._to&&this._from&&this._current&&this._final))return;this._time+=t;const e=Math.min(1,this._time/this.duration);for(let s=0;s<this._current.length;s++){const t=this._current[s],r=this._from[s],i=this._to[s];t.scale=p(r.scale,i.scale,e);for(let s=0;s<t.effects.length;s++){const n=t.effects[s],c=r.effects[s],o=i.effects[s];n.interpolate(c,o,e)}}1===e&&(this._current=this._final,this._set("effects",this._current[0]?s(this._current[0].effects):[]),this._from=this._to=this._final=null)}_updateForScale(t){if(this._set("scale",t),0===this._current.length)return;const e=this._current,s=this._current.length-1;let r,i,n=1;if(1===e.length||t>=e[0].scale)i=r=e[0].effects;else if(t<=e[s].scale)i=r=e[s].effects;else for(let c=0;c<s;c++){const s=e[c],o=e[c+1];if(s.scale>=t&&o.scale<=t){n=(t-s.scale)/(o.scale-s.scale),r=s.effects,i=o.effects;break}}for(let c=0;c<this.effects.length;c++){this.effects[c].interpolate(r[c],i[c],n)}}};function h(t){const e=c(t)||[];return m(e)?[{scale:l,effects:e}]:e}function u(t,e,s){if(!t[0]?.effects||!e[0]?.effects)return!0;return!((t[0]?.scale===l||e[0]?.scale===l)&&(t.length>1||e.length>1)&&s<=0)&&o(t[0].effects,e[0].effects)}function _(t,e,s){const r=t.length>e.length?t:e,i=t.length>e.length?e:t,n=i[i.length-1],c=n?.scale??s,o=n?.effects??[];for(let f=i.length;f<r.length;f++)i.push({scale:c,effects:[...o]});for(let a=0;a<r.length;a++)i[a].scale=i[a].scale===l?s:i[a].scale,r[a].scale=r[a].scale===l?s:r[a].scale,f(i[a].effects,r[a].effects)}function p(t,e,s){return t+(e-t)*s}function m(t){const e=t[0];return!!e&&"type"in e}t([i()],a.prototype,"_to",void 0),t([i()],a.prototype,"duration",void 0),t([i({value:""})],a.prototype,"effect",null),t([i({readOnly:!0})],a.prototype,"effects",void 0),t([i({readOnly:!0})],a.prototype,"hasEffects",null),t([i({value:0})],a.prototype,"scale",null),t([i({readOnly:!0})],a.prototype,"transitioning",null),a=t([n("esri.layers.effects.EffectView")],a);export{a as EffectView,u as canInterpolateEffectStops,h as convertEffectToStops,_ as normalizeEffectStops};
|