Added basic mobile touch support. Needs a library.
This commit is contained in:
parent
34a91e97c5
commit
5516665db1
|
@ -26,6 +26,7 @@ ascii.Controller = function(view, state) {
|
||||||
|
|
||||||
// TODO: Setup different bindings for tablet/mobile.
|
// TODO: Setup different bindings for tablet/mobile.
|
||||||
this.installDesktopBindings();
|
this.installDesktopBindings();
|
||||||
|
this.installTouchBindings();
|
||||||
};
|
};
|
||||||
|
|
||||||
ascii.Controller.prototype.handlePress = function(x, y) {
|
ascii.Controller.prototype.handlePress = function(x, y) {
|
||||||
|
@ -92,6 +93,7 @@ ascii.Controller.prototype.handleZoom = function(delta) {
|
||||||
ascii.Controller.prototype.installDesktopBindings = function() {
|
ascii.Controller.prototype.installDesktopBindings = function() {
|
||||||
var controller = this;
|
var controller = this;
|
||||||
$(this.view.canvas).bind('mousewheel', function(e) {
|
$(this.view.canvas).bind('mousewheel', function(e) {
|
||||||
|
|
||||||
controller.handleZoom(e.originalEvent.wheelDelta);
|
controller.handleZoom(e.originalEvent.wheelDelta);
|
||||||
});
|
});
|
||||||
$(this.view.canvas).mousedown(function(e) {
|
$(this.view.canvas).mousedown(function(e) {
|
||||||
|
@ -105,3 +107,25 @@ ascii.Controller.prototype.installDesktopBindings = function() {
|
||||||
});
|
});
|
||||||
$(window).resize(function(e) { controller.view.resizeCanvas() });
|
$(window).resize(function(e) { controller.view.resizeCanvas() });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ascii.Controller.prototype.installTouchBindings = function() {
|
||||||
|
var controller = this;
|
||||||
|
$(this.view.canvas).bind("touchstart", function(e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
controller.handlePress(
|
||||||
|
e.originalEvent.touches[0].clientX,
|
||||||
|
e.originalEvent.touches[0].clientY);
|
||||||
|
});
|
||||||
|
$(this.view.canvas).bind("touchend", function(e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
controller.handleRelease(
|
||||||
|
e.originalEvent.touches[0].clientX,
|
||||||
|
e.originalEvent.touches[0].clientY);
|
||||||
|
});
|
||||||
|
$(this.view.canvas).bind("touchmove", function(e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
controller.handleMove(
|
||||||
|
e.originalEvent.touches[0].clientX,
|
||||||
|
e.originalEvent.touches[0].clientY);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
|
||||||
<title>asciiflow-2.0</title>
|
<title>asciiflow-2.0</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
Loading…
Reference in New Issue