Fix dithering right-click color inversion on FF/IE

Record pressed mouse button type only at mousedown time.
On IE/FF, the button type is not available during mousemove.
Did a round of testing on both FF and Chrome.
This commit is contained in:
grosbouddha 2015-09-15 00:57:13 +02:00
parent d0acb625cf
commit 7d964c7fde

View File

@ -17,12 +17,17 @@
* @override
*/
ns.DitheringTool.prototype.applyToolAt = function(col, row, color, frame, overlay, event) {
// On Firefox/IE, the clicked button type is not part of the mousemove event.
// Ensure we record the pressed button on the initial mousedown only.
if (event.type == 'mousedown') {
this.invertColors_ = event.button === Constants.RIGHT_BUTTON;
}
// Use primary selected color on cell with either an odd col or row.
// Use secondary color otherwise.
// When using the right mouse button, invert the above behavior to allow quick corrections.
var usePrimaryColor = (col + row) % 2;
var invertColors = event.button === Constants.RIGHT_BUTTON;
usePrimaryColor = invertColors ? !usePrimaryColor : usePrimaryColor;
usePrimaryColor = this.invertColors_ ? !usePrimaryColor : usePrimaryColor;
var selectedColors = pskl.app.selectedColorsService.getColors();
var ditheringColor = usePrimaryColor ? selectedColors[0] : selectedColors[1];