@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.78 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{PinchAndPanControllerGlobal as t}from"../../state/controllers/PinchAndPanControllerGlobal.js";import{PinchAndPanControllerLocal as e}from"../../state/controllers/PinchAndPanControllerLocal.js";import{InputHandler as s}from"../../../input/InputHandler.js";import{eventMatchesMousePointerActions as r}from"../../../input/handlers/support.js";class i extends s{constructor(t,e,s){super(!0),this._view=t,this.pointerActions=e,this._lastEndTimestamp=0,this._lastTimestamp=0,this.registerIncoming("drag",s,(t=>this._handleDrag(t)))}_handleDrag(t){if("mouse"===t.data.pointerType&&!r(t.data,this.pointerActions))return;const e=t.timestamp-this._lastEndTimestamp,s=40,i=this._momentum&&this._momentum.running&&e<s;switch(t.data.action){case"start":case"update":if(i)break;this._controller&&this._controller.running?t.data.timestamp-this._lastTimestamp>2&&(this._controller.update(t.data),this._lastTimestamp=t.timestamp):this._startController(t);break;case"end":case"removed":this._endController(t,!0);break;case"added":this._endController(t,!1),this._startController(t)}t.stopPropagation()}_endController(t,e){if(this._controller?.running){this._lastEndTimestamp=t.timestamp;const s=this._controller.end(t.data);e&&s&&(this._momentum=s,this._view.state.switchCameraController(this._momentum))}this._controller=null}_startController(t){this._controller=this._createController(),this._view.state.switchCameraController(this._controller),this._controller.begin(t.data),this._lastTimestamp=t.timestamp}_createController(){return this._view.state.isGlobal?new t({view:this._view}):new e({view:this._view})}}export{i as PinchAndPanNavigation};