@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.88 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{createScreenPointArray as o}from"../../../../core/screenUtils.js";import{State as t}from"../../state/controllers/CameraController.js";import{FovController as e}from"../../state/controllers/FovController.js";import{ZoomStepControllerGlobal as r}from"../../state/controllers/ZoomStepControllerGlobal.js";import{ZoomStepControllerLocal as l}from"../../state/controllers/ZoomStepControllerLocal.js";import{InputHandler as s}from"../../../input/InputHandler.js";class i extends s{constructor(o,t){super(!0),this._view=o,this.registerIncoming("mouse-wheel",[t],(o=>this._handleFov(o))),this.registerIncoming("mouse-wheel",(o=>this._handleZoom(o)))}_handleZoom(t){if(!this._mouseWheelZoomEnabled)return;const e=t.data;this._zoomController?.running||(this._stopFovController(),this._zoomController=this._view.state.isGlobal?new r({view:this._view,mode:"interaction"}):new l({view:this._view,mode:"interaction"}),this._view.state.switchCameraController(this._zoomController)),this._zoomController.step(-e.deltaY/60,o(e.x,e.y)),t.preventDefault(),t.stopPropagation()}_handleFov(o){this._mouseWheelZoomEnabled&&(this._fovController?.running||(this._zoomController?.finish(),this._fovController?.hideOverlay(),this._fovController=new e({view:this._view,onStop:()=>this._stopFovController()}),this._view.state.switchCameraController(this._fovController),this._fovController.state!==t.Rejected)?(this._fovController.updateTimeout(),this._fovController.step(o.data.deltaY/20),o.preventDefault(),o.stopPropagation()):this._stopFovController())}get _mouseWheelZoomEnabled(){return"zoom"===this._view.navigation.actionMap.mouseWheel}_stopFovController(){this._fovController?.finish(),this._fovController=null}}export{i as MouseWheelZoom};