lyb-pixi-js 1.12.35 → 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.
|
@@ -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,64 +41,39 @@ 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() {
|
|
@@ -124,6 +99,36 @@ export class LibPixiDialog extends LibPixiBaseContainer {
|
|
|
124
99
|
});
|
|
125
100
|
});
|
|
126
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
|
+
}
|
|
127
132
|
}
|
|
128
133
|
/** 黑色背景透明度 */
|
|
129
134
|
LibPixiDialog.bgAlpha = 0.5;
|