-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathyandex_module_remote.js
42 lines (31 loc) · 1.29 KB
/
yandex_module_remote.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(function() {
'use strict';
let time = 0;
// document.addEventListener("mouseup", function (e) {
// e.preventDefault();
// Lampa.Controller.enter();
// });
Lampa.Noty.show('ver 1'); // Yandex.Browser for TV doesn't allow to refresh the page without cache
// https://github.com/yumata/lampa-source/blob/main/src/interaction/keypad.js
window.addEventListener("mousemove", function (e) {
if (time > Date.now() - 100) return
time = Date.now();
var button = e.button;
var key = e.key;
var movementX = e.movementX;
var movementY = e.movementY;
var screenX = e.screenX;
if (movementX < 0) {
Lampa.Controller.move('left');
} else if (movementX > 0) {
Lampa.Controller.move('right');
} else if (movementY < 0) {
Lampa.Controller.move('up');
} else if (movementY > 0) {
Lampa.Controller.move('down');
} else if (screenX == 0) { // it works with the left side, but doesn't work on others
Lampa.Controller.move('left');
}
Lampa.Noty.show('mouse move, button: ' + button + ', movementX: ' + movementX + ', movementY: ' + movementY + ', key: ' + key);
});
})();