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

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
node_modules
test
dist
资料
资料
\copyDist2Anyview.js

View File

@ -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) {

View File

@ -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);