mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Fix : trigger tool move on keyup to acknowledge modifier changes
This commit is contained in:
parent
a3c409ff94
commit
21a759d8eb
@ -75,6 +75,7 @@
|
|||||||
|
|
||||||
window.addEventListener('mouseup', this.onMouseup_.bind(this));
|
window.addEventListener('mouseup', this.onMouseup_.bind(this));
|
||||||
window.addEventListener('mousemove', this.onMousemove_.bind(this));
|
window.addEventListener('mousemove', this.onMousemove_.bind(this));
|
||||||
|
window.addEventListener('keyup', this.onKeyup_.bind(this));
|
||||||
|
|
||||||
// Deactivate right click:
|
// Deactivate right click:
|
||||||
body.contextmenu(this.onCanvasContextMenu_);
|
body.contextmenu(this.onCanvasContextMenu_);
|
||||||
@ -146,40 +147,54 @@
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ns.DrawingController.prototype.onMousemove_ = function (event) {
|
ns.DrawingController.prototype.onMousemove_ = function (event) {
|
||||||
|
this._clientX = event.clientX;
|
||||||
|
this._clientY = event.clientY;
|
||||||
|
|
||||||
var currentTime = new Date().getTime();
|
var currentTime = new Date().getTime();
|
||||||
// Throttling of the mousemove event:
|
// Throttling of the mousemove event:
|
||||||
|
|
||||||
if ((currentTime - this.previousMousemoveTime) > Constants.MOUSEMOVE_THROTTLING ) {
|
if ((currentTime - this.previousMousemoveTime) > Constants.MOUSEMOVE_THROTTLING ) {
|
||||||
var coords = this.renderer.getCoordinates(event.clientX, event.clientY);
|
this.moveTool_(this._clientX, this._clientY, event);
|
||||||
var currentFrame = this.piskelController.getCurrentFrame();
|
|
||||||
|
|
||||||
if (this.isClicked) {
|
|
||||||
// Warning : do not call setCurrentButton here
|
|
||||||
// mousemove do not have the correct mouse button information on all browsers
|
|
||||||
this.currentToolBehavior.moveToolAt(
|
|
||||||
coords.x | 0,
|
|
||||||
coords.y | 0,
|
|
||||||
this.getCurrentColor_(event),
|
|
||||||
currentFrame,
|
|
||||||
this.overlayFrame,
|
|
||||||
event
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
this.currentToolBehavior.moveUnactiveToolAt(
|
|
||||||
coords.x,
|
|
||||||
coords.y,
|
|
||||||
this.getCurrentColor_(event),
|
|
||||||
currentFrame,
|
|
||||||
this.overlayFrame,
|
|
||||||
event
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$.publish(Events.CURSOR_MOVED, [coords.x, coords.y]);
|
|
||||||
this.previousMousemoveTime = currentTime;
|
this.previousMousemoveTime = currentTime;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ns.DrawingController.prototype.onKeyup_ = function (event) {
|
||||||
|
this.moveTool_(this._clientX, this._clientY, event);
|
||||||
|
};
|
||||||
|
|
||||||
|
ns.DrawingController.prototype.moveTool_ = function (x, y, event) {
|
||||||
|
var coords = this.renderer.getCoordinates(x, y);
|
||||||
|
var currentFrame = this.piskelController.getCurrentFrame();
|
||||||
|
|
||||||
|
if (this.isClicked) {
|
||||||
|
// Warning : do not call setCurrentButton here
|
||||||
|
// mousemove do not have the correct mouse button information on all browsers
|
||||||
|
this.currentToolBehavior.moveToolAt(
|
||||||
|
coords.x | 0,
|
||||||
|
coords.y | 0,
|
||||||
|
this.getCurrentColor_(),
|
||||||
|
currentFrame,
|
||||||
|
this.overlayFrame,
|
||||||
|
event
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
this.currentToolBehavior.moveUnactiveToolAt(
|
||||||
|
coords.x,
|
||||||
|
coords.y,
|
||||||
|
this.getCurrentColor_(),
|
||||||
|
currentFrame,
|
||||||
|
this.overlayFrame,
|
||||||
|
event
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$.publish(Events.CURSOR_MOVED, [coords.x, coords.y]);
|
||||||
|
}
|
||||||
|
|
||||||
ns.DrawingController.prototype.onMousewheel_ = function (jQueryEvent) {
|
ns.DrawingController.prototype.onMousewheel_ = function (jQueryEvent) {
|
||||||
var event = jQueryEvent.originalEvent;
|
var event = jQueryEvent.originalEvent;
|
||||||
var delta = event.wheelDeltaY || (-2 * event.deltaY);
|
var delta = event.wheelDeltaY || (-2 * event.deltaY);
|
||||||
|
@ -42,11 +42,6 @@
|
|||||||
*/
|
*/
|
||||||
ns.ShapeTool.prototype.releaseToolAt = function(col, row, color, frame, overlay, event) {
|
ns.ShapeTool.prototype.releaseToolAt = function(col, row, color, frame, overlay, event) {
|
||||||
overlay.clear();
|
overlay.clear();
|
||||||
if (event.shiftKey) {
|
|
||||||
var scaled = this.getScaledCoordinates_(col, row);
|
|
||||||
col = scaled.col;
|
|
||||||
row = scaled.row;
|
|
||||||
}
|
|
||||||
var coords = this.getCoordinates_(col, row, event);
|
var coords = this.getCoordinates_(col, row, event);
|
||||||
this.draw_(coords.col, coords.row, color, frame);
|
this.draw_(coords.col, coords.row, color, frame);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user