always set tool intern to mouse while image drop is active

This commit is contained in:
raphael 2020-05-04 14:40:24 +02:00
parent ea0e9f8452
commit 89dbabf1d2
1 changed files with 4 additions and 11 deletions

View File

@ -554,11 +554,8 @@ const whiteboard = {
}, },
addImgToCanvasByUrl: function (url) { addImgToCanvasByUrl: function (url) {
var _this = this; var _this = this;
var wasTextTool = false; var oldTool = _this.tool;
if (_this.tool === "text") { _this.setTool("mouse"); //Set to mouse tool while dropping to prevent errors
wasTextTool = true;
_this.setTool("mouse"); //Set to mouse tool while dropping to prevent errors
}
_this.imgDragActive = true; _this.imgDragActive = true;
_this.mouseOverlay.css({ "cursor": "default" }); _this.mouseOverlay.css({ "cursor": "default" });
var imgDiv = $('<div class="dragMe" style="border: 2px dashed gray; position:absolute; left:200px; top:200px; min-width:160px; min-height:100px; cursor:move;">' + var imgDiv = $('<div class="dragMe" style="border: 2px dashed gray; position:absolute; left:200px; top:200px; min-width:160px; min-height:100px; cursor:move;">' +
@ -574,9 +571,7 @@ const whiteboard = {
_this.imgDragActive = false; _this.imgDragActive = false;
_this.refreshCursorAppearance(); _this.refreshCursorAppearance();
imgDiv.remove(); imgDiv.remove();
if (wasTextTool) { _this.setTool(oldTool);
_this.setTool("text");
}
}); });
imgDiv.find(".addToCanvasBtn,.addToBackgroundBtn").click(function () { imgDiv.find(".addToCanvasBtn,.addToBackgroundBtn").click(function () {
var draw = $(this).attr("draw"); var draw = $(this).attr("draw");
@ -595,9 +590,7 @@ const whiteboard = {
_this.sendFunction({ "t": "addImgBG", "draw": draw, "url": url, "d": [width, height, left, top] }); _this.sendFunction({ "t": "addImgBG", "draw": draw, "url": url, "d": [width, height, left, top] });
_this.drawId++; _this.drawId++;
imgDiv.remove(); imgDiv.remove();
if (wasTextTool) { _this.setTool(oldTool);
_this.setTool("text");
}
}); });
_this.mouseOverlay.append(imgDiv); _this.mouseOverlay.append(imgDiv);
imgDiv.draggable(); imgDiv.draggable();