lyb-pixi-js 1.4.9 → 1.4.11

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,5 +1,5 @@
1
- import { LibPixiContainer } from "../Base/LibPixiContainer";
2
1
  import type { Sprite } from "pixi.js";
2
+ import { LibPixiContainer } from "../Base/LibPixiContainer";
3
3
  export interface LibPixiCloseBtnParams {
4
4
  /** 按钮素材 */
5
5
  sprite: Sprite;
@@ -1,6 +1,6 @@
1
1
  import gsap from "gsap";
2
- import { LibPixiContainer } from "../Base/LibPixiContainer";
3
2
  import { libPixiEvent } from "../../Utils/LibPixiEvent";
3
+ import { LibPixiContainer } from "../Base/LibPixiContainer";
4
4
  /** @description 右上角关闭按钮,支持悬浮旋转动画
5
5
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiCloseBtn-关闭按钮
6
6
  */
@@ -18,7 +18,7 @@ export class LibPixiCloseBtn extends LibPixiContainer {
18
18
  rotation: 180 * (Math.PI / 180),
19
19
  });
20
20
  });
21
- libPixiEvent(this, "pointerleave", () => {
21
+ const offLeave = libPixiEvent(this, "pointerleave", () => {
22
22
  sprite.alpha = 1;
23
23
  gsap.to(sprite, {
24
24
  duration: 0.25,
@@ -30,6 +30,7 @@ export class LibPixiCloseBtn extends LibPixiContainer {
30
30
  });
31
31
  libPixiEvent(this, "pointerup", () => {
32
32
  onClick();
33
+ offLeave();
33
34
  });
34
35
  }
35
36
  }
package/README.md CHANGED
@@ -597,6 +597,12 @@ libPixiEvent(container, "pointerdown", (e) => {
597
597
  console.log("Pointer down event triggered", e);
598
598
  });
599
599
 
600
+ //停止监听
601
+ const offEvent = libPixiEvent(container, "pointerdown", (e) => {
602
+ console.log("Pointer down event triggered", e);
603
+ offEvent();
604
+ });
605
+
600
606
  //只执行一次的事件
601
607
  libPixiEvent(
602
608
  container,
@@ -782,7 +788,7 @@ globalUpdater.setInstance("ToolbarUI", this.toolbarUI);
782
788
  import type { GameUI } from "@/app/ui/GameUI";
783
789
  import type { ToolbarUI } from "@/app/ui/ToolbarUI";
784
790
 
785
- type Instances = "GameUI" | "ToolbarUI"
791
+ type Instances = "GameUI" | "ToolbarUI";
786
792
  const globalUpdater = new GlobalUpdater<Instances>();
787
793
  export { globalUpdater };
788
794
 
@@ -798,6 +804,5 @@ $bus.on("play", () => {
798
804
  > 多边形绘制工具,绘制时浏览器窗口需要全屏显示,空格键控制开始和结束,开始后鼠标进行点击绘制,退格删除点,空格结束绘制,绘制结果在控制台打印,不满意可再次按空格清空并重新绘制
799
805
 
800
806
  ```ts
801
- new LibPixiPolygonDrawTool(app)
807
+ new LibPixiPolygonDrawTool(app);
802
808
  ```
803
-
@@ -1,9 +1,10 @@
1
- import type { Container, DisplayObjectEvents } from "pixi.js";
1
+ import type { Container, DisplayObjectEvents, FederatedPointerEvent } from "pixi.js";
2
2
  /** @description 事件注册
3
3
  * @param v 事件容器
4
4
  * @param eventName 事件名称
5
5
  * @param callback 回调函数
6
6
  * @param once 是否只执行一次
7
+ * @returns 停止监听
7
8
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiEvent-事件注册
8
9
  */
9
- export declare const libPixiEvent: (v: Container, eventName: keyof DisplayObjectEvents, callback: (...args: any) => void, once?: boolean) => void;
10
+ export declare const libPixiEvent: (v: Container, eventName: keyof DisplayObjectEvents, callback: (event: FederatedPointerEvent) => void, once?: boolean) => () => void;
@@ -3,6 +3,7 @@
3
3
  * @param eventName 事件名称
4
4
  * @param callback 回调函数
5
5
  * @param once 是否只执行一次
6
+ * @returns 停止监听
6
7
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiEvent-事件注册
7
8
  */
8
9
  export const libPixiEvent = (v, eventName, callback, once = false) => {
@@ -19,4 +20,7 @@ export const libPixiEvent = (v, eventName, callback, once = false) => {
19
20
  else {
20
21
  v.on(eventName, fn);
21
22
  }
23
+ return () => {
24
+ v.off(eventName, fn);
25
+ };
22
26
  };
@@ -1,8 +1,8 @@
1
- import type { Container, DisplayObjectEvents } from "pixi.js";
1
+ import type { Container, DisplayObjectEvents, FederatedPointerEvent } from "pixi.js";
2
2
  /** @description 设置可关闭的事件监听,调用自身后不再触发
3
3
  * @param container 事件容器
4
4
  * @param eventName 事件名称
5
5
  * @param callback 事件回调
6
6
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiEventControlled-可关闭的事件
7
7
  */
8
- export declare const libPixiEventControlled: (container: Container, eventName: keyof DisplayObjectEvents, callback: (...args: any) => void) => () => void;
8
+ export declare const libPixiEventControlled: (container: Container, eventName: keyof DisplayObjectEvents, callback: (e: FederatedPointerEvent) => void) => () => void;
package/libPixiJs.d.ts CHANGED
@@ -106,14 +106,14 @@ export declare const Utils: {
106
106
  * @param once 是否只执行一次
107
107
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiEvent-事件注册
108
108
  */
109
- libPixiEvent: (v: import("pixi.js").Container, eventName: keyof import("pixi.js").DisplayObjectEvents, callback: (...args: any) => void, once?: boolean) => void;
109
+ libPixiEvent: (v: import("pixi.js").Container, eventName: keyof import("pixi.js").DisplayObjectEvents, callback: (event: import("pixi.js").FederatedPointerEvent) => void, once?: boolean) => () => void;
110
110
  /** @description 设置可关闭的事件监听,调用自身后不再触发
111
111
  * @param container 事件容器
112
112
  * @param eventName 事件名称
113
113
  * @param callback 事件回调
114
114
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiEventControlled-可关闭的事件
115
115
  */
116
- libPixiEventControlled: (container: import("pixi.js").Container, eventName: keyof import("pixi.js").DisplayObjectEvents, callback: (...args: any) => void) => () => void;
116
+ libPixiEventControlled: (container: import("pixi.js").Container, eventName: keyof import("pixi.js").DisplayObjectEvents, callback: (e: import("pixi.js").FederatedPointerEvent) => void) => () => void;
117
117
  /** @description 滤镜
118
118
  * @param filterName 滤镜名称
119
119
  * @param v 滤镜值