fix shift draw with line tool
This commit is contained in:
parent
707e8eacbb
commit
2f637671c3
@ -172,7 +172,7 @@ var whiteboard = {
|
|||||||
|
|
||||||
if (_this.tool === "line") {
|
if (_this.tool === "line") {
|
||||||
if (_this.pressedKeys.shift) {
|
if (_this.pressedKeys.shift) {
|
||||||
var angs = getRoundedAngles(currX, currY);
|
var angs = _this.getRoundedAngles(currX, currY);
|
||||||
currX = angs.x;
|
currX = angs.x;
|
||||||
currY = angs.y;
|
currY = angs.y;
|
||||||
}
|
}
|
||||||
@ -266,27 +266,27 @@ var whiteboard = {
|
|||||||
_this.sendFunction({ "t": "addTextBox", "d": [_this.drawcolor, fontsize, currX, currY, txId] });
|
_this.sendFunction({ "t": "addTextBox", "d": [_this.drawcolor, fontsize, currX, currY, txId] });
|
||||||
_this.addTextBox(_this.drawcolor, fontsize, currX, currY, txId, true);
|
_this.addTextBox(_this.drawcolor, fontsize, currX, currY, txId, true);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
function getRoundedAngles(currX, currY) { //For drawing lines at 0,45,90° ....
|
getRoundedAngles: function (currX, currY) { //For drawing lines at 0,45,90° ....
|
||||||
var x = currX - _this.startCoords[0];
|
var _this = this;
|
||||||
var y = currY - _this.startCoords[1];
|
var x = currX - _this.startCoords[0];
|
||||||
var angle = Math.atan2(x, y) * (180 / Math.PI);
|
var y = currY - _this.startCoords[1];
|
||||||
var angle45 = Math.round(angle / 45) * 45;
|
var angle = Math.atan2(x, y) * (180 / Math.PI);
|
||||||
if (angle45 % 90 == 0) {
|
var angle45 = Math.round(angle / 45) * 45;
|
||||||
if (Math.abs(currX - _this.startCoords[0]) > Math.abs(currY - _this.startCoords[1])) {
|
if (angle45 % 90 == 0) {
|
||||||
currY = _this.startCoords[1]
|
if (Math.abs(currX - _this.startCoords[0]) > Math.abs(currY - _this.startCoords[1])) {
|
||||||
} else {
|
currY = _this.startCoords[1]
|
||||||
currX = _this.startCoords[0]
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if ((currY - _this.startCoords[1]) * (currX - _this.startCoords[0]) > 0) {
|
currX = _this.startCoords[0]
|
||||||
currX = _this.startCoords[0] + (currY - _this.startCoords[1]);
|
}
|
||||||
} else {
|
} else {
|
||||||
currX = _this.startCoords[0] - (currY - _this.startCoords[1]);
|
if ((currY - _this.startCoords[1]) * (currX - _this.startCoords[0]) > 0) {
|
||||||
}
|
currX = _this.startCoords[0] + (currY - _this.startCoords[1]);
|
||||||
|
} else {
|
||||||
|
currX = _this.startCoords[0] - (currY - _this.startCoords[1]);
|
||||||
}
|
}
|
||||||
return { "x": currX, "y": currY };
|
|
||||||
}
|
}
|
||||||
|
return { "x": currX, "y": currY };
|
||||||
},
|
},
|
||||||
triggerMouseMove: function (e) {
|
triggerMouseMove: function (e) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
@ -324,7 +324,7 @@ var whiteboard = {
|
|||||||
} else if (_this.tool === "line") {
|
} else if (_this.tool === "line") {
|
||||||
if (_this.svgLine) {
|
if (_this.svgLine) {
|
||||||
if (_this.pressedKeys.shift) {
|
if (_this.pressedKeys.shift) {
|
||||||
var angs = getRoundedAngles(currX, currY);
|
var angs = _this.getRoundedAngles(currX, currY);
|
||||||
currX = angs.x;
|
currX = angs.x;
|
||||||
currY = angs.y;
|
currY = angs.y;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user