From 37cdcf1f5bc10094b848fdba5bddcb73c1dbdc40 Mon Sep 17 00:00:00 2001 From: mizy <1060950782@163.com> Date: Wed, 15 Mar 2023 17:47:23 +0800 Subject: [PATCH 1/2] add: polyline & autoscale fix: scroll time fix: scroll time fix: polyline --- package.json | 2 +- src/Shape/Lines/PolyLine.ts | 12 +++++++----- src/Utils/Controller.ts | 4 +++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 351796b..7298acc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vesoft-inc/veditor", - "version": "4.4.3-beta.3", + "version": "4.4.5-beta.4", "description": "svg flow editor", "main": "./dist/VEditor.js", "types": "./types/index.d.ts", diff --git a/src/Shape/Lines/PolyLine.ts b/src/Shape/Lines/PolyLine.ts index 0abfba1..67732ec 100644 --- a/src/Shape/Lines/PolyLine.ts +++ b/src/Shape/Lines/PolyLine.ts @@ -11,6 +11,7 @@ const PolyLine: LineRender = { ...Line, startSpace: 1, arcRadius: 5, + lineDistance: 50, makePath( from: InstanceNodePoint, to: InstanceNodePoint, @@ -28,14 +29,15 @@ const PolyLine: LineRender = { end.y += endSpace * Math.sin(endAngle); const disX = end.x - start.x; const disY = end.y - start.y; - + const lineDistanceY = this.lineDistance || (disY * .5); + const lineDistanceX = this.lineDistance || (disX * .5); const paths: any = [{ - x: start.x + disX * .5 * Math.cos(startAngle) * (disX > 0 ? 1 : -1), - y: start.y + disY * .5 * Math.sin(startAngle), + x: start.x + lineDistanceX * Math.cos(startAngle) * (disX > 0 ? 1 : -1), + y: start.y + lineDistanceY * Math.sin(startAngle), type: "L" }, { - x: end.x + disX * .5 * Math.cos(endAngle) * (disX > 0 ? 1 : -1), - y: end.y + disY * .5 * Math.sin(endAngle), + x: end.x + (disX - lineDistanceX) * Math.cos(endAngle) * (disX > 0 ? 1 : -1), + y: end.y + (disY - lineDistanceY) * Math.sin(endAngle), type: "L" }]; diff --git a/src/Utils/Controller.ts b/src/Utils/Controller.ts index 90bc93f..eaccf9c 100644 --- a/src/Utils/Controller.ts +++ b/src/Utils/Controller.ts @@ -17,6 +17,7 @@ class Controller extends Utils.Event { achors: number[] = []; status: string; startPosition: { x: any; y: any }; + disableScroll: boolean = false; constructor(editor: VEditor) { super(); this.editor = editor; @@ -113,15 +114,16 @@ class Controller extends Utils.Event { if (this.status === "disabled") { return; } - e.preventDefault(); if (e.ctrlKey) { // 双指 const newScale = Math.max(1 - e.deltaY * this.scaleRatio, 0.1); this.zoom(newScale, e.offsetX, e.offsetY); } else { + if (this.disableScroll) return; this.pan(-e.deltaX, -e.deltaY); } + e.preventDefault(); }; panStart = (ev: MouseEvent) => { From 2597e33dc2baf7abc0b4e2742dd2d7b71e18e67b Mon Sep 17 00:00:00 2001 From: mizy <1060950782@163.com> Date: Thu, 20 Apr 2023 13:43:53 +0800 Subject: [PATCH 2/2] fix: bug --- package.json | 2 +- src/Shape/Lines/PolyLine.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7298acc..e84ecd8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vesoft-inc/veditor", - "version": "4.4.5-beta.4", + "version": "4.4.5", "description": "svg flow editor", "main": "./dist/VEditor.js", "types": "./types/index.d.ts", diff --git a/src/Shape/Lines/PolyLine.ts b/src/Shape/Lines/PolyLine.ts index 67732ec..206c03e 100644 --- a/src/Shape/Lines/PolyLine.ts +++ b/src/Shape/Lines/PolyLine.ts @@ -27,8 +27,8 @@ const PolyLine: LineRender = { start.y += startSpace * Math.sin(startAngle); end.x += endSpace * Math.cos(endAngle); end.y += endSpace * Math.sin(endAngle); - const disX = end.x - start.x; - const disY = end.y - start.y; + const disX = Math.abs(end.x - start.x); + const disY = Math.abs(end.y - start.y); const lineDistanceY = this.lineDistance || (disY * .5); const lineDistanceX = this.lineDistance || (disX * .5); const paths: any = [{