From 8a7245bfeaeb7d3e77e60cd7048c5c2afa4d4c52 Mon Sep 17 00:00:00 2001 From: juliandescottes Date: Thu, 6 Sep 2012 00:14:32 +0200 Subject: [PATCH] onMouseUp triggering releaseToolAt unnecessarily --- js/piskel.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/js/piskel.js b/js/piskel.js index 6fcc9d37..58d2260b 100644 --- a/js/piskel.js +++ b/js/piskel.js @@ -193,6 +193,7 @@ $.namespace("pskl"); }, onMousedown : function (event) { + console.log("onMousedown"); isClicked = true; if(event.button == 2) { // right click @@ -211,6 +212,7 @@ $.namespace("pskl"); }, onMousemove : function (event) { + console.log("onMousemove"); var currentTime = new Date().getTime(); // Throttling of the mousemove event: if ((currentTime - previousMousemoveTime) > 40 ) { @@ -233,27 +235,30 @@ $.namespace("pskl"); }, onMouseup : function (event) { + console.log("onMouseup"); if(isClicked || isRightClicked) { // A mouse button was clicked on the drawing canvas before this mouseup event, // the user was probably drawing on the canvas. // Note: The mousemove movement (and the mouseup) may end up outside // of the drawing canvas. - // TODO: Remove that when we have the centralized redraw loop - this.previewsController.createPreviews(); - } - - if(isRightClicked) { - $.publish(Events.CANVAS_RIGHT_CLICK_RELEASED); - } - isClicked = false; - isRightClicked = false; - var spriteCoordinate = this.getSpriteCoordinate(event); - currentToolBehavior.releaseToolAt( + if(isRightClicked) { + $.publish(Events.CANVAS_RIGHT_CLICK_RELEASED); + } + isClicked = false; + isRightClicked = false; + var spriteCoordinate = this.getSpriteCoordinate(event); + currentToolBehavior.releaseToolAt( spriteCoordinate.col, spriteCoordinate.row, penColor, this.drawingController ); + + // TODO: Remove that when we have the centralized redraw loop + this.previewsController.createPreviews(); + } + + }, onCanvasContextMenu : function (event) {