diff --git a/package.json b/package.json index 351796b..e84ecd8 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", "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..206c03e 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, @@ -26,16 +27,17 @@ 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 = [{ - 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) => {