summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2018-10-02 13:29:22 +0300
committerDevaev Maxim <[email protected]>2018-10-02 13:29:22 +0300
commit0cf50f55aa8d6cc9866a8eaba05d6df3bc71e08e (patch)
tree56e07b3483e36103aaa8b5261a8ede66af527395
parentf89918b4bf5c5cd087e9b34a527215ff7baa0bba (diff)
wheel fix
-rw-r--r--web/js/mouse.js25
1 files changed, 18 insertions, 7 deletions
diff --git a/web/js/mouse.js b/web/js/mouse.js
index e4038436..d1c45118 100644
--- a/web/js/mouse.js
+++ b/web/js/mouse.js
@@ -7,6 +7,7 @@ function Mouse() {
var __current_pos = {x: 0, y:0};
var __sent_pos = {x: 0, y:0};
+ var __wheel_delta = {x: 0, y: 0};
var __stream_hovered = false;
@@ -132,13 +133,23 @@ function Mouse() {
if (event.preventDefault) {
event.preventDefault();
}
- var delta = {x: event.deltaX, y: event.deltaY};
- tools.debug("Mouse wheel:", delta);
- if (__ws) {
- __ws.send(JSON.stringify({
- event_type: "mouse_wheel",
- delta: delta,
- }));
+
+ var delta = {x: 0, y: 0};
+
+ __wheel_delta.y += event.deltaY;
+ if (Math.abs(__wheel_delta.y) >= 100) {
+ delta.y = __wheel_delta.y / Math.abs(__wheel_delta.y) * (-5);
+ __wheel_delta.y = 0;
+ }
+
+ if (delta.y) {
+ tools.debug("Mouse wheel:", delta);
+ if (__ws) {
+ __ws.send(JSON.stringify({
+ event_type: "mouse_wheel",
+ delta: delta,
+ }));
+ }
}
};