lyb-pixi-js 1.12.47 → 1.12.49

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.
@@ -27,10 +27,6 @@ interface Params {
27
27
  integer?: boolean;
28
28
  /** 是否允许输入负数 */
29
29
  isNegative?: boolean;
30
- /** 最小值 */
31
- min?: number;
32
- /** 最大值 */
33
- max?: number;
34
30
  /** 最大长度 */
35
31
  maxLength?: number;
36
32
  /** 对齐方式 */
@@ -59,8 +55,14 @@ export declare class LibPixiInput extends LibPixiContainer {
59
55
  constructor(params: Params);
60
56
  /** @description 设置值 */
61
57
  setValue(v: string): void;
58
+ /** @description 更改输入框描述 */
59
+ setPlaceholder(v: string): void;
62
60
  /** @description 聚焦 */
63
61
  focus(): void;
62
+ /** @description 设置输入框类型 */
63
+ toggleType(type: "text" | "password"): void;
64
+ /** @description 清空输入框 */
65
+ clear(): void;
64
66
  /** @description 创建输入框 */
65
67
  private _createInput;
66
68
  /** @description 创建只读输入框 */
@@ -71,7 +73,5 @@ export declare class LibPixiInput extends LibPixiContainer {
71
73
  private _onBlurHandler;
72
74
  /** @description 实时更新输入框位置 */
73
75
  private _updateInputPosition;
74
- /** @description 设置输入框类型 */
75
- toggleType(type: "text" | "password"): void;
76
76
  }
77
77
  export {};
@@ -13,20 +13,15 @@ export class LibPixiInput extends LibPixiContainer {
13
13
  this._value = "";
14
14
  /** @description 失去焦点处理 */
15
15
  this._onBlurHandler = () => {
16
- const { type = "text", integer = false, min = 1, max = Infinity, } = this._params;
16
+ const { type = "text", integer = false } = this._params;
17
17
  let text = this._input.value.trim();
18
18
  //如果类型为字符串,则不参与校验
19
19
  if (["text", "password"].includes(type))
20
20
  return text;
21
- //如果为空,则使用最小值
22
- if (this._input.value === "")
23
- text = min.toString();
24
- //如果不能为负数,输入值小于最小值,则使用最小值
25
- if (Number(text) < min)
26
- text = min.toString();
27
- //如果存在最大值,且输入值大于最大值,则使用最大值
28
- if (max && Number(text) > max)
29
- text = max.toString();
21
+ const num = Number(text);
22
+ //如果小于0,则返回空
23
+ if (num <= 0)
24
+ return "";
30
25
  //如果要求整数,则取整
31
26
  if (integer)
32
27
  text = parseInt(text).toString();
@@ -65,6 +60,10 @@ export class LibPixiInput extends LibPixiContainer {
65
60
  this._readonlyInput.text = (onFormatValue === null || onFormatValue === void 0 ? void 0 : onFormatValue(value)) || value;
66
61
  }
67
62
  }
63
+ /** @description 更改输入框描述 */
64
+ setPlaceholder(v) {
65
+ this._placeholder.text = v;
66
+ }
68
67
  /** @description 聚焦 */
69
68
  focus() {
70
69
  const { type } = this._params;
@@ -79,6 +78,19 @@ export class LibPixiInput extends LibPixiContainer {
79
78
  this._input.value = this._value;
80
79
  }
81
80
  }
81
+ /** @description 设置输入框类型 */
82
+ toggleType(type) {
83
+ this._input.type = type;
84
+ this._params.type = type;
85
+ this.setValue(this._value);
86
+ }
87
+ /** @description 清空输入框 */
88
+ clear() {
89
+ this._input.value = "";
90
+ this._placeholder.visible = true;
91
+ this._readonlyInput.visible = false;
92
+ this._blur();
93
+ }
82
94
  /** @description 创建输入框 */
83
95
  _createInput() {
84
96
  const { color = "#fff", maxLength = 999999, align = "left", type = "text", onInput = () => { }, fontFamily = "", bold = false, } = this._params;
@@ -148,7 +160,7 @@ export class LibPixiInput extends LibPixiContainer {
148
160
  this.setValue(value);
149
161
  this._input.style.display = "none";
150
162
  libPixiScaleContainer(this._readonlyInput, width);
151
- if (this._params.type === "number") {
163
+ if (this._params.type === "number" && value !== "") {
152
164
  this._readonlyInput.visible = true;
153
165
  onValue === null || onValue === void 0 ? void 0 : onValue(Number(value));
154
166
  }
@@ -189,10 +201,4 @@ export class LibPixiInput extends LibPixiContainer {
189
201
  this._input.style.transform = `rotate(90deg)`;
190
202
  }
191
203
  }
192
- /** @description 设置输入框类型 */
193
- toggleType(type) {
194
- this._input.type = type;
195
- this._params.type = type;
196
- this.setValue(this._value);
197
- }
198
204
  }
@@ -77,7 +77,7 @@ export declare class LibPixiScrollContainerY extends LibPixiContainer {
77
77
  */
78
78
  setDimensions(width: number, height: number): void;
79
79
  /** @description 返回顶部 */
80
- scrollToTop(): void;
80
+ scrollToTop(animate?: boolean): void;
81
81
  /** @description 往滚动内容添加元素 */
82
82
  addContent(container: Container): void;
83
83
  /** @description 更新右边距坐标 */
@@ -120,9 +120,14 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
120
120
  this._updateBottomMargin();
121
121
  }
122
122
  /** @description 返回顶部 */
123
- scrollToTop() {
123
+ scrollToTop(animate = false) {
124
124
  gsap.killTweensOf(this._content);
125
- this._content.y = 0;
125
+ if (animate) {
126
+ gsap.to(this._content, { y: 0, duration: 0.25 });
127
+ }
128
+ else {
129
+ this._content.y = 0;
130
+ }
126
131
  }
127
132
  /** @description 往滚动内容添加元素 */
128
133
  addContent(container) {
@@ -8,7 +8,9 @@ interface IViewCtor {
8
8
  /** @description 弹窗管理器 */
9
9
  export declare class LibPixiDialogManager {
10
10
  /** 视图表 */
11
- private views;
11
+ private _views;
12
+ /** 弹窗关闭监听器表 */
13
+ private _closeListeners;
12
14
  /** open时显示的元素的父容器 */
13
15
  private _openContainer;
14
16
  constructor(parent: Container);
@@ -18,6 +20,11 @@ export declare class LibPixiDialogManager {
18
20
  * @param args 实例参数
19
21
  */
20
22
  open<T extends IViewCtor>(View: T, id: string, ...args: ConstructorParameters<T>): InstanceType<T>;
23
+ /** 监听弹窗关闭
24
+ * @param id 弹窗id
25
+ * @param callback 关闭回调
26
+ */
27
+ onClose(id: string, callback: () => void): void;
21
28
  /** @description 关闭页面,会调用页面的 onBeforeUnmount 事件,里面会做关闭动画,动画结束后会自动销毁
22
29
  * @param id 页面名称
23
30
  */
@@ -13,7 +13,9 @@ export { LibPixiDialog } from "./ui/LibPixiDialog";
13
13
  export class LibPixiDialogManager {
14
14
  constructor(parent) {
15
15
  /** 视图表 */
16
- this.views = {};
16
+ this._views = {};
17
+ /** 弹窗关闭监听器表 */
18
+ this._closeListeners = new Map();
17
19
  this._openContainer = parent;
18
20
  }
19
21
  /**
@@ -24,26 +26,41 @@ export class LibPixiDialogManager {
24
26
  open(View, id, ...args) {
25
27
  const view = new View(...args);
26
28
  this._openContainer.addChild(view);
27
- this.views[id] = view;
29
+ this._views[id] = view;
28
30
  return view;
29
31
  }
32
+ /** 监听弹窗关闭
33
+ * @param id 弹窗id
34
+ * @param callback 关闭回调
35
+ */
36
+ onClose(id, callback) {
37
+ if (!this._closeListeners.has(id))
38
+ this._closeListeners.set(id, new Set());
39
+ this._closeListeners.get(id).add(callback);
40
+ }
30
41
  /** @description 关闭页面,会调用页面的 onBeforeUnmount 事件,里面会做关闭动画,动画结束后会自动销毁
31
42
  * @param id 页面名称
32
43
  */
33
44
  close(id) {
34
45
  return __awaiter(this, void 0, void 0, function* () {
35
46
  var _a;
36
- const view = this.views[id];
47
+ const view = this._views[id];
37
48
  if (view) {
38
49
  yield ((_a = view.destroy) === null || _a === void 0 ? void 0 : _a.call(view));
39
- delete this.views[id];
50
+ delete this._views[id];
51
+ const set = this._closeListeners.get(id);
52
+ if (!set)
53
+ return;
54
+ for (const cb of set)
55
+ cb();
56
+ this._closeListeners.delete(id);
40
57
  }
41
58
  });
42
59
  }
43
60
  /** @description 关闭并销毁所有弹窗 */
44
61
  closeAll() {
45
62
  return __awaiter(this, void 0, void 0, function* () {
46
- const ids = Object.keys(this.views);
63
+ const ids = Object.keys(this._views);
47
64
  for (const id of ids) {
48
65
  yield this.close(id);
49
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyb-pixi-js",
3
- "version": "1.12.47",
3
+ "version": "1.12.49",
4
4
  "description": "自用Pixi.JS方法库",
5
5
  "license": "ISC",
6
6
  "exports": {