lyb-pixi-js 1.12.59 → 1.12.60

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,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
+ }
package/README.md CHANGED
@@ -931,6 +931,10 @@ const amountContainer = new LibLabelValue({
931
931
 
932
932
  > 一列占满后进入下一列,支持从左到右或从右到左
933
933
 
934
+ ### LibPixiNoticeBar
935
+
936
+ > 滚动跑马灯
937
+
934
938
  ## Utils-工具方法
935
939
 
936
940
  ### LibPixiAudio-音频播放器
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.60",
4
4
  "description": "自用Pixi.JS方法库",
5
5
  "license": "ISC",
6
6
  "exports": {