From ff3aa9bc455e6ca5aa9f6cb8f09e937d1284623b Mon Sep 17 00:00:00 2001 From: lVAL Date: Wed, 30 Sep 2020 14:56:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=BF=AE=E6=94=B9card=20?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=E7=B2=98=E8=B4=B4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/iscs/iscs.js | 3 ++- src/iscs/keyboardController.js | 4 +++- src/jmap/keyboardController.js | 1 + src/jmap/map.js | 2 +- src/jmapNew/keyboardController.js | 3 ++- src/jmapNew/map.js | 1 + 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/iscs/iscs.js b/src/iscs/iscs.js index ee75b4ca8..21b94f746 100644 --- a/src/iscs/iscs.js +++ b/src/iscs/iscs.js @@ -33,7 +33,8 @@ class Iscs { const height = opts.config.height; this.isAllowDragging = false; this.$iscsZr = zrender.init(opts.dom, Object.assign({ renderer, devicePixelRatio, width, height }, opts.config)); - this.$options = new Options(Object.assign({ scaleRate: 1, offsetX: 0, offsetY: 0 }, opts.options || {})); // 缩放 + this.$iscsZr.dom.setAttribute('tabIndex', -1); + this.$options = new Options(Object.assign({ scaleRate: 1, offsetX: 0, offsetY: 0 }, opts.options || {})); // 缩放 this.$mouseController = new MouseController(this); this.$mouseController.enable(); diff --git a/src/iscs/keyboardController.js b/src/iscs/keyboardController.js index 013379a22..38c2262db 100644 --- a/src/iscs/keyboardController.js +++ b/src/iscs/keyboardController.js @@ -19,7 +19,8 @@ class KeyboardController extends Eventful { opts = opts || {}; this._keyOnDownUp = opts.keyOnDownUp || true; - dom.addEventListener('keyup', keydownHandle, false); + dom.addEventListener('keyup', keydownHandle, false); + dom.focus(); }; this.disable = function () { @@ -33,6 +34,7 @@ class KeyboardController extends Eventful { } keydown(e) { + console.log(e, 111111111111111) if (this._keyOnDownUp && !e.repeat) { const currentEvent = keyboardEvents[e.key.toUpperCase()]||{event:""}; this.trigger(this.events.Keyboard, currentEvent.event); diff --git a/src/jmap/keyboardController.js b/src/jmap/keyboardController.js index 93754a399..9c40ef810 100644 --- a/src/jmap/keyboardController.js +++ b/src/jmap/keyboardController.js @@ -22,6 +22,7 @@ class KeyboardController extends Eventful { dom.addEventListener('keydown', keydownHandle, false); dom.addEventListener('keyup', keyupHandle, false); + dom.focus(); }; this.disable = function () { diff --git a/src/jmap/map.js b/src/jmap/map.js index d7c95a8b3..0f52b3dde 100644 --- a/src/jmap/map.js +++ b/src/jmap/map.js @@ -44,7 +44,7 @@ class Jlmap { this.zoomOnMouseWheel = opts.options.zoomOnMouseWheel; this.$zr = zrender.init(opts.dom, deepAssign({ renderer, devicePixelRatio, width, height }, opts.config)); - + this.$zr.dom.setAttribute('tabIndex', -1); this.$options = new Options(deepAssign({ scaleRate: 1, offsetX: 0, offsetY: 0 }, opts.options || {}), (dataZoom) => { this.$mouseController.trigger(this.events.DataZoom, dataZoom); }); // 缩放 this.$painter = new Painter(this); this.$painter.updateZrSize({width: this.$zr.getWidth(), height: this.$zr.getHeight()}); diff --git a/src/jmapNew/keyboardController.js b/src/jmapNew/keyboardController.js index dc6c8e695..24b0ca785 100644 --- a/src/jmapNew/keyboardController.js +++ b/src/jmapNew/keyboardController.js @@ -20,7 +20,8 @@ class KeyboardController extends Eventful { opts = opts || {}; this._keyOnDownUp = opts.keyOnDownUp || true; - dom.addEventListener('keyup', keydownHandle, false); + dom.addEventListener('keyup', keydownHandle, false); + dom.focus(); }; this.disable = function () { diff --git a/src/jmapNew/map.js b/src/jmapNew/map.js index 96e142f24..e0819251a 100644 --- a/src/jmapNew/map.js +++ b/src/jmapNew/map.js @@ -54,6 +54,7 @@ class Jlmap { this.previewOrMapDraw = opts.showConfig.previewOrMapDraw; this.$zr = zrender.init(opts.dom, deepAssign({ renderer, devicePixelRatio, width, height }, opts.config)); + this.$zr.dom.setAttribute('tabIndex', -1); this.$options = new Options(deepAssign({ scaleRate: 1, offsetX: 0, offsetY: 0 }, opts.options || {}), (dataZoom) => { this.$mouseController.trigger(this.events.DataZoom, dataZoom); }); // 缩放 this.$painter = new Painter(this);