|
@@ -1,5 +1,5 @@
|
|
|
import { Transform } from "konva/lib/Util";
|
|
|
-import { themeColor, themeMouseColors } from "@/constant/help-style.ts";
|
|
|
+import { themeMouseColors } from "@/constant/help-style.ts";
|
|
|
import {
|
|
|
BaseItem,
|
|
|
generateSnapInfos,
|
|
@@ -159,31 +159,98 @@ export const matResponse = (
|
|
|
data.height = dec.scaleY * initData.height;
|
|
|
data.width = dec.scaleX * initData.width;
|
|
|
|
|
|
+ let minwNdxs: number[] = []
|
|
|
+ let minhNdxs: number[] = []
|
|
|
let w = 0;
|
|
|
let h = 0;
|
|
|
- data.content.forEach((row, rndx) => {
|
|
|
- row.forEach((col, cndx) => {
|
|
|
- const initCol = initData.content[rndx][cndx];
|
|
|
- const minSize = getColMinSize(initCol);
|
|
|
- col.width = Math.max(
|
|
|
- minSize.w,
|
|
|
- data.width * (initCol.width / initData.width)
|
|
|
- );
|
|
|
- col.height = Math.max(
|
|
|
- minSize.h,
|
|
|
- data.height * (initCol.height / initData.height)
|
|
|
- );
|
|
|
- if (rndx === 0) {
|
|
|
- w += col.width;
|
|
|
- }
|
|
|
- if (cndx === 0) {
|
|
|
- h += col.height;
|
|
|
- }
|
|
|
+
|
|
|
+ const updateColSize = () => {
|
|
|
+ // 调整最小值
|
|
|
+ let curMinwNdxs = [...minwNdxs]
|
|
|
+ let curMinhNdxs = [...minhNdxs]
|
|
|
+
|
|
|
+ const getNewWidth = (ndx: number) => {
|
|
|
+
|
|
|
+ // data.width * (initCol.width / initData.width)
|
|
|
+
|
|
|
+ const initCol = initData.content[0][ndx]
|
|
|
+ let initWidth = initData.width
|
|
|
+ const index = minwNdxs.indexOf(ndx)
|
|
|
+ const spMinwNdxs = ~index ? minwNdxs.slice(0, index) : minwNdxs
|
|
|
+ spMinwNdxs.forEach(ndx => initWidth -= initData.content[0][ndx].width)
|
|
|
+ const width = (data.width - w) * (initCol.width / initWidth);
|
|
|
+ return width
|
|
|
+ }
|
|
|
+ const getNewHeight = (ndx: number) => {
|
|
|
+ const initCol = initData.content[ndx][0]
|
|
|
+ let initHeight = initData.height
|
|
|
+ const index = minhNdxs.indexOf(ndx)
|
|
|
+ const spMinhNdxs = ~index ? minhNdxs.slice(0, index) : minhNdxs
|
|
|
+ spMinhNdxs.forEach(ndx => initHeight -= initData.content[ndx][0].height)
|
|
|
+ const height = (data.height - h) * (initCol.height / initHeight)
|
|
|
+ return height
|
|
|
+ }
|
|
|
+
|
|
|
+ data.content.forEach((row, rndx) => {
|
|
|
+ row.forEach((col, cndx) => {
|
|
|
+ const initCol = initData.content[rndx][cndx];
|
|
|
+ const minSize = getColMinSize(initCol);
|
|
|
+
|
|
|
+ if (!curMinwNdxs.includes(cndx)) {
|
|
|
+ const neww = getNewWidth(cndx)
|
|
|
+ if (neww < minSize.w) {
|
|
|
+ col.width = minSize.w
|
|
|
+ if (rndx === 0) {
|
|
|
+ minwNdxs.push(cndx)
|
|
|
+ w += col.width
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!curMinhNdxs.includes(rndx)) {
|
|
|
+ const newh = getNewHeight(rndx)
|
|
|
+ if (newh < minSize.h) {
|
|
|
+ col.height = minSize.h
|
|
|
+ if (cndx === 0) {
|
|
|
+ minhNdxs.push(rndx)
|
|
|
+ h += col.height
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
+
|
|
|
+ if (curMinwNdxs.length !== minwNdxs.length || curMinhNdxs.length !== minhNdxs.length) {
|
|
|
+ return updateColSize()
|
|
|
+ }
|
|
|
+ const needUpdateH = curMinhNdxs.length !== data.content.length
|
|
|
+ const needUpdateW = curMinhNdxs.length !== data.content.length
|
|
|
+ if (!needUpdateH && !needUpdateW) return;
|
|
|
+
|
|
|
+ data.content.forEach((row, rndx) => {
|
|
|
+ row.forEach((col, cndx) => {
|
|
|
+ if (needUpdateW && !minwNdxs.includes(cndx)) {
|
|
|
+ col.width = getNewWidth(cndx)
|
|
|
+ }
|
|
|
+ if (needUpdateH && !minhNdxs.includes(rndx)) {
|
|
|
+ col.height = getNewHeight(rndx)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ data.content.forEach((row, rndx) => {
|
|
|
+ row.forEach((col, cndx) => {
|
|
|
+ if (needUpdateW && !minwNdxs.includes(cndx) && rndx === 0) {
|
|
|
+ w += col.width
|
|
|
+ }
|
|
|
+ if (needUpdateH &&!minhNdxs.includes(rndx) && cndx === 0) {
|
|
|
+ h += col.height
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ updateColSize()
|
|
|
const eqW = numEq(w, data.width);
|
|
|
const eqH = numEq(h, data.height);
|
|
|
-
|
|
|
if (!eqW || !eqH) {
|
|
|
if (operType) {
|
|
|
Object.assign(data, oldData);
|