onMouseUp triggering releaseToolAt unnecessarily

This commit is contained in:
juliandescottes 2012-09-06 00:14:32 +02:00
parent 870cecc989
commit 8a7245bfea

View File

@ -193,6 +193,7 @@ $.namespace("pskl");
}, },
onMousedown : function (event) { onMousedown : function (event) {
console.log("onMousedown");
isClicked = true; isClicked = true;
if(event.button == 2) { // right click if(event.button == 2) { // right click
@ -211,6 +212,7 @@ $.namespace("pskl");
}, },
onMousemove : function (event) { onMousemove : function (event) {
console.log("onMousemove");
var currentTime = new Date().getTime(); var currentTime = new Date().getTime();
// Throttling of the mousemove event: // Throttling of the mousemove event:
if ((currentTime - previousMousemoveTime) > 40 ) { if ((currentTime - previousMousemoveTime) > 40 ) {
@ -233,27 +235,30 @@ $.namespace("pskl");
}, },
onMouseup : function (event) { onMouseup : function (event) {
console.log("onMouseup");
if(isClicked || isRightClicked) { if(isClicked || isRightClicked) {
// A mouse button was clicked on the drawing canvas before this mouseup event, // A mouse button was clicked on the drawing canvas before this mouseup event,
// the user was probably drawing on the canvas. // the user was probably drawing on the canvas.
// Note: The mousemove movement (and the mouseup) may end up outside // Note: The mousemove movement (and the mouseup) may end up outside
// of the drawing canvas. // of the drawing canvas.
// TODO: Remove that when we have the centralized redraw loop if(isRightClicked) {
this.previewsController.createPreviews(); $.publish(Events.CANVAS_RIGHT_CLICK_RELEASED);
} }
isClicked = false;
if(isRightClicked) { isRightClicked = false;
$.publish(Events.CANVAS_RIGHT_CLICK_RELEASED); var spriteCoordinate = this.getSpriteCoordinate(event);
} currentToolBehavior.releaseToolAt(
isClicked = false;
isRightClicked = false;
var spriteCoordinate = this.getSpriteCoordinate(event);
currentToolBehavior.releaseToolAt(
spriteCoordinate.col, spriteCoordinate.col,
spriteCoordinate.row, spriteCoordinate.row,
penColor, penColor,
this.drawingController this.drawingController
); );
// TODO: Remove that when we have the centralized redraw loop
this.previewsController.createPreviews();
}
}, },
onCanvasContextMenu : function (event) { onCanvasContextMenu : function (event) {