lyb-pixi-js 1.12.17 → 1.12.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Components/Custom/LibPixiArrangeLinearV2.d.ts +23 -0
- package/Components/Custom/LibPixiArrangeLinearV2.js +68 -0
- package/Components/Custom/LibPixiScrollContainerY.d.ts +7 -5
- package/Components/Custom/LibPixiScrollContainerY.js +17 -10
- package/README.md +4 -0
- package/Utils/LibPixiArrangeLinear.d.ts +13 -7
- package/Utils/LibPixiArrangeLinear.js +29 -12
- package/libPixiJs.d.ts +3 -0
- package/libPixiJs.js +3 -0
- package/lyb-pixi.js +76 -11
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
export interface GridLayoutParams {
|
|
3
|
+
gap?: number | number[];
|
|
4
|
+
direction?: "x" | "y";
|
|
5
|
+
colNum?: number;
|
|
6
|
+
elementList?: any[];
|
|
7
|
+
}
|
|
8
|
+
/** @description 线性排列 */
|
|
9
|
+
export declare class LibPixiArrangeLinearV2<T extends Container> extends Container {
|
|
10
|
+
/** 参数 */
|
|
11
|
+
private _params;
|
|
12
|
+
/** 元素列表 */
|
|
13
|
+
private _elementList;
|
|
14
|
+
constructor(params?: GridLayoutParams);
|
|
15
|
+
/** @description 追加元素 */
|
|
16
|
+
push(element: T): void;
|
|
17
|
+
/** @description 布局 */
|
|
18
|
+
layout(): void;
|
|
19
|
+
/** @description 获取列表元素 */
|
|
20
|
+
getList(): T[];
|
|
21
|
+
/** @description 销毁列表元素 */
|
|
22
|
+
destroyList(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
/** @description 线性排列 */
|
|
3
|
+
export class LibPixiArrangeLinearV2 extends Container {
|
|
4
|
+
constructor(params) {
|
|
5
|
+
super();
|
|
6
|
+
/** 元素列表 */
|
|
7
|
+
this._elementList = [];
|
|
8
|
+
this._params = params || {};
|
|
9
|
+
this._elementList = this._params.elementList || [];
|
|
10
|
+
}
|
|
11
|
+
/** @description 追加元素 */
|
|
12
|
+
push(element) {
|
|
13
|
+
this.addChild(element);
|
|
14
|
+
this._elementList.push(element);
|
|
15
|
+
}
|
|
16
|
+
/** @description 布局 */
|
|
17
|
+
layout() {
|
|
18
|
+
const { colNum = this._elementList.length, gap = 10, direction = "x" } = this._params;
|
|
19
|
+
let lastRowMax = 0; // 当前行(或列)的最大高度(或宽度),用于多行/多列换行时计算偏移
|
|
20
|
+
let rowOffset = 0; // 累计偏移量,控制换行后的整体偏移位置
|
|
21
|
+
this._elementList.forEach((item, index) => {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
const row = Math.floor(index / colNum); // 当前行号
|
|
24
|
+
const col = index % colNum; // 当前列号
|
|
25
|
+
if (direction === "x") {
|
|
26
|
+
//间隔
|
|
27
|
+
const gapValue = Array.isArray(gap) ? ((_a = gap[index - 1]) !== null && _a !== void 0 ? _a : 0) : gap;
|
|
28
|
+
//在每行第一列重置列偏移量
|
|
29
|
+
if (col === 0 && row > 0) {
|
|
30
|
+
rowOffset += lastRowMax + gapValue;
|
|
31
|
+
lastRowMax = 0;
|
|
32
|
+
}
|
|
33
|
+
// 横向位置 = 前一个元素的右侧 + 间隔;首列则从 0 开始
|
|
34
|
+
item.x = col === 0 ? 0 : this._elementList[index - 1].x + this._elementList[index - 1].width + gapValue;
|
|
35
|
+
// 纵向位置 = 当前累计的行偏移
|
|
36
|
+
rowOffset && (item.y = rowOffset);
|
|
37
|
+
// 更新当前行的最大高度
|
|
38
|
+
lastRowMax = Math.max(lastRowMax, item.height);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
//间隔
|
|
42
|
+
const gapValue = Array.isArray(gap) ? ((_b = gap[index - 1]) !== null && _b !== void 0 ? _b : 0) : gap;
|
|
43
|
+
//在每列第一行重置行偏移
|
|
44
|
+
if (col === 0 && row > 0) {
|
|
45
|
+
rowOffset += lastRowMax + gapValue;
|
|
46
|
+
lastRowMax = 0;
|
|
47
|
+
}
|
|
48
|
+
// 纵向位置 = 首列则从 0 开始,其余从前一个元素的y坐标 + 高度 + 间隔;
|
|
49
|
+
item.y = col === 0 ? 0 : this._elementList[index - 1].y + this._elementList[index - 1].height + gapValue;
|
|
50
|
+
// 横向位置 = 当前累计的列偏移
|
|
51
|
+
rowOffset && (item.x = rowOffset);
|
|
52
|
+
// 更新当前列的最大宽度
|
|
53
|
+
lastRowMax = Math.max(lastRowMax, item.width);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** @description 获取列表元素 */
|
|
58
|
+
getList() {
|
|
59
|
+
return this._elementList;
|
|
60
|
+
}
|
|
61
|
+
/** @description 销毁列表元素 */
|
|
62
|
+
destroyList() {
|
|
63
|
+
this._elementList.forEach((item) => {
|
|
64
|
+
item.destroy();
|
|
65
|
+
});
|
|
66
|
+
this._elementList = [];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Container } from "pixi.js";
|
|
1
|
+
import { Container, Texture } from "pixi.js";
|
|
2
2
|
import { LibPixiContainer } from "../Base/LibPixiContainer";
|
|
3
3
|
export interface LibPixiScrollContainerYParams {
|
|
4
4
|
/** 宽度 */
|
|
@@ -7,10 +7,6 @@ export interface LibPixiScrollContainerYParams {
|
|
|
7
7
|
height: number;
|
|
8
8
|
/** 滚动内容 */
|
|
9
9
|
scrollContent: Container;
|
|
10
|
-
/** 顶部边距 */
|
|
11
|
-
topMargin?: number;
|
|
12
|
-
/** 底部边距 */
|
|
13
|
-
bottomMargin?: number;
|
|
14
10
|
/** 背景色,用于定位 */
|
|
15
11
|
bgColor?: string;
|
|
16
12
|
/** 是否需要滚动条 */
|
|
@@ -21,6 +17,12 @@ export interface LibPixiScrollContainerYParams {
|
|
|
21
17
|
scrollbarWidth?: number;
|
|
22
18
|
/** 滚动条颜色 */
|
|
23
19
|
scrollbarColor?: string;
|
|
20
|
+
/** 自定义遮罩贴图 */
|
|
21
|
+
maskTexture?: Texture;
|
|
22
|
+
/** 遮罩X坐标 */
|
|
23
|
+
maskX?: number;
|
|
24
|
+
/** 遮罩Y坐标 */
|
|
25
|
+
maskY?: number;
|
|
24
26
|
/** 滚动触发 */
|
|
25
27
|
onScroll?: (y: number) => void;
|
|
26
28
|
}
|
|
@@ -8,7 +8,7 @@ import { LibPixiRectangle } from "../Base/LibPixiRectangle";
|
|
|
8
8
|
*/
|
|
9
9
|
export class LibPixiScrollContainerY extends LibPixiContainer {
|
|
10
10
|
constructor(params) {
|
|
11
|
-
const { width, height, scrollbar = false, scrollContent, scrollbarRgiht = 0, scrollbarWidth = 10, scrollbarColor = "#ffffff", onScroll, bgColor, } = params;
|
|
11
|
+
const { width, height, scrollbar = false, scrollContent, scrollbarRgiht = 0, scrollbarWidth = 10, scrollbarColor = "#ffffff", onScroll, bgColor, maskTexture, maskX = 0, maskY = 0, } = params;
|
|
12
12
|
super(width, height, bgColor);
|
|
13
13
|
/** 开始位置 */
|
|
14
14
|
this._startY = 0;
|
|
@@ -36,10 +36,20 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
|
|
|
36
36
|
this._content = new Container();
|
|
37
37
|
this.addChild(this._content);
|
|
38
38
|
this._content.addChild(this._scrollContent);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
//自定义遮罩
|
|
40
|
+
if (maskTexture) {
|
|
41
|
+
this._maskGraphics = new Sprite(maskTexture);
|
|
42
|
+
this.addChild(this._maskGraphics);
|
|
43
|
+
this._maskGraphics.width = width;
|
|
44
|
+
this._maskGraphics.height = height;
|
|
45
|
+
this._maskGraphics.position.set(maskX, maskY);
|
|
46
|
+
this.mask = this._maskGraphics;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this._maskGraphics = new LibPixiRectangle(width, height, "#000");
|
|
50
|
+
this.addChild(this._maskGraphics);
|
|
51
|
+
this.mask = this._maskGraphics;
|
|
52
|
+
}
|
|
43
53
|
// 创建滚动条
|
|
44
54
|
this._scrollbar = new LibPixiRectangle(scrollbarWidth, height, this._scrollbarColor);
|
|
45
55
|
this._scrollbar.x = width - (scrollbarRgiht || scrollbarWidth);
|
|
@@ -104,11 +114,8 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
|
|
|
104
114
|
* @param height 高度
|
|
105
115
|
*/
|
|
106
116
|
setDimensions(width, height) {
|
|
107
|
-
|
|
108
|
-
this._maskGraphics.
|
|
109
|
-
this._maskGraphics.beginFill(0x000000);
|
|
110
|
-
this._maskGraphics.drawRect(0, 0, width, height);
|
|
111
|
-
this._maskGraphics.endFill();
|
|
117
|
+
this._maskGraphics.width = width;
|
|
118
|
+
this._maskGraphics.height = height;
|
|
112
119
|
this.setSize(width, height);
|
|
113
120
|
this._scrollbar.x = width - (this._scrollbarRgiht || this._scrollbarWidth);
|
|
114
121
|
}
|
package/README.md
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { Container } from "pixi.js";
|
|
1
|
+
import type { Container } from "pixi.js";
|
|
2
2
|
/**
|
|
3
|
-
* @description
|
|
4
|
-
* @param items
|
|
5
|
-
* @param gap
|
|
6
|
-
* @param direction
|
|
7
|
-
* @param cols
|
|
8
|
-
* @
|
|
3
|
+
* @description 线性排列 PIXI.Container 元素(支持横向/纵向排列,多列布局、固定或自定义间隔)
|
|
4
|
+
* @param items 需要排列的容器数组
|
|
5
|
+
* @param gap 间隔,可为固定值或数组(数组长度必须等于 items.length - 1)
|
|
6
|
+
* @param direction 排列方向:"x" 横向排列,"y" 纵向排列
|
|
7
|
+
* @param cols 每行(或每列)最多的元素个数,默认为 Infinity(单行/单列)
|
|
8
|
+
* @example
|
|
9
|
+
* // 横向排列
|
|
10
|
+
* LibPixiArrangeLinear([sprite1, sprite2, sprite3], 10, "x");
|
|
11
|
+
* // 纵向排列
|
|
12
|
+
* LibPixiArrangeLinear([sprite1, sprite2, sprite3], 20, "y");
|
|
13
|
+
* // 两列布局
|
|
14
|
+
* LibPixiArrangeLinear([sprite1, sprite2, sprite3, sprite4], 10, "x", 2);
|
|
9
15
|
*/
|
|
10
16
|
export declare const LibPixiArrangeLinear: (items: Container[], gap: number | number[], direction?: "x" | "y", cols?: number) => void;
|
|
@@ -1,44 +1,61 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @description
|
|
3
|
-
* @param items
|
|
4
|
-
* @param gap
|
|
5
|
-
* @param direction
|
|
6
|
-
* @param cols
|
|
7
|
-
* @
|
|
2
|
+
* @description 线性排列 PIXI.Container 元素(支持横向/纵向排列,多列布局、固定或自定义间隔)
|
|
3
|
+
* @param items 需要排列的容器数组
|
|
4
|
+
* @param gap 间隔,可为固定值或数组(数组长度必须等于 items.length - 1)
|
|
5
|
+
* @param direction 排列方向:"x" 横向排列,"y" 纵向排列
|
|
6
|
+
* @param cols 每行(或每列)最多的元素个数,默认为 Infinity(单行/单列)
|
|
7
|
+
* @example
|
|
8
|
+
* // 横向排列
|
|
9
|
+
* LibPixiArrangeLinear([sprite1, sprite2, sprite3], 10, "x");
|
|
10
|
+
* // 纵向排列
|
|
11
|
+
* LibPixiArrangeLinear([sprite1, sprite2, sprite3], 20, "y");
|
|
12
|
+
* // 两列布局
|
|
13
|
+
* LibPixiArrangeLinear([sprite1, sprite2, sprite3, sprite4], 10, "x", 2);
|
|
8
14
|
*/
|
|
9
15
|
export const LibPixiArrangeLinear = (items, gap, direction = "x", cols = Infinity) => {
|
|
16
|
+
// 验证 gap 数组长度是否正确
|
|
10
17
|
if (Array.isArray(gap)) {
|
|
11
18
|
if (gap.length !== items.length - 1) {
|
|
12
19
|
console.error(new Error("间隔的数组长度只能等于元素数组长度-1"));
|
|
13
20
|
return;
|
|
14
21
|
}
|
|
15
22
|
}
|
|
16
|
-
let lastRowMax = 0; //
|
|
17
|
-
let rowOffset = 0; //
|
|
23
|
+
let lastRowMax = 0; // 当前行(或列)的最大高度(或宽度),用于多行/多列换行时计算偏移
|
|
24
|
+
let rowOffset = 0; // 累计偏移量,控制换行后的整体偏移位置
|
|
18
25
|
items.forEach((item, index) => {
|
|
19
26
|
var _a, _b;
|
|
20
|
-
const row = Math.floor(index / cols);
|
|
21
|
-
const col = index % cols;
|
|
27
|
+
const row = Math.floor(index / cols); // 当前行号
|
|
28
|
+
const col = index % cols; // 当前列号
|
|
22
29
|
if (direction === "x") {
|
|
30
|
+
//间隔
|
|
23
31
|
const gapValue = Array.isArray(gap) ? (_a = gap[index - 1]) !== null && _a !== void 0 ? _a : 0 : gap;
|
|
32
|
+
//在每行第一列重置列偏移量
|
|
24
33
|
if (col === 0 && row > 0) {
|
|
25
34
|
rowOffset += lastRowMax + gapValue;
|
|
26
35
|
lastRowMax = 0;
|
|
27
36
|
}
|
|
37
|
+
// 横向位置 = 前一个元素的右侧 + 间隔;首列则从 0 开始
|
|
28
38
|
item.x =
|
|
29
39
|
col === 0 ? 0 : items[index - 1].x + items[index - 1].width + gapValue;
|
|
30
|
-
|
|
40
|
+
// 纵向位置 = 当前累计的行偏移
|
|
41
|
+
rowOffset && (item.y = rowOffset);
|
|
42
|
+
// 更新当前行的最大高度
|
|
31
43
|
lastRowMax = Math.max(lastRowMax, item.height);
|
|
32
44
|
}
|
|
33
45
|
else {
|
|
46
|
+
//间隔
|
|
34
47
|
const gapValue = Array.isArray(gap) ? (_b = gap[index - 1]) !== null && _b !== void 0 ? _b : 0 : gap;
|
|
48
|
+
//在每列第一行重置行偏移
|
|
35
49
|
if (col === 0 && row > 0) {
|
|
36
50
|
rowOffset += lastRowMax + gapValue;
|
|
37
51
|
lastRowMax = 0;
|
|
38
52
|
}
|
|
53
|
+
// 纵向位置 = 首列则从 0 开始,其余从前一个元素的y坐标 + 高度 + 间隔;
|
|
39
54
|
item.y =
|
|
40
55
|
col === 0 ? 0 : items[index - 1].y + items[index - 1].height + gapValue;
|
|
41
|
-
|
|
56
|
+
// 横向位置 = 当前累计的列偏移
|
|
57
|
+
rowOffset && (item.x = rowOffset);
|
|
58
|
+
// 更新当前列的最大宽度
|
|
42
59
|
lastRowMax = Math.max(lastRowMax, item.width);
|
|
43
60
|
}
|
|
44
61
|
});
|
package/libPixiJs.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ import { LibPixiRoundedRect } from "./Components/Base/LibPixiRoundedRect";
|
|
|
35
35
|
import { LibPixiInput } from "./Components/Custom/LibPixiInput";
|
|
36
36
|
import { LibPixiGridLayoutV2 } from "./Utils/LibPixiGridLayoutV2";
|
|
37
37
|
import { LibPixiTicker } from "./Utils/LibPixiTicker";
|
|
38
|
+
import { LibPixiArrangeLinearV2 } from "./Components/Custom/LibPixiArrangeLinearV2";
|
|
38
39
|
/** @description 组件 */
|
|
39
40
|
export declare const Components: {
|
|
40
41
|
Base: {
|
|
@@ -150,6 +151,8 @@ export declare const Components: {
|
|
|
150
151
|
LibPixiTurntable: (num: number, distance: number, layoutCallback: (x: number, y: number, rotation: number, index: number) => void) => void;
|
|
151
152
|
/** @description 输入框 */
|
|
152
153
|
LibPixiInput: typeof LibPixiInput;
|
|
154
|
+
/** @description 线性排列 */
|
|
155
|
+
LibPixiArrangeLinearV2: typeof LibPixiArrangeLinearV2;
|
|
153
156
|
};
|
|
154
157
|
};
|
|
155
158
|
/** @description 方法 */
|
package/libPixiJs.js
CHANGED
|
@@ -54,6 +54,7 @@ import { LibPixiRoundedRect } from "./Components/Base/LibPixiRoundedRect";
|
|
|
54
54
|
import { LibPixiInput } from "./Components/Custom/LibPixiInput";
|
|
55
55
|
import { LibPixiGridLayoutV2 } from "./Utils/LibPixiGridLayoutV2";
|
|
56
56
|
import { LibPixiTicker } from "./Utils/LibPixiTicker";
|
|
57
|
+
import { LibPixiArrangeLinearV2 } from "./Components/Custom/LibPixiArrangeLinearV2";
|
|
57
58
|
/** @description 组件 */
|
|
58
59
|
export const Components = {
|
|
59
60
|
Base: {
|
|
@@ -169,6 +170,8 @@ export const Components = {
|
|
|
169
170
|
LibPixiTurntable,
|
|
170
171
|
/** @description 输入框 */
|
|
171
172
|
LibPixiInput,
|
|
173
|
+
/** @description 线性排列 */
|
|
174
|
+
LibPixiArrangeLinearV2,
|
|
172
175
|
},
|
|
173
176
|
};
|
|
174
177
|
/** @description 方法 */
|
package/lyb-pixi.js
CHANGED
|
@@ -49359,7 +49359,10 @@ void main(void)\r
|
|
|
49359
49359
|
scrollbarWidth = 10,
|
|
49360
49360
|
scrollbarColor = "#ffffff",
|
|
49361
49361
|
onScroll,
|
|
49362
|
-
bgColor
|
|
49362
|
+
bgColor,
|
|
49363
|
+
maskTexture,
|
|
49364
|
+
maskX = 0,
|
|
49365
|
+
maskY = 0
|
|
49363
49366
|
} = params;
|
|
49364
49367
|
super(width, height, bgColor);
|
|
49365
49368
|
this._startY = 0;
|
|
@@ -49379,9 +49382,18 @@ void main(void)\r
|
|
|
49379
49382
|
this._content = new Container();
|
|
49380
49383
|
this.addChild(this._content);
|
|
49381
49384
|
this._content.addChild(this._scrollContent);
|
|
49382
|
-
|
|
49383
|
-
|
|
49384
|
-
|
|
49385
|
+
if (maskTexture) {
|
|
49386
|
+
this._maskGraphics = new Sprite(maskTexture);
|
|
49387
|
+
this.addChild(this._maskGraphics);
|
|
49388
|
+
this._maskGraphics.width = width;
|
|
49389
|
+
this._maskGraphics.height = height;
|
|
49390
|
+
this._maskGraphics.position.set(maskX, maskY);
|
|
49391
|
+
this.mask = this._maskGraphics;
|
|
49392
|
+
} else {
|
|
49393
|
+
this._maskGraphics = new LibPixiRectangle(width, height, "#000");
|
|
49394
|
+
this.addChild(this._maskGraphics);
|
|
49395
|
+
this.mask = this._maskGraphics;
|
|
49396
|
+
}
|
|
49385
49397
|
this._scrollbar = new LibPixiRectangle(
|
|
49386
49398
|
scrollbarWidth,
|
|
49387
49399
|
height,
|
|
@@ -49451,10 +49463,8 @@ void main(void)\r
|
|
|
49451
49463
|
* @param height 高度
|
|
49452
49464
|
*/
|
|
49453
49465
|
setDimensions(width, height) {
|
|
49454
|
-
this._maskGraphics.
|
|
49455
|
-
this._maskGraphics.
|
|
49456
|
-
this._maskGraphics.drawRect(0, 0, width, height);
|
|
49457
|
-
this._maskGraphics.endFill();
|
|
49466
|
+
this._maskGraphics.width = width;
|
|
49467
|
+
this._maskGraphics.height = height;
|
|
49458
49468
|
this.setSize(width, height);
|
|
49459
49469
|
this._scrollbar.x = width - (this._scrollbarRgiht || this._scrollbarWidth);
|
|
49460
49470
|
}
|
|
@@ -55153,7 +55163,7 @@ void main(void){
|
|
|
55153
55163
|
lastRowMax = 0;
|
|
55154
55164
|
}
|
|
55155
55165
|
item.x = col === 0 ? 0 : items[index - 1].x + items[index - 1].width + gapValue;
|
|
55156
|
-
item.y = rowOffset;
|
|
55166
|
+
rowOffset && (item.y = rowOffset);
|
|
55157
55167
|
lastRowMax = Math.max(lastRowMax, item.height);
|
|
55158
55168
|
} else {
|
|
55159
55169
|
const gapValue = Array.isArray(gap) ? gap[index - 1] ?? 0 : gap;
|
|
@@ -55162,7 +55172,7 @@ void main(void){
|
|
|
55162
55172
|
lastRowMax = 0;
|
|
55163
55173
|
}
|
|
55164
55174
|
item.y = col === 0 ? 0 : items[index - 1].y + items[index - 1].height + gapValue;
|
|
55165
|
-
item.x = rowOffset;
|
|
55175
|
+
rowOffset && (item.x = rowOffset);
|
|
55166
55176
|
lastRowMax = Math.max(lastRowMax, item.width);
|
|
55167
55177
|
}
|
|
55168
55178
|
});
|
|
@@ -58425,6 +58435,59 @@ void main(void){
|
|
|
58425
58435
|
};
|
|
58426
58436
|
_LibPixiTicker._callbacks = /* @__PURE__ */ new Map();
|
|
58427
58437
|
let LibPixiTicker = _LibPixiTicker;
|
|
58438
|
+
class LibPixiArrangeLinearV2 extends Container {
|
|
58439
|
+
constructor(params) {
|
|
58440
|
+
super();
|
|
58441
|
+
this._elementList = [];
|
|
58442
|
+
this._params = params || {};
|
|
58443
|
+
this._elementList = this._params.elementList || [];
|
|
58444
|
+
}
|
|
58445
|
+
/** @description 追加元素 */
|
|
58446
|
+
push(element) {
|
|
58447
|
+
this.addChild(element);
|
|
58448
|
+
this._elementList.push(element);
|
|
58449
|
+
}
|
|
58450
|
+
/** @description 布局 */
|
|
58451
|
+
layout() {
|
|
58452
|
+
const { colNum = this._elementList.length, gap = 10, direction = "x" } = this._params;
|
|
58453
|
+
let lastRowMax = 0;
|
|
58454
|
+
let rowOffset = 0;
|
|
58455
|
+
this._elementList.forEach((item, index) => {
|
|
58456
|
+
const row = Math.floor(index / colNum);
|
|
58457
|
+
const col = index % colNum;
|
|
58458
|
+
if (direction === "x") {
|
|
58459
|
+
const gapValue = Array.isArray(gap) ? gap[index - 1] ?? 0 : gap;
|
|
58460
|
+
if (col === 0 && row > 0) {
|
|
58461
|
+
rowOffset += lastRowMax + gapValue;
|
|
58462
|
+
lastRowMax = 0;
|
|
58463
|
+
}
|
|
58464
|
+
item.x = col === 0 ? 0 : this._elementList[index - 1].x + this._elementList[index - 1].width + gapValue;
|
|
58465
|
+
rowOffset && (item.y = rowOffset);
|
|
58466
|
+
lastRowMax = Math.max(lastRowMax, item.height);
|
|
58467
|
+
} else {
|
|
58468
|
+
const gapValue = Array.isArray(gap) ? gap[index - 1] ?? 0 : gap;
|
|
58469
|
+
if (col === 0 && row > 0) {
|
|
58470
|
+
rowOffset += lastRowMax + gapValue;
|
|
58471
|
+
lastRowMax = 0;
|
|
58472
|
+
}
|
|
58473
|
+
item.y = col === 0 ? 0 : this._elementList[index - 1].y + this._elementList[index - 1].height + gapValue;
|
|
58474
|
+
rowOffset && (item.x = rowOffset);
|
|
58475
|
+
lastRowMax = Math.max(lastRowMax, item.width);
|
|
58476
|
+
}
|
|
58477
|
+
});
|
|
58478
|
+
}
|
|
58479
|
+
/** @description 获取列表元素 */
|
|
58480
|
+
getList() {
|
|
58481
|
+
return this._elementList;
|
|
58482
|
+
}
|
|
58483
|
+
/** @description 销毁列表元素 */
|
|
58484
|
+
destroyList() {
|
|
58485
|
+
this._elementList.forEach((item) => {
|
|
58486
|
+
item.destroy();
|
|
58487
|
+
});
|
|
58488
|
+
this._elementList = [];
|
|
58489
|
+
}
|
|
58490
|
+
}
|
|
58428
58491
|
const Components = {
|
|
58429
58492
|
Base: {
|
|
58430
58493
|
/** (已废弃)
|
|
@@ -58538,7 +58601,9 @@ void main(void){
|
|
|
58538
58601
|
/** @description 转盘布局 */
|
|
58539
58602
|
LibPixiTurntable,
|
|
58540
58603
|
/** @description 输入框 */
|
|
58541
|
-
LibPixiInput
|
|
58604
|
+
LibPixiInput,
|
|
58605
|
+
/** @description 线性排列 */
|
|
58606
|
+
LibPixiArrangeLinearV2
|
|
58542
58607
|
}
|
|
58543
58608
|
};
|
|
58544
58609
|
const Utils = {
|