From 96e1bb2a8d842dc37e4982a273a5bde48f6944c3 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 25 Jun 2012 16:37:06 -0700 Subject: Fix for IKNINJA-1615: Enable mouse up event on top of the user document scrollbar Chrome has a bug where mouse up does not fire when the mouse is released on top of a scrollbar. To work around this issue, I temporary increase the canvas to cover the scrollbar when drawing and then shrink it back on mouse up. Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index f4de3070..1de4e003 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -343,8 +343,6 @@ exports.Stage = Montage.create(Component, { // Hide the canvas this.hideCanvas(true); - this.eventManager.addEventListener( "appMouseUp", this, false); - this.eventManager.addEventListener( "enableStageMove", this, false); this.eventManager.addEventListener( "disableStageMove", this, false); @@ -454,6 +452,7 @@ exports.Stage = Montage.create(Component, { enableMouseInOut: { value: function() { + document.addEventListener("mouseup", this, true); this._drawingCanvas.addEventListener("mouseout", this, false); this._drawingCanvas.addEventListener("mouseover", this, false); } @@ -466,6 +465,19 @@ exports.Stage = Montage.create(Component, { } }, + captureMouseup: { + value: function(event) { + var target = event._event.target.getAttribute("data-montage-id"); + + if(target && target === "drawingCanvas") { + return true; + } else { + this.handleAppMouseUp(event); + return true; + } + } + }, + handleMouseout: { value: function(event) { this.outFlag = true; @@ -480,6 +492,11 @@ exports.Stage = Montage.create(Component, { handleMousedown: { value: function(event) { + + // Increase the canvas to cover the scroll bars + this._drawingCanvas.height = this._drawingCanvas.height + 11; + this._drawingCanvas.width = this._drawingCanvas.width + 11; + // Call the focus manager to set focus to blur any focus'd elements this.focusManager.setFocus(); @@ -509,13 +526,18 @@ exports.Stage = Montage.create(Component, { handleMouseup: { value: function(event) { + // Restore canvas to un-cover the scroll bars. + this._drawingCanvas.height = this._drawingCanvas.height - 11; + this._drawingCanvas.width = this._drawingCanvas.width - 11; // If the mouse up comes from dismissing the context menu return + if(this.contextMenu) { this.contextMenu = false; return; } - //this.disableMouseInOut(); + this.disableMouseInOut(); + document.removeEventListener("mouseup", this, true); this.application.ninja.toolsData.selectedToolInstance.HandleLeftButtonUp(event); @@ -563,12 +585,17 @@ exports.Stage = Montage.create(Component, { handleAppMouseUp: { value: function(event) { if(this.outFlag) { + this._drawingCanvas.height = this._drawingCanvas.height - 11; + this._drawingCanvas.width = this._drawingCanvas.width - 11; + if(this.application.ninja.toolsData.selectedToolInstance.isDrawing) { this.application.ninja.toolsData.selectedToolInstance.HandleLeftButtonUp(event); } this.disableMouseInOut(); this.outFlag = false; } + + document.removeEventListener("mouseup", this, true); } }, -- cgit v1.2.3