lyb-pixi-js 1.12.59 → 1.12.61

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.
@@ -1,4 +1,5 @@
1
1
  import { Container } from "pixi.js";
2
+ import { libPixiPivot } from "../../Utils/LibPixiActhor";
2
3
  /** @description 线性排列 */
3
4
  export class LibPixiArrangeLinearV2 extends Container {
4
5
  constructor(params) {
@@ -63,8 +64,7 @@ export class LibPixiArrangeLinearV2 extends Container {
63
64
  lastRowMax = Math.max(lastRowMax, item.width);
64
65
  }
65
66
  });
66
- const bounds = this.getLocalBounds();
67
- this.pivot.set(bounds.x + bounds.width * anchorX, bounds.y + bounds.height * anchorY);
67
+ libPixiPivot(this, anchorX, anchorY);
68
68
  }
69
69
  /** @description 获取列表元素 */
70
70
  getList() {
@@ -1,4 +1,5 @@
1
1
  import { Container } from "pixi.js";
2
+ import { libPixiPivot } from "../../Utils/LibPixiActhor";
2
3
  /** @description 网格列布局 */
3
4
  export class LibPixiGridColumnLayout extends Container {
4
5
  constructor(params) {
@@ -23,8 +24,7 @@ export class LibPixiGridColumnLayout extends Container {
23
24
  item.x = isRTL ? -col * colGap : col * colGap;
24
25
  item.y = row * rowGap;
25
26
  });
26
- const bounds = this.getLocalBounds();
27
- this.pivot.set(bounds.x + bounds.width * anchorX, bounds.y + bounds.height * anchorY);
27
+ libPixiPivot(this, anchorX, anchorY);
28
28
  }
29
29
  /** @description 获取列表元素 */
30
30
  getList() {
@@ -1,4 +1,5 @@
1
1
  import { Container } from "pixi.js";
2
+ import { libPixiPivot } from "../../Utils/LibPixiActhor";
2
3
  /** @description 网格行布局 */
3
4
  export class LibPixiGridRowLayout extends Container {
4
5
  constructor(params) {
@@ -23,8 +24,7 @@ export class LibPixiGridRowLayout extends Container {
23
24
  item.y = row * rowGap;
24
25
  });
25
26
  // 根据 anchor 调整整体偏移
26
- const bounds = this.getLocalBounds();
27
- this.pivot.set(bounds.x + bounds.width * anchorX, bounds.y + bounds.height * anchorY);
27
+ libPixiPivot(this, anchorX, anchorY);
28
28
  }
29
29
  /** @description 获取列表元素 */
30
30
  getList() {
@@ -0,0 +1,26 @@
1
+ import { Container, type HTMLText, type Text } from "pixi.js";
2
+ interface Params {
3
+ /** 高度 */
4
+ width: number;
5
+ /** 宽度 */
6
+ height: number;
7
+ /** 速度,px/s,默认100 */
8
+ speed?: number;
9
+ /** 可见性回调 */
10
+ onVisable: (v: boolean) => void;
11
+ }
12
+ /** @description 滚动通知栏 */
13
+ export declare class LibPixiNoticeBar extends Container {
14
+ /** 当前参数 */
15
+ private _params;
16
+ /** 文本队列 */
17
+ private _textQueue;
18
+ /** 当前显示的文本 */
19
+ private _currentText?;
20
+ constructor(params: Params);
21
+ /** @description 添加到队列 */
22
+ addText(...text: (Text | HTMLText)[]): void;
23
+ /** @description 显示文本 */
24
+ private _showText;
25
+ }
26
+ export {};
@@ -0,0 +1,50 @@
1
+ import gsap from "gsap";
2
+ import { Container } from "pixi.js";
3
+ import { LibPixiRectangle } from "../Base/LibPixiRectangle";
4
+ /** @description 滚动通知栏 */
5
+ export class LibPixiNoticeBar extends Container {
6
+ constructor(params) {
7
+ super();
8
+ /** 文本队列 */
9
+ this._textQueue = [];
10
+ this._params = params;
11
+ const { width, height } = params;
12
+ const rectangle = new LibPixiRectangle(width, height);
13
+ this.addChild(rectangle);
14
+ this.mask = rectangle;
15
+ }
16
+ /** @description 添加到队列 */
17
+ addText(...text) {
18
+ this._textQueue.push(...text);
19
+ if (this._currentText)
20
+ return;
21
+ this._showText();
22
+ }
23
+ /** @description 显示文本 */
24
+ _showText() {
25
+ this._currentText = this._textQueue.shift();
26
+ if (!this._currentText)
27
+ return;
28
+ this._params.onVisable(true);
29
+ this.addChild(this._currentText);
30
+ this._currentText.anchor.y = 0.5;
31
+ this._currentText.position.set(this._params.width, this._params.height / 2);
32
+ gsap.to(this._currentText, {
33
+ x: -this._currentText.width,
34
+ duration: (this._params.width + this._currentText.width) /
35
+ (this._params.speed || 100),
36
+ ease: "none",
37
+ onComplete: () => {
38
+ this._currentText.destroy();
39
+ this._currentText = undefined;
40
+ if (this._textQueue.length) {
41
+ this._showText();
42
+ }
43
+ else {
44
+ this._params.onVisable(false);
45
+ this._currentText = undefined;
46
+ }
47
+ },
48
+ });
49
+ }
50
+ }
@@ -1,4 +1,5 @@
1
1
  import { Container, Text } from "pixi.js";
2
+ import { libPixiPivot } from "../../Utils/LibPixiActhor";
2
3
  /** @description 文本组换行 */
3
4
  export class LibPixiTextGroupWrap extends Container {
4
5
  constructor({ items, defaultStyle = {}, wordWrapWidth, paddingX = 0, paddingY = 0, align = "left", anchorX = 0, anchorY = 0, }) {
@@ -44,7 +45,6 @@ export class LibPixiTextGroupWrap extends Container {
44
45
  y += maxHeight + paddingY;
45
46
  }
46
47
  // 根据 anchor 调整整体偏移
47
- const bounds = this.getLocalBounds();
48
- this.pivot.set(bounds.x + bounds.width * anchorX, bounds.y + bounds.height * anchorY);
48
+ libPixiPivot(this, anchorX, anchorY);
49
49
  }
50
50
  }
package/README.md CHANGED
@@ -198,6 +198,8 @@ app.stage.addChild(box);
198
198
 
199
199
  \- [LibPixiTicker-Ticker管理器](#LibPixiTicker-Ticker管理器)
200
200
 
201
+ \- [LibPixiPivot-容器锚点设置](#LibPixiPivot-容器锚点设置)
202
+
201
203
  ## Base-基础
202
204
 
203
205
  ### LibPixiText-文本
@@ -931,6 +933,10 @@ const amountContainer = new LibLabelValue({
931
933
 
932
934
  > 一列占满后进入下一列,支持从左到右或从右到左
933
935
 
936
+ ### LibPixiNoticeBar
937
+
938
+ > 滚动跑马灯
939
+
934
940
  ## Utils-工具方法
935
941
 
936
942
  ### LibPixiAudio-音频播放器
@@ -1266,3 +1272,7 @@ LibPixiEmitContainerEvent(this, "EVENT_NAME", {});
1266
1272
  ### LibPixiTicker-Ticker管理器
1267
1273
 
1268
1274
  > 添加和删除 `Ticker` 函数,单个 `Ticker` 函数暂停开始,所有 `Ticker` 函数使用的是全局的 `Ticker`
1275
+
1276
+ ### LibPixiPivot-容器锚点设置
1277
+
1278
+ > 给容器设置精准的 `Pivot`,但当容器大小改变时,需要重新调用
@@ -0,0 +1,3 @@
1
+ import { Container } from "pixi.js";
2
+ /** @description 容器锚点设置 */
3
+ export declare const libPixiPivot: (container: Container, pivotX?: number, pivotY?: number) => void;
@@ -0,0 +1,6 @@
1
+ /** @description 容器锚点设置 */
2
+ export const libPixiPivot = (container, pivotX = 0, pivotY = pivotX) => {
3
+ const { x, y, width, height } = container.getLocalBounds();
4
+ container.pivot.x = x + width * pivotX;
5
+ container.pivot.y = y + height * pivotY;
6
+ };
@@ -14,6 +14,7 @@ import { LibPixiMaskBg } from "../../../Components/Custom/LibPixiMaskBg";
14
14
  import { libPixiEvent } from "../../LibPixiEvent";
15
15
  import { LibPixiBaseContainer } from "./LibPixiBaseContainer";
16
16
  import { LibPixiTicker } from "../../LibPixiTicker";
17
+ import { libPixiPivot } from "../../LibPixiActhor";
17
18
  /** @description 弹窗组件 */
18
19
  export class LibPixiDialog extends LibPixiBaseContainer {
19
20
  constructor(params) {
@@ -79,10 +80,7 @@ export class LibPixiDialog extends LibPixiBaseContainer {
79
80
  }
80
81
  /** @description 更新弹窗容器坐标 */
81
82
  updatePosition(w, h) {
82
- const bounds = this._dialogContainer.getLocalBounds();
83
- const dialogW = bounds.width / 2;
84
- const dialogH = bounds.height / 2;
85
- this._dialogContainer.pivot.set(bounds.x + dialogW, bounds.y + dialogH);
83
+ libPixiPivot(this._dialogContainer, 0.5, 0.5);
86
84
  const halfW = 1920 / 2;
87
85
  const halfH = 1080 / 2;
88
86
  if (w > h) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyb-pixi-js",
3
- "version": "1.12.59",
3
+ "version": "1.12.61",
4
4
  "description": "自用Pixi.JS方法库",
5
5
  "license": "ISC",
6
6
  "exports": {