diff options
author | Juanjo Diaz <juanjo.diazmo@gmail.com> | 2019-02-16 23:31:58 +0200 |
---|---|---|
committer | Juanjo Diaz <juanjo.diazmo@gmail.com> | 2019-02-16 23:31:58 +0200 |
commit | 9255e0fb47fe450793d8018c1cbb1f47124e9344 (patch) | |
tree | be44db3cba70a59489022a642d8c5d7da72a377f /core/input | |
parent | b00a608af7a5e42c819a6cd15bb2ff7b8cce9f65 (diff) | |
download | novnc-9255e0fb47fe450793d8018c1cbb1f47124e9344.tar.gz |
Remove intermediate variable from mouse
Diffstat (limited to 'core/input')
-rw-r--r-- | core/input/mouse.js | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/core/input/mouse.js b/core/input/mouse.js index c78f2ab..58a2982 100644 --- a/core/input/mouse.js +++ b/core/input/mouse.js @@ -238,43 +238,39 @@ export default class Mouse { // ===== PUBLIC METHODS ===== grab() { - const c = this._target; - if (isTouchDevice) { - c.addEventListener('touchstart', this._eventHandlers.mousedown); - c.addEventListener('touchend', this._eventHandlers.mouseup); - c.addEventListener('touchmove', this._eventHandlers.mousemove); + this._target.addEventListener('touchstart', this._eventHandlers.mousedown); + this._target.addEventListener('touchend', this._eventHandlers.mouseup); + this._target.addEventListener('touchmove', this._eventHandlers.mousemove); } - c.addEventListener('mousedown', this._eventHandlers.mousedown); - c.addEventListener('mouseup', this._eventHandlers.mouseup); - c.addEventListener('mousemove', this._eventHandlers.mousemove); - c.addEventListener('wheel', this._eventHandlers.mousewheel); + this._target.addEventListener('mousedown', this._eventHandlers.mousedown); + this._target.addEventListener('mouseup', this._eventHandlers.mouseup); + this._target.addEventListener('mousemove', this._eventHandlers.mousemove); + this._target.addEventListener('wheel', this._eventHandlers.mousewheel); /* Prevent middle-click pasting (see above for why we bind to document) */ document.addEventListener('click', this._eventHandlers.mousedisable); /* preventDefault() on mousedown doesn't stop this event for some reason so we have to explicitly block it */ - c.addEventListener('contextmenu', this._eventHandlers.mousedisable); + this._target.addEventListener('contextmenu', this._eventHandlers.mousedisable); } ungrab() { - const c = this._target; - this._resetWheelStepTimers(); if (isTouchDevice) { - c.removeEventListener('touchstart', this._eventHandlers.mousedown); - c.removeEventListener('touchend', this._eventHandlers.mouseup); - c.removeEventListener('touchmove', this._eventHandlers.mousemove); + this._target.removeEventListener('touchstart', this._eventHandlers.mousedown); + this._target.removeEventListener('touchend', this._eventHandlers.mouseup); + this._target.removeEventListener('touchmove', this._eventHandlers.mousemove); } - c.removeEventListener('mousedown', this._eventHandlers.mousedown); - c.removeEventListener('mouseup', this._eventHandlers.mouseup); - c.removeEventListener('mousemove', this._eventHandlers.mousemove); - c.removeEventListener('wheel', this._eventHandlers.mousewheel); + this._target.removeEventListener('mousedown', this._eventHandlers.mousedown); + this._target.removeEventListener('mouseup', this._eventHandlers.mouseup); + this._target.removeEventListener('mousemove', this._eventHandlers.mousemove); + this._target.removeEventListener('wheel', this._eventHandlers.mousewheel); document.removeEventListener('click', this._eventHandlers.mousedisable); - c.removeEventListener('contextmenu', this._eventHandlers.mousedisable); + this._target.removeEventListener('contextmenu', this._eventHandlers.mousedisable); } } |