lyb-pixi-js 1.12.49 → 1.12.51
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.
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Container, Graphics } from "pixi.js";
|
|
2
|
+
/** @description 全屏黑色蒙版 */
|
|
3
|
+
export declare class LibPixiMaskBg extends Graphics {
|
|
4
|
+
/** 舞台 */
|
|
5
|
+
static stage: Container;
|
|
6
|
+
/** 蒙版透明度 */
|
|
7
|
+
static bgAlpha: number;
|
|
8
|
+
constructor();
|
|
9
|
+
/** @description 更新蒙版 */
|
|
10
|
+
updateSize(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Graphics } from "pixi.js";
|
|
2
|
+
/** @description 全屏黑色蒙版 */
|
|
3
|
+
export class LibPixiMaskBg extends Graphics {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
}
|
|
7
|
+
/** @description 更新蒙版 */
|
|
8
|
+
updateSize() {
|
|
9
|
+
const topLeft = LibPixiMaskBg.stage.toLocal({ x: 0, y: 0 });
|
|
10
|
+
const bottomRight = LibPixiMaskBg.stage.toLocal({
|
|
11
|
+
x: window.innerWidth,
|
|
12
|
+
y: window.innerHeight,
|
|
13
|
+
});
|
|
14
|
+
this.clear();
|
|
15
|
+
this.beginFill(0x000000, LibPixiMaskBg.bgAlpha);
|
|
16
|
+
this.drawRect(topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y);
|
|
17
|
+
this.endFill();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** 蒙版透明度 */
|
|
21
|
+
LibPixiMaskBg.bgAlpha = 0.5;
|
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { Container } from "pixi.js";
|
|
11
11
|
import gsap from "gsap";
|
|
12
12
|
import { LibJsResizeWatcher } from "lyb-js/Base/LibJsResizeWatcher.js";
|
|
13
|
-
import {
|
|
13
|
+
import { LibPixiMaskBg } from "../../../Components/Custom/LibPixiMaskBg";
|
|
14
14
|
import { libPixiEvent } from "../../LibPixiEvent";
|
|
15
15
|
import { LibPixiBaseContainer } from "./LibPixiBaseContainer";
|
|
16
16
|
/** @description 弹窗组件 */
|
|
@@ -19,10 +19,12 @@ export class LibPixiDialog extends LibPixiBaseContainer {
|
|
|
19
19
|
super();
|
|
20
20
|
/** 竖版缩放大小 */
|
|
21
21
|
this._vScale = 1;
|
|
22
|
+
LibPixiMaskBg.stage = LibPixiDialog.stage;
|
|
23
|
+
LibPixiMaskBg.bgAlpha = LibPixiDialog.bgAlpha;
|
|
22
24
|
const { onClickMask, vScale = 1, needBg = true } = params || {};
|
|
23
25
|
this._vScale = vScale;
|
|
24
26
|
//蒙版
|
|
25
|
-
this._maskUI = new
|
|
27
|
+
this._maskUI = new LibPixiMaskBg();
|
|
26
28
|
this.addChild(this._maskUI);
|
|
27
29
|
this._maskUI.alpha = 0;
|
|
28
30
|
this._maskUI.eventMode = "static";
|
|
@@ -40,8 +42,16 @@ export class LibPixiDialog extends LibPixiBaseContainer {
|
|
|
40
42
|
this._dialogContainer = new Container();
|
|
41
43
|
this.addChild(this._dialogContainer);
|
|
42
44
|
this._dialogContainer.eventMode = "static";
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
+
const resize1 = new LibJsResizeWatcher(LibPixiDialog.adaptation);
|
|
46
|
+
const resize2 = new LibJsResizeWatcher();
|
|
47
|
+
const off1 = resize1.on(this._redraw.bind(this), false);
|
|
48
|
+
const off2 = resize2.on(() => {
|
|
49
|
+
this._maskUI.updateSize();
|
|
50
|
+
});
|
|
51
|
+
this._offResize = () => {
|
|
52
|
+
off1();
|
|
53
|
+
off2();
|
|
54
|
+
};
|
|
45
55
|
}
|
|
46
56
|
/** @description 设置弹窗内容 */
|
|
47
57
|
setDialogContent(content) {
|
|
@@ -108,22 +118,15 @@ export class LibPixiDialog extends LibPixiBaseContainer {
|
|
|
108
118
|
}
|
|
109
119
|
/** @description 重绘弹窗 */
|
|
110
120
|
_redraw(w, h) {
|
|
121
|
+
this._maskUI.updateSize();
|
|
111
122
|
if (this._lastIsH === w > h)
|
|
112
123
|
return;
|
|
113
124
|
this._lastIsH = w > h;
|
|
114
125
|
let scale = 0;
|
|
115
126
|
if (w > h) {
|
|
116
|
-
this._maskUI.width = 2700;
|
|
117
|
-
this._maskUI.height = 1080;
|
|
118
|
-
this._maskUI.x = -(2700 - 1920) / 2;
|
|
119
|
-
this._maskUI.y = 0;
|
|
120
127
|
scale = 1;
|
|
121
128
|
}
|
|
122
129
|
else {
|
|
123
|
-
this._maskUI.width = 1080;
|
|
124
|
-
this._maskUI.height = 2700;
|
|
125
|
-
this._maskUI.x = 0;
|
|
126
|
-
this._maskUI.y = -(2700 - 1920) / 2;
|
|
127
130
|
scale = this._vScale;
|
|
128
131
|
}
|
|
129
132
|
this.updatePosition(w, h);
|