Move anchor icon load to mouse down to avoid an issue where the view hasn't loaded yet

This commit is contained in:
DD Liu 2020-01-29 12:01:01 -05:00
parent 231c98da3c
commit 3f46c04f19

View file

@ -56,17 +56,6 @@ class BoundingBoxTool {
this._modeMap[BoundingBoxModes.MOVE] = this._modeMap[BoundingBoxModes.MOVE] =
new MoveTool(mode, setSelectedItems, clearSelectedItems, onUpdateImage, switchToTextTool); new MoveTool(mode, setSelectedItems, clearSelectedItems, onUpdateImage, switchToTextTool);
this._currentCursor = null; this._currentCursor = null;
if (!anchorIcon) {
paper.project.importSVG(selectionAnchorIcon, {
onLoad: function (item) {
anchorIcon = item;
item.visible = false;
item.parent = getGuideLayer();
setGuideItem(item);
}
});
}
} }
/** /**
@ -91,6 +80,17 @@ class BoundingBoxTool {
* @return {boolean} True if there was a hit, false otherwise * @return {boolean} True if there was a hit, false otherwise
*/ */
onMouseDown (event, clone, multiselect, doubleClicked, hitOptions) { onMouseDown (event, clone, multiselect, doubleClicked, hitOptions) {
if (!anchorIcon) {
paper.project.importSVG(selectionAnchorIcon, {
onLoad: function (item) {
anchorIcon = item;
item.visible = false;
item.parent = getGuideLayer();
setGuideItem(item);
}
});
}
if (event.event.button > 0) return; // only first mouse button if (event.event.button > 0) return; // only first mouse button
const {hitResult, mode} = this._determineMode(event, multiselect, hitOptions); const {hitResult, mode} = this._determineMode(event, multiselect, hitOptions);
if (!hitResult) { if (!hitResult) {