lyb-pixi-js 1.12.34 → 1.12.36
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/LibPixiHeadingParagraphLayout.d.ts +18 -0
- package/Components/Custom/LibPixiHeadingParagraphLayout.js +27 -0
- package/README.md +6 -0
- package/Utils/LibPixiDialogManager/ui/LibPixiDialog.d.ts +10 -8
- package/Utils/LibPixiDialogManager/ui/LibPixiDialog.js +58 -52
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Container, type ITextStyle } from "pixi.js";
|
|
2
|
+
interface Params {
|
|
3
|
+
/** 文本列表 */
|
|
4
|
+
textList: {
|
|
5
|
+
type: "h" | "p";
|
|
6
|
+
text: string;
|
|
7
|
+
style?: Partial<ITextStyle>;
|
|
8
|
+
}[];
|
|
9
|
+
/** 内容宽度 */
|
|
10
|
+
width: number;
|
|
11
|
+
/** 默认样式 */
|
|
12
|
+
defaultStyle?: Partial<ITextStyle>;
|
|
13
|
+
}
|
|
14
|
+
/** @description 标题内容纵向排列 */
|
|
15
|
+
export declare class LibPixiHeadingParagraphLayout extends Container {
|
|
16
|
+
constructor(params: Params);
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Container, Text } from "pixi.js";
|
|
2
|
+
/** @description 标题内容纵向排列 */
|
|
3
|
+
export class LibPixiHeadingParagraphLayout extends Container {
|
|
4
|
+
constructor(params) {
|
|
5
|
+
super();
|
|
6
|
+
const { textList, width, defaultStyle = {} } = params;
|
|
7
|
+
const textItemList = [];
|
|
8
|
+
let lastText;
|
|
9
|
+
textList.forEach((item, index) => {
|
|
10
|
+
const text = new Text(item.text, Object.assign(Object.assign({ wordWrap: true, wordWrapWidth: width }, defaultStyle), item.style));
|
|
11
|
+
this.addChild(text);
|
|
12
|
+
textItemList.push(text);
|
|
13
|
+
if (item.type === "h") {
|
|
14
|
+
text.anchor.x = 0.5;
|
|
15
|
+
text.x = width / 2;
|
|
16
|
+
text.style.align = "center";
|
|
17
|
+
}
|
|
18
|
+
if (lastText) {
|
|
19
|
+
text.y = lastText.y + lastText.height + Number(defaultStyle.fontSize) / 2;
|
|
20
|
+
}
|
|
21
|
+
if (item.type === "h" && index !== 0) {
|
|
22
|
+
text.y += Number(defaultStyle.fontSize);
|
|
23
|
+
}
|
|
24
|
+
lastText = text;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
package/README.md
CHANGED
|
@@ -156,6 +156,8 @@ app.stage.addChild(box);
|
|
|
156
156
|
|
|
157
157
|
\- [LibPixiAreaClick-扩大点击范围](#LibPixiAreaClick-扩大点击范围)
|
|
158
158
|
|
|
159
|
+
\- [LibPixiHeadingParagraphLayout-文章标题内容布局](#LibPixiHeadingParagraphLayout-文章标题内容布局)
|
|
160
|
+
|
|
159
161
|
### 方法
|
|
160
162
|
|
|
161
163
|
\- [LibPixiAudio-音频播放器](#LibPixiAudio-音频播放器)
|
|
@@ -921,6 +923,10 @@ const amountContainer = new LibLabelValue({
|
|
|
921
923
|
|
|
922
924
|
> 解决当图片有空隙时,无法准确点击图片,如箭头和关闭按钮
|
|
923
925
|
|
|
926
|
+
### LibPixiHeadingParagraphLayout-文章标题内容布局
|
|
927
|
+
|
|
928
|
+
> 只支持一个标题和一个内容,一般用于一些隐私政策和服务条款
|
|
929
|
+
|
|
924
930
|
## Utils-工具方法
|
|
925
931
|
|
|
926
932
|
### LibPixiAudio-音频播放器
|
|
@@ -3,10 +3,10 @@ import { LibPixiBaseContainer } from "./LibPixiBaseContainer";
|
|
|
3
3
|
interface Params {
|
|
4
4
|
/** 是否需要显示黑色背景 */
|
|
5
5
|
needBg?: boolean;
|
|
6
|
-
/** 竖版初始大小 */
|
|
7
|
-
size?: number;
|
|
8
6
|
/** 点击蒙版回调 */
|
|
9
7
|
onClickMask?: () => void;
|
|
8
|
+
/** 竖版缩放大小 */
|
|
9
|
+
vScale?: number;
|
|
10
10
|
}
|
|
11
11
|
/** @description 弹窗组件 */
|
|
12
12
|
export declare class LibPixiDialog extends LibPixiBaseContainer {
|
|
@@ -21,18 +21,20 @@ export declare class LibPixiDialog extends LibPixiBaseContainer {
|
|
|
21
21
|
private _maskUI;
|
|
22
22
|
/** 内容容器 */
|
|
23
23
|
private _dialogContainer;
|
|
24
|
-
/**
|
|
25
|
-
private
|
|
26
|
-
/**
|
|
27
|
-
private
|
|
24
|
+
/** 竖版缩放大小 */
|
|
25
|
+
private _vScale;
|
|
26
|
+
/** 上一次是否为横版 */
|
|
27
|
+
private _lastIsH?;
|
|
28
28
|
/** 停止监听窗口 */
|
|
29
29
|
private _offResize?;
|
|
30
30
|
constructor(params?: Params);
|
|
31
31
|
/** @description 设置弹窗内容 */
|
|
32
32
|
setDialogContent(content: Container): void;
|
|
33
|
-
/** @description
|
|
34
|
-
|
|
33
|
+
/** @description 设置弹窗容器锚点 */
|
|
34
|
+
updatePivot(): void;
|
|
35
35
|
/** @description 关闭 */
|
|
36
36
|
close(): Promise<void>;
|
|
37
|
+
/** @description 重绘弹窗 */
|
|
38
|
+
private _redraw;
|
|
37
39
|
}
|
|
38
40
|
export {};
|
|
@@ -17,10 +17,10 @@ import { LibPixiBaseContainer } from "./LibPixiBaseContainer";
|
|
|
17
17
|
export class LibPixiDialog extends LibPixiBaseContainer {
|
|
18
18
|
constructor(params) {
|
|
19
19
|
super();
|
|
20
|
-
/**
|
|
21
|
-
this.
|
|
22
|
-
const {
|
|
23
|
-
this.
|
|
20
|
+
/** 竖版缩放大小 */
|
|
21
|
+
this._vScale = 1;
|
|
22
|
+
const { onClickMask, vScale = 1, needBg = true } = params || {};
|
|
23
|
+
this._vScale = vScale;
|
|
24
24
|
//蒙版
|
|
25
25
|
this._maskUI = new LibPixiRectangle(2700, 1080, "#000");
|
|
26
26
|
this.addChild(this._maskUI);
|
|
@@ -41,69 +41,45 @@ export class LibPixiDialog extends LibPixiBaseContainer {
|
|
|
41
41
|
this.addChild(this._dialogContainer);
|
|
42
42
|
this._dialogContainer.eventMode = "static";
|
|
43
43
|
const resize = new LibJsResizeWatcher(LibPixiDialog.adaptation);
|
|
44
|
-
this._offResize = resize.on(this.
|
|
44
|
+
this._offResize = resize.on(this._redraw.bind(this), false);
|
|
45
45
|
}
|
|
46
46
|
/** @description 设置弹窗内容 */
|
|
47
47
|
setDialogContent(content) {
|
|
48
48
|
this._dialogContainer.addChild(content);
|
|
49
|
-
if (LibPixiDialog.adaptation === "h") {
|
|
50
|
-
this.redraw(1920, 1080);
|
|
51
|
-
}
|
|
52
|
-
else if (LibPixiDialog.adaptation === "v") {
|
|
53
|
-
this.redraw(1080, 1920);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
this.redraw(window.innerWidth, window.innerHeight);
|
|
57
|
-
}
|
|
58
|
-
this._dialogContainer.scale.set(0);
|
|
59
49
|
this._dialogContainer.alpha = 0;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
50
|
+
requestAnimationFrame(() => {
|
|
51
|
+
this.updatePivot();
|
|
52
|
+
if (LibPixiDialog.adaptation === "h") {
|
|
53
|
+
this._redraw(1920, 1080);
|
|
54
|
+
}
|
|
55
|
+
else if (LibPixiDialog.adaptation === "v") {
|
|
56
|
+
this._redraw(1080, 1920);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this._redraw(window.innerWidth, window.innerHeight);
|
|
60
|
+
}
|
|
61
|
+
gsap.to(this._maskUI, {
|
|
62
|
+
duration: LibPixiDialog.durationIn,
|
|
63
|
+
alpha: LibPixiDialog.bgAlpha,
|
|
64
|
+
});
|
|
65
|
+
gsap.to(this._dialogContainer, {
|
|
66
|
+
duration: LibPixiDialog.durationIn,
|
|
67
|
+
alpha: 1,
|
|
68
|
+
});
|
|
67
69
|
});
|
|
68
70
|
}
|
|
69
|
-
/** @description
|
|
70
|
-
|
|
71
|
+
/** @description 设置弹窗容器锚点 */
|
|
72
|
+
updatePivot() {
|
|
71
73
|
const dialogW = this._dialogContainer.width / 2;
|
|
72
74
|
const dialogH = this._dialogContainer.height / 2;
|
|
73
75
|
this._dialogContainer.pivot.set(dialogW, dialogH);
|
|
74
|
-
|
|
75
|
-
const halfH = 1080 / 2;
|
|
76
|
-
if (w > h) {
|
|
77
|
-
this._maskUI.width = 2700;
|
|
78
|
-
this._maskUI.height = 1080;
|
|
79
|
-
this._maskUI.x = -(2700 - 1920) / 2;
|
|
80
|
-
this._dialogContainer.position.set(halfW, halfH);
|
|
81
|
-
this._size = 1;
|
|
82
|
-
if (this._dialogContainer.scale.x === this._initialSize) {
|
|
83
|
-
this._dialogContainer.scale.set(1);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
this._maskUI.width = 1080;
|
|
88
|
-
this._maskUI.height = 2700;
|
|
89
|
-
this._maskUI.x = 0;
|
|
90
|
-
this._dialogContainer.position.set(halfH, halfW);
|
|
91
|
-
this._size = this._initialSize;
|
|
92
|
-
if (this._dialogContainer.scale.x === 1) {
|
|
93
|
-
this._dialogContainer.scale.set(this._initialSize);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
gsap.to(this._dialogContainer.scale, {
|
|
97
|
-
duration: LibPixiDialog.durationIn,
|
|
98
|
-
ease: "back.out",
|
|
99
|
-
x: this._size,
|
|
100
|
-
y: this._size,
|
|
101
|
-
});
|
|
76
|
+
console.log(this._dialogContainer.width, this._dialogContainer.height);
|
|
102
77
|
}
|
|
103
78
|
/** @description 关闭 */
|
|
104
79
|
close() {
|
|
105
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
81
|
var _a;
|
|
82
|
+
this._maskUI.eventMode = "none";
|
|
107
83
|
(_a = this._offResize) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
108
84
|
gsap.to(this._dialogContainer.scale, {
|
|
109
85
|
duration: LibPixiDialog.durationOut,
|
|
@@ -123,6 +99,36 @@ export class LibPixiDialog extends LibPixiBaseContainer {
|
|
|
123
99
|
});
|
|
124
100
|
});
|
|
125
101
|
}
|
|
102
|
+
/** @description 重绘弹窗 */
|
|
103
|
+
_redraw(w, h) {
|
|
104
|
+
if (this._lastIsH === w > h)
|
|
105
|
+
return;
|
|
106
|
+
this._lastIsH = w > h;
|
|
107
|
+
let scale = 0;
|
|
108
|
+
const halfW = 1920 / 2;
|
|
109
|
+
const halfH = 1080 / 2;
|
|
110
|
+
if (w > h) {
|
|
111
|
+
this._maskUI.width = 2700;
|
|
112
|
+
this._maskUI.height = 1080;
|
|
113
|
+
this._maskUI.x = -(2700 - 1920) / 2;
|
|
114
|
+
this._dialogContainer.position.set(halfW, halfH);
|
|
115
|
+
scale = 1;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
this._maskUI.width = 1080;
|
|
119
|
+
this._maskUI.height = 2700;
|
|
120
|
+
this._maskUI.x = 0;
|
|
121
|
+
this._dialogContainer.position.set(halfH, halfW);
|
|
122
|
+
scale = this._vScale;
|
|
123
|
+
}
|
|
124
|
+
this._dialogContainer.scale.set(0);
|
|
125
|
+
gsap.to(this._dialogContainer.scale, {
|
|
126
|
+
duration: LibPixiDialog.durationIn,
|
|
127
|
+
ease: "back.out",
|
|
128
|
+
x: scale,
|
|
129
|
+
y: scale,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
126
132
|
}
|
|
127
133
|
/** 黑色背景透明度 */
|
|
128
134
|
LibPixiDialog.bgAlpha = 0.5;
|