UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 1.03 kB
import{isSome as t}from"../../../../../core/maybe.js";import{isDiagonalResizeHandle as a}from"../../../analysis/Slice/sliceToolUtils.js";import{EventPipeline as e}from"../../../../interactive/dragEventPipeline.js";class s{constructor(){this._lastDragEvent=null,this._next=null,this._enabled=!1}get enabled(){return this._enabled}set enabled(a){if(this._enabled!==a&&t(this._lastDragEvent)&&t(this._next)){const t={...this._lastDragEvent,action:"update"};a&&this._adjustScaleFactors(t),this._next.execute(t)}this._enabled=a}createDragEventPipelineStep(){this._lastDragEvent=null;const t=new e;return this._next=t,[t=>(this._lastDragEvent="end"!==t.action?{...t}:null,this._enabled&&this._adjustScaleFactors(t),t),t]}_adjustScaleFactors(t){const e=a(t.handle)?Math.max(Math.abs(t.factor1),Math.abs(t.factor2)):0===t.handle.direction[0]?Math.abs(t.factor2):Math.abs(t.factor1);t.factor1=t.factor1<0?-e:e,t.factor2=t.factor2<0?-e:e}get test(){return{_adjustScaleFactors:t=>this._adjustScaleFactors(t)}}}export{s as PreserveAspectRatio};