fix:修复多种数据结构布局对齐问题

This commit is contained in:
黎智洲 2022-05-13 16:43:11 +08:00
parent bd6f9cd0d4
commit 4ef63ec96d
3 changed files with 20 additions and 12 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ node_modules
test test
dist dist
资料 资料
\copyDist2Anyview.js

View File

@ -1,6 +1,6 @@
const fs = require('fs'); const fs = require('fs');
const sourcePath = 'E:\\研究生\\StructV2\\dist\\sv.js'; const sourcePath = 'D:\\个人项目\\StructV2\\dist\\sv.js';
const targetPath = 'E:\\研究生\\froend_student\\src\\pages\\student\\assets\\js\\sv.js' const targetPath = 'D:\\个人项目\\froend_student\\src\\pages\\student\\assets\\js\\sv.js'
function COPY(from, to) { function COPY(from, to) {

View File

@ -284,8 +284,9 @@ export class LayoutProvider {
boundList: BoundingRect[] = [], boundList: BoundingRect[] = [],
groupPadding = this.viewOptions.groupPadding, groupPadding = this.viewOptions.groupPadding,
dx = 0, dx = 0,
dy = 0; dy = 0,
prevCenterX = 0,
prevCenterY = 0;
for (let i = 0; i < modelGroupList.length; i++) { for (let i = 0; i < modelGroupList.length; i++) {
group = modelGroupList[i]; group = modelGroupList[i];
@ -295,24 +296,30 @@ export class LayoutProvider {
if (layoutMode === ELayoutMode.HORIZONTAL) { if (layoutMode === ELayoutMode.HORIZONTAL) {
if (prevBound) { if (prevBound) {
dx = prevBound.x + prevBound.width - bound.x; dx = prevBound.x + prevBound.width - bound.x;
dy = prevCenterY - (bound.y + bound.height / 2);
} else { } else {
dx = bound.x; dx = bound.x;
} }
group.translate(dx, 0); group.translate(dx, dy);
Bound.translate(bound, dx, 0); Bound.translate(bound, dx, dy);
prevCenterY = bound.y + bound.height / 2;
} }
// 上到下垂直布局 // 上到下垂直布局
if (layoutMode === ELayoutMode.VERTICAL) { if (layoutMode === ELayoutMode.VERTICAL) {
if (prevBound) { if (prevBound) {
dx = prevCenterX - (bound.x + bound.width / 2);
dy = prevBound.y + prevBound.height - bound.y - groupPadding; dy = prevBound.y + prevBound.height - bound.y - groupPadding;
} else { } else {
dy = bound.y; dy = bound.y;
} }
group.translate(0, dy); group.translate(dx, dy);
Bound.translate(bound, 0, dy); Bound.translate(bound, dx, dy);
prevCenterX = bound.x + bound.width / 2;
} }
boundList.push(bound); boundList.push(bound);