From 4ef63ec96de6863f04ea5a9f6d3c390156e3916c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=99=BA=E6=B4=B2?= <1543046129@qq.com> Date: Fri, 13 May 2022 16:43:11 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=A4=9A?= =?UTF-8?q?=E7=A7=8D=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E5=AF=B9=E9=BD=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- copyDist2Anyview.js | 4 ++-- src/View/layoutProvider.ts | 25 ++++++++++++++++--------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index dd3ba36..e18ccaa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules test dist -资料 \ No newline at end of file +资料 +\copyDist2Anyview.js \ No newline at end of file diff --git a/copyDist2Anyview.js b/copyDist2Anyview.js index 5550fb7..41bd22d 100644 --- a/copyDist2Anyview.js +++ b/copyDist2Anyview.js @@ -1,6 +1,6 @@ const fs = require('fs'); -const sourcePath = 'E:\\研究生\\StructV2\\dist\\sv.js'; -const targetPath = 'E:\\研究生\\froend_student\\src\\pages\\student\\assets\\js\\sv.js' +const sourcePath = 'D:\\个人项目\\StructV2\\dist\\sv.js'; +const targetPath = 'D:\\个人项目\\froend_student\\src\\pages\\student\\assets\\js\\sv.js' function COPY(from, to) { diff --git a/src/View/layoutProvider.ts b/src/View/layoutProvider.ts index 58bbaa8..4371032 100644 --- a/src/View/layoutProvider.ts +++ b/src/View/layoutProvider.ts @@ -282,37 +282,44 @@ export class LayoutProvider { prevBound: BoundingRect, bound: BoundingRect, boundList: BoundingRect[] = [], - groupPadding = this.viewOptions.groupPadding, + groupPadding = this.viewOptions.groupPadding, dx = 0, - dy = 0; + dy = 0, + prevCenterX = 0, + prevCenterY = 0; - for (let i = 0; i < modelGroupList.length; i++) { group = modelGroupList[i]; bound = group.getPaddingBound(groupPadding); - // 左往右水平布局 + // 左往右水平布局 if (layoutMode === ELayoutMode.HORIZONTAL) { if (prevBound) { dx = prevBound.x + prevBound.width - bound.x; + dy = prevCenterY - (bound.y + bound.height / 2); } else { dx = bound.x; } - group.translate(dx, 0); - Bound.translate(bound, dx, 0); + group.translate(dx, dy); + Bound.translate(bound, dx, dy); + + prevCenterY = bound.y + bound.height / 2; } - // 上到下垂直布局 + // 上到下垂直布局 if (layoutMode === ELayoutMode.VERTICAL) { if (prevBound) { + dx = prevCenterX - (bound.x + bound.width / 2); dy = prevBound.y + prevBound.height - bound.y - groupPadding; } else { dy = bound.y; } - group.translate(0, dy); - Bound.translate(bound, 0, dy); + group.translate(dx, dy); + Bound.translate(bound, dx, dy); + + prevCenterX = bound.x + bound.width / 2; } boundList.push(bound);