Refactor files and fix layout bugs on mobile devices

This commit is contained in:
Marcel
2018-01-21 18:40:23 +01:00
parent 59e3dfd87b
commit 7b18a66b00
7 changed files with 162 additions and 11 deletions

24
js/touch-control.js Normal file
View File

@@ -0,0 +1,24 @@
const hammertime = new Hammer(document.getElementById("tetris"));
hammertime.on('swipeleft', (e) => {
keys.left.action();
});
hammertime.on('swiperight', (e) => {
keys.right.action();
});
hammertime.on('pandown swipedown', (e) => {
console.log(e);
keys.down.action();
});
hammertime.on('tap', (e) => {
if (e.tapCount >= 2) {
keys.rotateRight.action();
}
});
hammertime.on('press', () => {
keys.down.action();
});