UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 1.75 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{Manipulation as t,ManipulatorType as i}from"./Manipulation.js";import{createManipulatorDragEventPipeline as r,screenToMap as a}from"../../../../interactive/dragEventPipeline.js";import{GraphicManipulator as o}from"../../../../interactive/GraphicManipulator.js";import{AccumulationBehavior as e}from"../../../../interactive/editGeometry/interfaces.js";import{getSymbolInfo as n}from"../../../../interactive/support/utils.js";class s extends t{constructor(t){super(),this._view=t.view,this._tool=t.tool,this._graphic=t.graphic,this._manipulator=this._createManipulator(),this.forEachManipulator((t=>this._tool.manipulators.add(t)))}destroy(){this.forEachManipulator((t=>{this._tool.manipulators.remove(t),t.destroy()})),this._tool=null,this._view=null,this._manipulator=null,this._graphic=null}forEachManipulator(t){t(this._manipulator,i.TRANSLATE_XY)}createDragPipeline(t,i){let o=null,s=null,l=0,p=0,c=0;const{offsetX:m,offsetY:h,size:u}=n(this._graphic.symbol);return r(this._manipulator,((r,n)=>{n.next((i=>{if("start"===i.action){const i=t();o=i.editGeometryOperations,s=i.constraints}return i})).next(a(this._view)).next((t=>{const{x:r,y:a,z:n}=t.mapEnd;if(s&&(r+m<s.xmin||a+h-u<s.ymin||r+m>s.xmax||a+h-u>s.ymax))return t;("start"===t.action||0===l&&0===p&&0===c)&&(l=t.mapStart.x,p=t.mapStart.y,c=t.mapStart.z);const _=r-l,f=a-p,v=n-c;l=r,p=a,c=n;const x="start"===t.action?e.NEW_STEP:e.ACCUMULATE_STEPS,E=o.move(_,f,v,x);return i(t,E),t}))}))}_createManipulator(){const t=this._view,i=this._graphic;return new o({view:t,graphic:i,selectable:!0,cursor:"move"})}}export{s as DragManipulation};