diff options
author | Devaev Maxim <[email protected]> | 2018-07-13 05:52:22 +0000 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-07-13 05:52:22 +0000 |
commit | 1f02b77f662e3ba6a4d66e7c037dba334874d1db (patch) | |
tree | 6b22b89e7905d3f55ed0eafbd2287e98e4c3c2f0 /kvmd/web/js | |
parent | 2a6883064da7b63bca15e2aaeb9debe584d88bc7 (diff) |
client-side for mouse wheel
Diffstat (limited to 'kvmd/web/js')
-rw-r--r-- | kvmd/web/js/kvmd.js | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/kvmd/web/js/kvmd.js b/kvmd/web/js/kvmd.js index e93a4d88..489d70d1 100644 --- a/kvmd/web/js/kvmd.js +++ b/kvmd/web/js/kvmd.js @@ -47,8 +47,8 @@ function __installHidHandlers(ws) { el_stream_image.onmouseup = (event) => __onMouseButton(ws, event, false); el_stream_image.oncontextmenu = (event) => event.preventDefault(); el_stream_image.onmousemove = __onMouseMove; - runKvmdSession.mouse_timer_id = setInterval(() => __handleMouseMove(ws), 100); - // TODO: https://learn.javascript.ru/mousewheel + el_stream_image.onwheel = (event) => __onMouseWheel(ws, event); + runKvmdSession.mouse_move_timer = setInterval(() => __handleMouseMove(ws), 100); } function __clearHidHandlers() { @@ -60,7 +60,8 @@ function __clearHidHandlers() { el_stream_image.onmouseup = null; el_stream_image.oncontextmenu = null; el_stream_image.onmousemove = null; - clearInterval(runKvmdSession.mouse_timer_id); + el_stream_image.onwheel = null; + clearInterval(runKvmdSession.mouse_move_timer); } function __onKeyEvent(ws, event, state) { @@ -115,6 +116,20 @@ function __handleMouseMove(ws) { } __handleMouseMove.old_pos = {x: 0, y:0}; +function __onMouseWheel(ws, event) { + // https://learn.javascript.ru/mousewheel + if (event.preventDefault) { + event.preventDefault(); + } + ws.send(JSON.stringify({ + event_type: "mouse_wheel", + delta: { + x: event.deltaX, + y: event.deltaY, + }, + })); +} + // ----------------------------------------------------------------------------- function clickPowerButton() { |