lyb-pixi-js 1.8.6 → 1.8.8

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.
@@ -8,7 +8,7 @@ import { gsap } from "gsap";
8
8
  */
9
9
  export class LibPixiScrollContainerY extends LibPixiContainer {
10
10
  constructor(params) {
11
- const { width, height, scrollbar = false, scrollContent, scrollbarRgiht, scrollbarWidth = 10, scrollbarColor = "#F8A500", } = params;
11
+ const { width, height, scrollbar = false, scrollContent, scrollbarRgiht, scrollbarWidth = 10, scrollbarColor = "#ffffff", } = params;
12
12
  super(width, height);
13
13
  /** 开始位置 */
14
14
  this._startY = 0;
@@ -0,0 +1,28 @@
1
+ import type { Container } from "pixi.js";
2
+ import type { LibPixiBaseContainer } from "./ui/LibPixiBaseContainer";
3
+ export { LibPixiBaseContainer } from "./ui/LibPixiBaseContainer";
4
+ export { LibPixiDialog } from "./ui/LibPixiDialog";
5
+ interface IViewCtor {
6
+ new (...args: any[]): LibPixiBaseContainer;
7
+ }
8
+ /** @description 基础容器管理器 */
9
+ export declare class LibPixiBaseContainerManager {
10
+ /** 视图表 */
11
+ private views;
12
+ /** 上一次方向 */
13
+ private lastOrientation;
14
+ /** open时显示的元素的父容器 */
15
+ private _openContainer;
16
+ constructor(parent: Container);
17
+ /**
18
+ * 打开界面
19
+ * @param View 实例类型或构造方法
20
+ * @param args 实例参数
21
+ */
22
+ open<T extends IViewCtor>(View: T, id: string, ...args: ConstructorParameters<T>): InstanceType<T>;
23
+ /** @description 关闭页面,会调用页面的 onBeforeUnmount 事件,里面会做关闭动画,动画结束后会自动销毁
24
+ * @param id 页面名称
25
+ */
26
+ close(id: string): void;
27
+ private resize;
28
+ }
@@ -0,0 +1,62 @@
1
+ export { LibPixiBaseContainer } from "./ui/LibPixiBaseContainer";
2
+ export { LibPixiDialog } from "./ui/LibPixiDialog";
3
+ /** @description 基础容器管理器 */
4
+ export class LibPixiBaseContainerManager {
5
+ constructor(parent) {
6
+ /** 视图表 */
7
+ this.views = {};
8
+ /** 上一次方向 */
9
+ this.lastOrientation = "h";
10
+ this._openContainer = parent;
11
+ window.addEventListener("resize", () => {
12
+ var _a;
13
+ const w = window.innerWidth;
14
+ const h = window.innerHeight;
15
+ const orientation = w > h ? "h" : "v";
16
+ if (orientation !== this.lastOrientation) {
17
+ (_a = this.resize) === null || _a === void 0 ? void 0 : _a.call(this, window.innerWidth, window.innerHeight);
18
+ this.lastOrientation = orientation;
19
+ }
20
+ });
21
+ }
22
+ /**
23
+ * 打开界面
24
+ * @param View 实例类型或构造方法
25
+ * @param args 实例参数
26
+ */
27
+ open(View, id, ...args) {
28
+ var _a;
29
+ const view = new View(...args);
30
+ this._openContainer.addChild(view);
31
+ (_a = view.resize) === null || _a === void 0 ? void 0 : _a.call(view, window.innerWidth, window.innerHeight);
32
+ this.views[id] = view;
33
+ return view;
34
+ }
35
+ /** @description 关闭页面,会调用页面的 onBeforeUnmount 事件,里面会做关闭动画,动画结束后会自动销毁
36
+ * @param id 页面名称
37
+ */
38
+ close(id) {
39
+ const view = this.views[id];
40
+ if (view) {
41
+ if (view.beforeUnmount) {
42
+ view.beforeUnmount(() => {
43
+ requestAnimationFrame(() => {
44
+ view.destroy({ children: true });
45
+ });
46
+ });
47
+ }
48
+ else {
49
+ requestAnimationFrame(() => {
50
+ view.destroy({ children: true });
51
+ });
52
+ }
53
+ delete this.views[id];
54
+ }
55
+ }
56
+ resize(w, h) {
57
+ Object.values(this.views).forEach((view) => {
58
+ var _a;
59
+ (_a = view.resize) === null || _a === void 0 ? void 0 : _a.call(view, w, h);
60
+ });
61
+ }
62
+ }
@@ -0,0 +1,13 @@
1
+ import { Container } from "pixi.js";
2
+ /** @description 基础视图,所有弹窗或页面都基于此视图来管理视图生命周期 */
3
+ export declare class LibPixiBaseContainer extends Container {
4
+ /** 调用 GameDialogManager.close 时调用 */
5
+ beforeUnmount?: (destroy: () => void) => void;
6
+ /** 窗口大小发生改变后调用 */
7
+ resize?: (w: number, h: number) => void;
8
+ constructor();
9
+ /** @description 卸载前回调,需要调用回调参数进行手动销毁 */
10
+ protected _onBeforeUnmount(beforeUnmount: (destroy: () => void) => void): void;
11
+ /** @description 窗口大小发生改变后回调 */
12
+ protected _onResize(resize: (w: number, h: number) => void): void;
13
+ }
@@ -0,0 +1,15 @@
1
+ import { Container } from "pixi.js";
2
+ /** @description 基础视图,所有弹窗或页面都基于此视图来管理视图生命周期 */
3
+ export class LibPixiBaseContainer extends Container {
4
+ constructor() {
5
+ super();
6
+ }
7
+ /** @description 卸载前回调,需要调用回调参数进行手动销毁 */
8
+ _onBeforeUnmount(beforeUnmount) {
9
+ this.beforeUnmount = beforeUnmount;
10
+ }
11
+ /** @description 窗口大小发生改变后回调 */
12
+ _onResize(resize) {
13
+ this.resize = resize;
14
+ }
15
+ }
@@ -0,0 +1,31 @@
1
+ import { Container } from "pixi.js";
2
+ import { LibPixiBaseContainer } from "./LibPixiBaseContainer";
3
+ interface Params {
4
+ /** 是否需要显示黑色背景 */
5
+ needBg?: boolean;
6
+ /** 竖版初始大小 */
7
+ size?: number;
8
+ /** 点击蒙版回调 */
9
+ onClickMask?: () => void;
10
+ }
11
+ /** @description 弹窗组件 */
12
+ export declare class LibPixiDialog extends LibPixiBaseContainer {
13
+ /** 蒙版UI */
14
+ private maskUI;
15
+ /** 居中容器 */
16
+ private centerContainer;
17
+ /** 内容容器 */
18
+ private dialogContainer;
19
+ /** 当前大小 */
20
+ private size;
21
+ /** 竖版初始大小 */
22
+ private initialSize;
23
+ /** 是否处于关闭动画状态 */
24
+ private isCloseAnimating;
25
+ constructor(params?: Params);
26
+ /** @description 设置弹窗内容 */
27
+ setDialogContent(content: Container): void;
28
+ /** @description 关闭 */
29
+ close(): Promise<void>;
30
+ }
31
+ export {};
@@ -0,0 +1,120 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { Container } from "pixi.js";
11
+ import gsap from "gsap";
12
+ import { LibPixiBaseContainer } from "./LibPixiBaseContainer";
13
+ import { LibPixiRectBgColor } from "../../../Components/Base/LibPixiRectBgColor";
14
+ import { libPixiEvent } from '../../LibPixiEvent';
15
+ /** @description 弹窗组件 */
16
+ export class LibPixiDialog extends LibPixiBaseContainer {
17
+ constructor(params) {
18
+ super();
19
+ /** 当前大小 */
20
+ this.size = 1;
21
+ /** 是否处于关闭动画状态 */
22
+ this.isCloseAnimating = false;
23
+ const { size = 1, onClickMask, needBg = true } = params || {};
24
+ this.initialSize = size;
25
+ //蒙版
26
+ this.maskUI = new LibPixiRectBgColor({
27
+ bgColor: "#000",
28
+ width: 2700,
29
+ height: 1080,
30
+ });
31
+ this.addChild(this.maskUI);
32
+ this.maskUI.alpha = 0;
33
+ this.maskUI.eventMode = "static";
34
+ this.maskUI.visible = needBg;
35
+ if (onClickMask) {
36
+ libPixiEvent(this.maskUI, "pointertap", () => {
37
+ if (this.isCloseAnimating)
38
+ return;
39
+ onClickMask === null || onClickMask === void 0 ? void 0 : onClickMask();
40
+ });
41
+ }
42
+ //居中容器
43
+ this.centerContainer = new Container();
44
+ this.addChild(this.centerContainer);
45
+ this.centerContainer.eventMode = "static";
46
+ //弹窗内容容器
47
+ this.dialogContainer = new Container();
48
+ }
49
+ /** @description 设置弹窗内容 */
50
+ setDialogContent(content) {
51
+ this.dialogContainer.addChild(content);
52
+ this.centerContainer.addChild(this.dialogContainer);
53
+ const w = this.dialogContainer.width / 2;
54
+ const h = this.dialogContainer.height / 2;
55
+ this.dialogContainer.pivot.set(w, h);
56
+ this.dialogContainer.scale.set(0);
57
+ this.dialogContainer.alpha = 0;
58
+ // this.dialogContainer.y = -55;
59
+ gsap.to(this.maskUI, {
60
+ duration: 0.5,
61
+ alpha: 0.5,
62
+ });
63
+ gsap.to(this.dialogContainer, {
64
+ duration: 0.5,
65
+ alpha: 1,
66
+ });
67
+ this._onResize((w, h) => {
68
+ const halfW = 1920 / 2;
69
+ const halfH = 1080 / 2;
70
+ if (w > h) {
71
+ this.maskUI.renderBg(2700, 1080);
72
+ this.maskUI.x = -(2700 - 1920) / 2;
73
+ this.centerContainer.position.set(halfW, halfH);
74
+ this.size = 1;
75
+ if (this.dialogContainer.scale.x === this.initialSize) {
76
+ this.dialogContainer.scale.set(1);
77
+ }
78
+ }
79
+ else {
80
+ this.maskUI.renderBg(1080, 2700);
81
+ this.maskUI.x = 0;
82
+ this.centerContainer.position.set(halfH, halfW);
83
+ this.size = this.initialSize;
84
+ if (this.dialogContainer.scale.x === 1) {
85
+ this.dialogContainer.scale.set(this.initialSize);
86
+ }
87
+ }
88
+ gsap.to(this.dialogContainer.scale, {
89
+ duration: 0.5,
90
+ ease: "back.out",
91
+ x: this.size,
92
+ y: this.size,
93
+ });
94
+ });
95
+ }
96
+ /** @description 关闭 */
97
+ close() {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ if (this.isCloseAnimating)
100
+ return;
101
+ this.isCloseAnimating = true;
102
+ gsap.to(this.dialogContainer.scale, {
103
+ duration: 0.5,
104
+ ease: "back.in",
105
+ x: 0,
106
+ y: 0,
107
+ });
108
+ gsap.to(this.dialogContainer, {
109
+ duration: 0.5,
110
+ delay: 0.25,
111
+ alpha: 0,
112
+ });
113
+ yield gsap.to(this.maskUI, {
114
+ duration: 0.5,
115
+ delay: 0.25,
116
+ alpha: 0,
117
+ });
118
+ });
119
+ }
120
+ }
package/lyb-pixi.js CHANGED
@@ -49265,7 +49265,7 @@ void main(void)\r
49265
49265
  scrollContent,
49266
49266
  scrollbarRgiht,
49267
49267
  scrollbarWidth = 10,
49268
- scrollbarColor = "#F8A500"
49268
+ scrollbarColor = "#ffffff"
49269
49269
  } = params;
49270
49270
  super(width, height);
49271
49271
  this._startY = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyb-pixi-js",
3
- "version": "1.8.6",
3
+ "version": "1.8.8",
4
4
  "description": "自用Pixi.JS方法库",
5
5
  "license": "ISC",
6
6
  "exports": {