Skip to content

Commit

Permalink
Implement touch support for tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartheyrman22 committed May 7, 2018
1 parent 25fb1ec commit cc3662a
Show file tree
Hide file tree
Showing 19 changed files with 784 additions and 341 deletions.
69 changes: 47 additions & 22 deletions src/js/tools/blur.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,56 @@ class Blur_class extends Base_tools_class {
this.started = false;
}

dragStart(event) {
var _this = this;
if (config.TOOL.name != _this.name)
return;
_this.mousedown(event);
}

dragMove(event) {
var _this = this;
if (config.TOOL.name != _this.name)
return;
_this.mousemove(event);

//mouse cursor
var mouse = _this.get_mouse_info(e);
var params = _this.getParams();
_this.show_mouse_cursor(mouse.x, mouse.y, params.size, 'circle');
}

dragEnd(event) {
var _this = this;
if (config.TOOL.name != _this.name)
return;
_this.mouseup(event);
}

load() {
var _this = this;

//mouse events
document.addEventListener('mousedown', function (e) {
if (config.TOOL.name != _this.name)
return;
_this.mousedown(e);
});
document.addEventListener('mousemove', function (e) {
if (config.TOOL.name != _this.name)
return;
_this.mousemove(e);

//mouse cursor
var mouse = _this.get_mouse_info(e);
var params = _this.getParams();
_this.show_mouse_cursor(mouse.x, mouse.y, params.size, 'circle');

});
document.addEventListener('mouseup', function (e) {
if (config.TOOL.name != _this.name)
return;
_this.mouseup(e);
});
//mouse events
document.addEventListener('mousedown', function (event) {
_this.dragStart(event);
});
document.addEventListener('mousemove', function (event) {
_this.dragMove(event);
});
document.addEventListener('mouseup', function (event) {
_this.dragEnd(event);
});

// collect touch events
document.addEventListener('touchstart', function (event) {
_this.dragStart(event);
});
document.addEventListener('touchmove', function (event) {
_this.dragMove(event);
});
document.addEventListener('touchend', function (event) {
_this.dragEnd(event);
});
}

mousedown(e) {
Expand Down
68 changes: 47 additions & 21 deletions src/js/tools/brush.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,56 @@ class Brush_class extends Base_tools_class {
this.params_hash = false;
}

dragStart(event) {
var _this = this;
if (config.TOOL.name != _this.name)
return;
_this.mousedown(event);
}

dragMove(event) {
var _this = this;
if (config.TOOL.name != _this.name)
return;
_this.mousemove(event);

//mouse cursor
var mouse = _this.get_mouse_info(event);
var params = _this.getParams();
_this.show_mouse_cursor(mouse.x, mouse.y, params.size, 'circle');
}

dragEnd(event) {
var _this = this;
if (config.TOOL.name != _this.name)
return;
_this.mouseup(event);
}

load() {
var _this = this;

//events
document.addEventListener('mousedown', function (e) {
if (config.TOOL.name != _this.name)
return;
_this.mousedown(e);
});
document.addEventListener('mousemove', function (e) {
if (config.TOOL.name != _this.name)
return;
_this.mousemove(e);

//mouse cursor
var mouse = _this.get_mouse_info(e);
var params = _this.getParams();
_this.show_mouse_cursor(mouse.x, mouse.y, params.size, 'circle');
});
document.addEventListener('mouseup', function (e) {
if (config.TOOL.name != _this.name)
return;
_this.mouseup(e);
});
//mouse events
document.addEventListener('mousedown', function (event) {
_this.dragStart(event);
});
document.addEventListener('mousemove', function (event) {
_this.dragMove(event);
});
document.addEventListener('mouseup', function (event) {
_this.dragEnd(event);
});

// collect touch events
document.addEventListener('touchstart', function (event) {
_this.dragStart(event);
});
document.addEventListener('touchmove', function (event) {
_this.dragMove(event);
});
document.addEventListener('touchend', function (event) {
_this.dragEnd(event);
});
}

mousedown(e) {
Expand Down
67 changes: 46 additions & 21 deletions src/js/tools/bulge_pinch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,55 @@ class BulgePinch_class extends Base_tools_class {
this.started = false;
}

dragStart(event) {
var _this = this;
if (config.TOOL.name != _this.name)
return;
_this.mousedown(event);
}

dragMove(event) {
var _this = this;
if (config.TOOL.name != _this.name)
return;

//mouse cursor
var mouse = _this.get_mouse_info(event);
var params = _this.getParams();
_this.show_mouse_cursor(mouse.x, mouse.y, params.radius, 'circle');
}

dragEnd(event) {
var _this = this;
if (config.TOOL.name != _this.name)
return;
_this.mouseup(event);
}

load() {
var _this = this;

//mouse events
document.addEventListener('mousedown', function (e) {
if (config.TOOL.name != _this.name)
return;
_this.mousedown(e);
});
document.addEventListener('mousemove', function (e) {
if (config.TOOL.name != _this.name)
return;

//mouse cursor
var mouse = _this.get_mouse_info(e);
var params = _this.getParams();
_this.show_mouse_cursor(mouse.x, mouse.y, params.radius, 'circle');

});
document.addEventListener('mouseup', function (e) {
if (config.TOOL.name != _this.name)
return;
_this.mouseup(e);
});
//mouse events
document.addEventListener('mousedown', function (event) {
_this.dragStart(event);
});
document.addEventListener('mousemove', function (event) {
_this.dragMove(event);
});
document.addEventListener('mouseup', function (event) {
_this.dragEnd(event);
});

// collect touch events
document.addEventListener('touchstart', function (event) {
_this.dragStart(event);
});
document.addEventListener('touchmove', function (event) {
_this.dragMove(event);
});
document.addEventListener('touchend', function (event) {
_this.dragEnd(event);
});
}

mousedown(e) {
Expand Down
58 changes: 42 additions & 16 deletions src/js/tools/circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,51 @@ class Circle_class extends Base_tools_class {
this.layer = {};
}

dragStart(event) {
var _this = this;
if (config.TOOL.name != _this.name)
return;
_this.mousedown(event);
}

dragMove(event) {
var _this = this;
if (config.TOOL.name != _this.name)
return;
_this.mousemove(event);
}

dragEnd(event) {
var _this = this;
if (config.TOOL.name != _this.name)
return;
_this.mouseup(event);
}

load() {
var _this = this;

//events
document.addEventListener('mousedown', function (e) {
if (config.TOOL.name != _this.name)
return;
_this.mousedown(e);
});
document.addEventListener('mousemove', function (e) {
if (config.TOOL.name != _this.name)
return;
_this.mousemove(e);
});
document.addEventListener('mouseup', function (e) {
if (config.TOOL.name != _this.name)
return;
_this.mouseup(e);
});
//mouse events
document.addEventListener('mousedown', function (event) {
_this.dragStart(event);
});
document.addEventListener('mousemove', function (event) {
_this.dragMove(event);
});
document.addEventListener('mouseup', function (event) {
_this.dragEnd(event);
});

// collect touch events
document.addEventListener('touchstart', function (event) {
_this.dragStart(event);
});
document.addEventListener('touchmove', function (event) {
_this.dragMove(event);
});
document.addEventListener('touchend', function (event) {
_this.dragEnd(event);
});
}

mousedown(e) {
Expand Down
Loading

0 comments on commit cc3662a

Please sign in to comment.