Refactor files and fix layout bugs on mobile devices
This commit is contained in:
24
js/touch-control.js
Normal file
24
js/touch-control.js
Normal 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();
|
||||
});
|
Reference in New Issue
Block a user