lyb-pixi-js 1.12.5 → 1.12.6
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/README.md +4 -0
- package/Utils/LibPixiGridLayoutV2.d.ts +25 -0
- package/Utils/LibPixiGridLayoutV2.js +30 -0
- package/libPixiJs.d.ts +3 -0
- package/libPixiJs.js +3 -0
- package/lyb-pixi.js +29 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1229,6 +1229,10 @@ LibPixiDownScaleAnimation(sprite);
|
|
|
1229
1229
|
LibPixiGridLayout(cardList, 20, 3); //间隔20,一行三个
|
|
1230
1230
|
```
|
|
1231
1231
|
|
|
1232
|
+
### LibPixiGridLayoutV2-网格布局V2
|
|
1233
|
+
|
|
1234
|
+
> 省略自己创建数组对组件进行 `push` ,内部做了 `push` 处理
|
|
1235
|
+
|
|
1232
1236
|
### LibPixiArrangeLinear-间隔布局
|
|
1233
1237
|
|
|
1234
1238
|
> 按照指定方向(水平或垂直)排列元素,支持固定间隔或自定义每个间隔
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface GridLayoutParams {
|
|
2
|
+
/** 列数 */
|
|
3
|
+
colNum?: number;
|
|
4
|
+
/** 列间隔 */
|
|
5
|
+
colGap?: number;
|
|
6
|
+
/** 行间隔 */
|
|
7
|
+
rowGap?: number;
|
|
8
|
+
/** 元素列表 */
|
|
9
|
+
elementList?: any[];
|
|
10
|
+
}
|
|
11
|
+
import { Container } from "pixi.js";
|
|
12
|
+
/** @description 网格布局 */
|
|
13
|
+
export declare class LibPixiGridLayoutV2<T extends Container> extends Container {
|
|
14
|
+
/** 参数 */
|
|
15
|
+
private _params;
|
|
16
|
+
/** 元素列表 */
|
|
17
|
+
private _elementList;
|
|
18
|
+
constructor(params?: GridLayoutParams);
|
|
19
|
+
/** @description 追加元素 */
|
|
20
|
+
push(element: T): void;
|
|
21
|
+
/** @description 布局 */
|
|
22
|
+
layout(): void;
|
|
23
|
+
/** @description 获取列表元素 */
|
|
24
|
+
getList(): T[];
|
|
25
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
/** @description 网格布局 */
|
|
3
|
+
export class LibPixiGridLayoutV2 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 = 3, colGap = 325, rowGap = 75 } = this._params;
|
|
19
|
+
this._elementList.forEach((item, index) => {
|
|
20
|
+
const col = index % colNum;
|
|
21
|
+
const row = Math.floor(index / colNum);
|
|
22
|
+
item.x = col * colGap;
|
|
23
|
+
item.y = row * rowGap;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** @description 获取列表元素 */
|
|
27
|
+
getList() {
|
|
28
|
+
return this._elementList;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/libPixiJs.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ import { LibPixiOval } from "./Components/Base/LibPixiOval";
|
|
|
33
33
|
import { LibPixiRound } from "./Components/Base/LibPixiRound";
|
|
34
34
|
import { LibPixiRoundedRect } from "./Components/Base/LibPixiRoundedRect";
|
|
35
35
|
import { LibPixiInput } from "./Components/Custom/LibPixiInput";
|
|
36
|
+
import { LibPixiGridLayoutV2 } from "./Utils/LibPixiGridLayoutV2";
|
|
36
37
|
/** @description 组件 */
|
|
37
38
|
export declare const Components: {
|
|
38
39
|
Base: {
|
|
@@ -267,6 +268,8 @@ export declare const Utils: {
|
|
|
267
268
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiGridLayout-网格布局
|
|
268
269
|
*/
|
|
269
270
|
LibPixiGridLayout: (items: import("pixi.js").Container[], gap: number, cols?: number, direction?: "row" | "col") => void;
|
|
271
|
+
/** @description 网格布局V2 */
|
|
272
|
+
LibPixiGridLayoutV2: typeof LibPixiGridLayoutV2;
|
|
270
273
|
/**
|
|
271
274
|
* @description 按照指定方向(水平或垂直)排列元素,支持固定间隔或自定义每个间隔。
|
|
272
275
|
* @param items 要排列的元素数组。
|
package/libPixiJs.js
CHANGED
|
@@ -52,6 +52,7 @@ import { LibPixiOval } from "./Components/Base/LibPixiOval";
|
|
|
52
52
|
import { LibPixiRound } from "./Components/Base/LibPixiRound";
|
|
53
53
|
import { LibPixiRoundedRect } from "./Components/Base/LibPixiRoundedRect";
|
|
54
54
|
import { LibPixiInput } from "./Components/Custom/LibPixiInput";
|
|
55
|
+
import { LibPixiGridLayoutV2 } from "./Utils/LibPixiGridLayoutV2";
|
|
55
56
|
/** @description 组件 */
|
|
56
57
|
export const Components = {
|
|
57
58
|
Base: {
|
|
@@ -286,6 +287,8 @@ export const Utils = {
|
|
|
286
287
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiGridLayout-网格布局
|
|
287
288
|
*/
|
|
288
289
|
LibPixiGridLayout,
|
|
290
|
+
/** @description 网格布局V2 */
|
|
291
|
+
LibPixiGridLayoutV2,
|
|
289
292
|
/**
|
|
290
293
|
* @description 按照指定方向(水平或垂直)排列元素,支持固定间隔或自定义每个间隔。
|
|
291
294
|
* @param items 要排列的元素数组。
|
package/lyb-pixi.js
CHANGED
|
@@ -58322,6 +58322,33 @@ void main(void){
|
|
|
58322
58322
|
}
|
|
58323
58323
|
}
|
|
58324
58324
|
}
|
|
58325
|
+
class LibPixiGridLayoutV2 extends Container {
|
|
58326
|
+
constructor(params) {
|
|
58327
|
+
super();
|
|
58328
|
+
this._elementList = [];
|
|
58329
|
+
this._params = params || {};
|
|
58330
|
+
this._elementList = this._params.elementList || [];
|
|
58331
|
+
}
|
|
58332
|
+
/** @description 追加元素 */
|
|
58333
|
+
push(element) {
|
|
58334
|
+
this.addChild(element);
|
|
58335
|
+
this._elementList.push(element);
|
|
58336
|
+
}
|
|
58337
|
+
/** @description 布局 */
|
|
58338
|
+
layout() {
|
|
58339
|
+
const { colNum = 3, colGap = 325, rowGap = 75 } = this._params;
|
|
58340
|
+
this._elementList.forEach((item, index) => {
|
|
58341
|
+
const col = index % colNum;
|
|
58342
|
+
const row = Math.floor(index / colNum);
|
|
58343
|
+
item.x = col * colGap;
|
|
58344
|
+
item.y = row * rowGap;
|
|
58345
|
+
});
|
|
58346
|
+
}
|
|
58347
|
+
/** @description 获取列表元素 */
|
|
58348
|
+
getList() {
|
|
58349
|
+
return this._elementList;
|
|
58350
|
+
}
|
|
58351
|
+
}
|
|
58325
58352
|
const Components = {
|
|
58326
58353
|
Base: {
|
|
58327
58354
|
/** (已废弃)
|
|
@@ -58554,6 +58581,8 @@ void main(void){
|
|
|
58554
58581
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiGridLayout-网格布局
|
|
58555
58582
|
*/
|
|
58556
58583
|
LibPixiGridLayout,
|
|
58584
|
+
/** @description 网格布局V2 */
|
|
58585
|
+
LibPixiGridLayoutV2,
|
|
58557
58586
|
/**
|
|
58558
58587
|
* @description 按照指定方向(水平或垂直)排列元素,支持固定间隔或自定义每个间隔。
|
|
58559
58588
|
* @param items 要排列的元素数组。
|