lyb-pixi-js 1.12.44 → 1.12.46
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/LibPixiGridColumnLayout.d.ts +35 -0
- package/Components/Custom/LibPixiGridColumnLayout.js +40 -0
- package/Components/Custom/{LibPixiGridLayoutV2.d.ts → LibPixiGridRowLayout.d.ts} +6 -2
- package/Components/Custom/{LibPixiGridLayoutV2.js → LibPixiGridRowLayout.js} +6 -3
- package/Components/Custom/LibPixiInput.d.ts +1 -1
- package/README.md +36 -2
- package/Utils/LibPixiDialogManager/index.d.ts +2 -0
- package/Utils/LibPixiDialogManager/index.js +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface GridLayoutParams {
|
|
2
|
+
/** 行数 */
|
|
3
|
+
rowNum?: number;
|
|
4
|
+
/** 列间隔 */
|
|
5
|
+
colGap?: number;
|
|
6
|
+
/** 行间隔 */
|
|
7
|
+
rowGap?: number;
|
|
8
|
+
/** 元素列表 */
|
|
9
|
+
elementList?: any[];
|
|
10
|
+
/** 锚点X */
|
|
11
|
+
anchorX?: number;
|
|
12
|
+
/** 锚点Y */
|
|
13
|
+
anchorY?: number;
|
|
14
|
+
/** 每列最大行数 */
|
|
15
|
+
maxRow?: number;
|
|
16
|
+
/** 布局方向:ltr 左到右,rtl 右到左 */
|
|
17
|
+
direction?: "ltr" | "rtl";
|
|
18
|
+
}
|
|
19
|
+
import { Container } from "pixi.js";
|
|
20
|
+
/** @description 网格列布局 */
|
|
21
|
+
export declare class LibPixiGridColumnLayout<T extends Container> extends Container {
|
|
22
|
+
/** 参数 */
|
|
23
|
+
private _params;
|
|
24
|
+
/** 元素列表 */
|
|
25
|
+
private _elementList;
|
|
26
|
+
constructor(params?: GridLayoutParams);
|
|
27
|
+
/** @description 追加元素 */
|
|
28
|
+
push(element: T): void;
|
|
29
|
+
/** @description 列布局 */
|
|
30
|
+
layout(): void;
|
|
31
|
+
/** @description 获取列表元素 */
|
|
32
|
+
getList(): T[];
|
|
33
|
+
/** @description 销毁列表元素 */
|
|
34
|
+
destroyList(): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
/** @description 网格列布局 */
|
|
3
|
+
export class LibPixiGridColumnLayout 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 { rowNum = 1, colGap = 325, rowGap = 75, anchorX = 0, anchorY = 0, direction = "ltr", } = this._params;
|
|
19
|
+
const isRTL = direction === "rtl";
|
|
20
|
+
this._elementList.forEach((item, index) => {
|
|
21
|
+
const row = index % rowNum;
|
|
22
|
+
const col = Math.floor(index / rowNum);
|
|
23
|
+
item.x = isRTL ? -col * colGap : col * colGap;
|
|
24
|
+
item.y = row * rowGap;
|
|
25
|
+
});
|
|
26
|
+
const bounds = this.getLocalBounds();
|
|
27
|
+
this.pivot.set(bounds.x + bounds.width * anchorX, bounds.y + bounds.height * anchorY);
|
|
28
|
+
}
|
|
29
|
+
/** @description 获取列表元素 */
|
|
30
|
+
getList() {
|
|
31
|
+
return this._elementList;
|
|
32
|
+
}
|
|
33
|
+
/** @description 销毁列表元素 */
|
|
34
|
+
destroyList() {
|
|
35
|
+
this._elementList.forEach((item) => {
|
|
36
|
+
item.destroy();
|
|
37
|
+
});
|
|
38
|
+
this._elementList = [];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -7,10 +7,14 @@ export interface GridLayoutParams {
|
|
|
7
7
|
rowGap?: number;
|
|
8
8
|
/** 元素列表 */
|
|
9
9
|
elementList?: any[];
|
|
10
|
+
/** 锚点X */
|
|
11
|
+
anchorX?: number;
|
|
12
|
+
/** 锚点Y */
|
|
13
|
+
anchorY?: number;
|
|
10
14
|
}
|
|
11
15
|
import { Container } from "pixi.js";
|
|
12
|
-
/** @description
|
|
13
|
-
export declare class
|
|
16
|
+
/** @description 网格行布局 */
|
|
17
|
+
export declare class LibPixiGridRowLayout<T extends Container> extends Container {
|
|
14
18
|
/** 参数 */
|
|
15
19
|
private _params;
|
|
16
20
|
/** 元素列表 */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Container } from "pixi.js";
|
|
2
|
-
/** @description
|
|
3
|
-
export class
|
|
2
|
+
/** @description 网格行布局 */
|
|
3
|
+
export class LibPixiGridRowLayout extends Container {
|
|
4
4
|
constructor(params) {
|
|
5
5
|
super();
|
|
6
6
|
/** 元素列表 */
|
|
@@ -15,13 +15,16 @@ export class LibPixiGridLayoutV2 extends Container {
|
|
|
15
15
|
}
|
|
16
16
|
/** @description 布局 */
|
|
17
17
|
layout() {
|
|
18
|
-
const { colNum = this._elementList.length, colGap = 325, rowGap = 75, } = this._params;
|
|
18
|
+
const { colNum = this._elementList.length, colGap = 325, rowGap = 75, anchorX = 0, anchorY = 0, } = this._params;
|
|
19
19
|
this._elementList.forEach((item, index) => {
|
|
20
20
|
const col = index % colNum;
|
|
21
21
|
const row = Math.floor(index / colNum);
|
|
22
22
|
item.x = col * colGap;
|
|
23
23
|
item.y = row * rowGap;
|
|
24
24
|
});
|
|
25
|
+
// 根据 anchor 调整整体偏移
|
|
26
|
+
const bounds = this.getLocalBounds();
|
|
27
|
+
this.pivot.set(bounds.x + bounds.width * anchorX, bounds.y + bounds.height * anchorY);
|
|
25
28
|
}
|
|
26
29
|
/** @description 获取列表元素 */
|
|
27
30
|
getList() {
|
package/README.md
CHANGED
|
@@ -915,9 +915,9 @@ const amountContainer = new LibLabelValue({
|
|
|
915
915
|
|
|
916
916
|
> 内部创建文本类组,公共样式和单个设置样式,并整体支持换行
|
|
917
917
|
|
|
918
|
-
###
|
|
918
|
+
### LibPixiGridRowLayout-网格行布局
|
|
919
919
|
|
|
920
|
-
>
|
|
920
|
+
> 一列占满后进入下一列
|
|
921
921
|
|
|
922
922
|
### LibPixiAreaClick-扩大点击范围
|
|
923
923
|
|
|
@@ -927,6 +927,10 @@ const amountContainer = new LibLabelValue({
|
|
|
927
927
|
|
|
928
928
|
> 只支持一个标题和一个内容,一般用于一些隐私政策和服务条款
|
|
929
929
|
|
|
930
|
+
### LibPixiGridColumnLayout-网格列布局
|
|
931
|
+
|
|
932
|
+
> 一列占满后进入下一列,支持从左到右或从右到左
|
|
933
|
+
|
|
930
934
|
## Utils-工具方法
|
|
931
935
|
|
|
932
936
|
### LibPixiAudio-音频播放器
|
|
@@ -1077,6 +1081,36 @@ libPixiEvent(btn, "pointertap", () => {
|
|
|
1077
1081
|
removeEventListener();
|
|
1078
1082
|
}
|
|
1079
1083
|
});
|
|
1084
|
+
|
|
1085
|
+
//带动画
|
|
1086
|
+
libPixiEvent(tipIcon, "pointertap", () => {
|
|
1087
|
+
this._isShowTip = !this._isShowTip;
|
|
1088
|
+
gsap.to(tipContainer, {
|
|
1089
|
+
duration: 0.25,
|
|
1090
|
+
ease: this._isShowTip ? "back.out" : "back.in",
|
|
1091
|
+
pixi: {
|
|
1092
|
+
scale: this._isShowTip ? 1 : 0,
|
|
1093
|
+
},
|
|
1094
|
+
});
|
|
1095
|
+
|
|
1096
|
+
//列表显示后开始监听是否点击容器外
|
|
1097
|
+
if (this._isShowTip) {
|
|
1098
|
+
removeEventListener = libPixiOutsideClick(tipContainer, tipIcon, () => {
|
|
1099
|
+
this._isShowTip = false;
|
|
1100
|
+
gsap.to(tipContainer, {
|
|
1101
|
+
duration: 0.25,
|
|
1102
|
+
ease: "back.in",
|
|
1103
|
+
pixi: {
|
|
1104
|
+
scale: 0,
|
|
1105
|
+
},
|
|
1106
|
+
});
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
//如果通过再次点击按钮关闭了列表,则移除监听器
|
|
1110
|
+
else {
|
|
1111
|
+
removeEventListener?.();
|
|
1112
|
+
}
|
|
1113
|
+
});
|
|
1080
1114
|
```
|
|
1081
1115
|
|
|
1082
1116
|
### LibPixiPromiseTickerTimeout-TickerPromise 定时器
|
|
@@ -40,4 +40,13 @@ export class LibPixiDialogManager {
|
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
+
/** @description 关闭并销毁所有弹窗 */
|
|
44
|
+
closeAll() {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const ids = Object.keys(this.views);
|
|
47
|
+
for (const id of ids) {
|
|
48
|
+
yield this.close(id);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
43
52
|
}
|