move setting cursor to own its function

This commit is contained in:
raphael 2019-01-11 14:01:43 +01:00
parent 0228492bbe
commit 39cf577124

View File

@ -275,21 +275,13 @@ var whiteboard = {
destCanvasContext.drawImage(_this.canvas, left, top, width, height, 0, 0, width, height); destCanvasContext.drawImage(_this.canvas, left, top, width, height, 0, 0, width, height);
imgDiv.find(".xCanvasBtn").click(function () { imgDiv.find(".xCanvasBtn").click(function () {
_this.imgDragActive = false; _this.imgDragActive = false;
if (_this.tool === "pen") { _this.refreshCursorAppearance();
_this.mouseOverlay.css({ "cursor": "none" });
} else {
_this.mouseOverlay.css({ "cursor": "crosshair" });
}
imgDiv.remove(); imgDiv.remove();
dragOutOverlay.remove(); dragOutOverlay.remove();
}); });
imgDiv.find(".addToCanvasBtn").click(function () { imgDiv.find(".addToCanvasBtn").click(function () {
_this.imgDragActive = false; _this.imgDragActive = false;
if (_this.tool === "pen") { _this.refreshCursorAppearance();
_this.mouseOverlay.css({ "cursor": "none" });
} else {
_this.mouseOverlay.css({ "cursor": "crosshair" });
}
var widthT = imgDiv.width(); var widthT = imgDiv.width();
var heightT = imgDiv.height(); var heightT = imgDiv.height();
var p = imgDiv.position(); var p = imgDiv.position();
@ -489,25 +481,13 @@ var whiteboard = {
'</div>'); '</div>');
imgDiv.find(".xCanvasBtn").click(function () { imgDiv.find(".xCanvasBtn").click(function () {
_this.imgDragActive = false; _this.imgDragActive = false;
if (_this.tool === "pen") { this.refreshCursorAppearance();
_this.mouseOverlay.css({ "cursor": "none" });
} else if (_this.tool === "mouse") {
_this.mouseOverlay.css({ "cursor": "auto" });
} else {
_this.mouseOverlay.css({ "cursor": "crosshair" });
}
imgDiv.remove(); imgDiv.remove();
}); });
imgDiv.find(".addToCanvasBtn").click(function () { imgDiv.find(".addToCanvasBtn").click(function () {
var draw = $(this).attr("draw"); var draw = $(this).attr("draw");
_this.imgDragActive = false; _this.imgDragActive = false;
if (_this.tool === "pen") { this.refreshCursorAppearance();
_this.mouseOverlay.css({ "cursor": "none" });
} else if (_this.tool === "mouse") {
_this.mouseOverlay.css({ "cursor": "auto" });
} else {
_this.mouseOverlay.css({ "cursor": "crosshair" });
}
var width = imgDiv.width(); var width = imgDiv.width();
var height = imgDiv.height(); var height = imgDiv.height();
var p = imgDiv.position(); var p = imgDiv.position();
@ -569,13 +549,7 @@ var whiteboard = {
}, },
setTool: function (tool) { setTool: function (tool) {
this.tool = tool; this.tool = tool;
if (tool === "pen" || tool === "eraser") { this.refreshCursorAppearance();
this.mouseOverlay.css({ "cursor": "none" });
} else if (tool === "mouse") {
this.mouseOverlay.css({ "cursor": "default" });
} else {
this.mouseOverlay.css({ "cursor": "crosshair" });
}
this.mouseOverlay.find(".xCanvasBtn").click(); this.mouseOverlay.find(".xCanvasBtn").click();
}, },
handleEventsAndData: function (content, isNewData, doneCallback) { handleEventsAndData: function (content, isNewData, doneCallback) {
@ -725,5 +699,17 @@ var whiteboard = {
}, },
isRecPointCollision: function (rx, ry, rw, rh, px, py) { isRecPointCollision: function (rx, ry, rw, rh, px, py) {
return rx <= px && px <= rx + rw && ry <= py && py <= ry + rh; return rx <= px && px <= rx + rw && ry <= py && py <= ry + rh;
},
refreshCursorAppearance() { //Set cursor depending on current active tool
var _this = this;
if (_this.tool === "pen" || _this.tool === "eraser") {
_this.mouseOverlay.css({ "cursor": "none" });
} else if (_this.tool === "mouse") {
this.mouseOverlay.css({ "cursor": "default" });
} else if(_this.tool === "text") {
_this.mouseOverlay.css({ "cursor": "text" });
} else { //Line, Rec, Circle, Cutting
_this.mouseOverlay.css({ "cursor": "crosshair" });
}
} }
} }