Fix : Tools event listeners are now on window

Smoother user experience. Drawing shapes, selecting etc... is no longer
blocked by either the drawing canvas or the document.
This commit is contained in:
jdescottes 2014-04-02 22:37:01 +02:00
parent c9251229fc
commit 1ce633bd06
3 changed files with 4 additions and 22 deletions

View File

@ -67,8 +67,6 @@
ns.DrawingController.prototype.initMouseBehavior = function() {
var body = $('body');
this.container.mousedown($.proxy(this.onMousedown_, this));
this.container.mouseenter($.proxy(this.onMouseenter_, this));
this.container.mouseleave($.proxy(this.onMouseleave_, this));
if (pskl.utils.UserAgent.isChrome) {
this.container.on('mousewheel', $.proxy(this.onMousewheel_, this));
@ -76,7 +74,8 @@
this.container.on('wheel', $.proxy(this.onMousewheel_, this));
}
body.mouseup($.proxy(this.onMouseup_, this));
window.addEventListener('mouseup', this.onMouseup_.bind(this));
window.addEventListener('mousemove', this.onMousemove_.bind(this));
// Deactivate right click:
body.contextmenu(this.onCanvasContextMenu_);
@ -116,21 +115,6 @@
$.publish(Events.ZOOM_CHANGED);
};
/**
* @private
*/
ns.DrawingController.prototype.onMouseenter_ = function (event) {
$('body').bind('mousemove', $.proxy(this.onMousemove_, this));
};
/**
* @private
*/
ns.DrawingController.prototype.onMouseleave_ = function (event) {
this.container.unbind('mousemove');
this.currentToolBehavior.hideHighlightedPixel(this.overlayFrame);
};
/**
* @private
*/

View File

@ -28,6 +28,8 @@
this.highlightedPixelCol = col;
this.highlightedPixelRow = row;
} else {
this.hideHighlightedPixel(overlay);
}
};

View File

@ -70,10 +70,6 @@
}
};
ns.BaseSelect.prototype.hideHighlightedPixel = function () {
// not implemented for selection tools
};
/**
* If we mouseover the selection draw inside the overlay frame, show the 'move' cursor
* instead of the 'select' one. It indicates that we can move the selection by dragndroping it.