@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 779 B
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{InputHandler as o}from"../../../input/InputHandler.js";class t extends o{constructor(o,t,e){super(!0),this.view=o,this.keys=t,this._keysToZoomAction={},this.registerIncoming("key-down",e,o=>this._handleKeyDown(o)),t.zoomIn.forEach(o=>this._keysToZoomAction[o]=0),t.zoomOut.forEach(o=>this._keysToZoomAction[o]=1)}_handleKeyDown(o){this._handleKey(o)}_handleKey(o){const t=o.modifiers;if(t.size>0&&!t.has("Shift"))return;const{key:e}=o.data;if(!(e in this._keysToZoomAction))return;const i=this._keysToZoomAction[e],{mapViewNavigation:n}=this.view;let s=null;switch(i){case 0:s=n.zoomIn();break;case 1:s=n.zoomOut();break;default:return}n.begin(),s.then(()=>n.end()),o.stopPropagation()}}export{t as KeyZoom};