Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 绘制元素状态退出 #422

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/components/tools.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ const state = reactive({
// let drawHandler = null;
const addText = (option) => {
cancelDraw();
const text = new fabric.IText(t('everything_is_fine'), {
...defaultPosition,
...option,
Expand All @@ -269,6 +270,7 @@ const addText = (option) => {
// };
const addTextBox = (option) => {
cancelDraw();
const text = new fabric.Textbox(t('everything_goes_well'), {
...defaultPosition,
...option,
Expand All @@ -286,6 +288,7 @@ const addTextBox = (option) => {
};
const addTriangle = (option) => {
cancelDraw();
const triangle = new fabric.Triangle({
...defaultPosition,
...option,
Expand All @@ -303,6 +306,7 @@ const addTriangle = (option) => {
};
const addPolygon = (option) => {
cancelDraw();
const polygon = new fabric.Polygon(getPolygonVertices(5, 200), {
...defaultPosition,
...option,
Expand All @@ -328,7 +332,7 @@ const addPolygon = (option) => {
};
const addCircle = (option) => {
console.log(canvasEditor);
cancelDraw();
const circle = new fabric.Circle({
...defaultPosition,
...option,
Expand All @@ -345,6 +349,7 @@ const addCircle = (option) => {
};
const addRect = (option) => {
cancelDraw();
const rect = new fabric.Rect({
...defaultPosition,
...option,
Expand Down Expand Up @@ -496,6 +501,20 @@ onMounted(() => {
});
});
});
// 退出绘制状态
const cancelDraw = () => {
if (!state.isDrawingLineMode) return;
state.isDrawingLineMode = false;
state.lineType = '';
canvasEditor.setMode(false);
endConflictTools();
ensureObjectSelEvStatus(true, true);
};
onDeactivated(() => {
cancelDraw();
});
</script>

<style scoped lang="less">
Expand Down
Loading