lyb-pixi-js 1.12.13 → 1.12.15

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.
@@ -7,6 +7,8 @@ export interface LibPixiScrollContainerYParams {
7
7
  height: number;
8
8
  /** 滚动内容 */
9
9
  scrollContent: Container;
10
+ /** 顶部边距 */
11
+ topMargin?: number;
10
12
  /** 底部边距 */
11
13
  bottomMargin?: number;
12
14
  /** 背景色,用于定位 */
@@ -8,7 +8,7 @@ import { LibPixiRectangle } from "../Base/LibPixiRectangle";
8
8
  */
9
9
  export class LibPixiScrollContainerY extends LibPixiContainer {
10
10
  constructor(params) {
11
- const { width, height, scrollbar = false, scrollContent, scrollbarRgiht = 0, scrollbarWidth = 10, scrollbarColor = "#ffffff", onScroll, bgColor, bottomMargin = 0, } = params;
11
+ const { width, height, scrollbar = false, scrollContent, scrollbarRgiht = 0, scrollbarWidth = 10, scrollbarColor = "#ffffff", onScroll, bgColor, topMargin = 0, bottomMargin = 0, } = params;
12
12
  super(width, height, bgColor);
13
13
  /** 开始位置 */
14
14
  this._startY = 0;
@@ -36,10 +36,24 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
36
36
  this._content = new Container();
37
37
  this.addChild(this._content);
38
38
  this._content.addChild(this._scrollContent);
39
- //创建底部边距
40
- const bottomMarginBox = new Sprite();
41
- this._content.addChild(bottomMarginBox);
42
- bottomMarginBox.height = this._content.height + bottomMargin;
39
+ if (topMargin) {
40
+ //创建底部边距
41
+ const topMarginBox = new Sprite();
42
+ this._content.addChild(topMarginBox);
43
+ topMarginBox.height = topMargin;
44
+ requestAnimationFrame(() => {
45
+ this._scrollContent.y += topMargin;
46
+ });
47
+ }
48
+ if (bottomMargin) {
49
+ //创建底部边距
50
+ const bottomMarginBox = new Sprite();
51
+ this._content.addChild(bottomMarginBox);
52
+ bottomMarginBox.height = bottomMargin;
53
+ requestAnimationFrame(() => {
54
+ bottomMarginBox.y = topMargin + this._scrollContent.height;
55
+ });
56
+ }
43
57
  // 创建遮罩
44
58
  this._maskGraphics = new LibPixiRectangle(width, height, "#000");
45
59
  this.addChild(this._maskGraphics);
@@ -25,6 +25,8 @@ export declare class LibPixiDialog extends LibPixiBaseContainer {
25
25
  private _size;
26
26
  /** 竖版初始大小 */
27
27
  private _initialSize;
28
+ /** 窗口变化 */
29
+ private _resize?;
28
30
  /** 停止监听窗口 */
29
31
  private _offResize?;
30
32
  constructor(params?: Params);
@@ -9,10 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { Container } from "pixi.js";
11
11
  import gsap from "gsap";
12
+ import { LibJsResizeWatcher } from "lyb-js/Base/LibJsResizeWatcher.js";
12
13
  import { LibPixiRectBgColor } from "../../../Components/Base/LibPixiRectBgColor";
13
14
  import { libPixiEvent } from "../../LibPixiEvent";
14
15
  import { LibPixiBaseContainer } from "./LibPixiBaseContainer";
15
- import { LibJsResizeWatcher } from "lyb-js/Base/LibJsResizeWatcher.js";
16
16
  /** @description 弹窗组件 */
17
17
  export class LibPixiDialog extends LibPixiBaseContainer {
18
18
  constructor(params) {
@@ -47,6 +47,7 @@ export class LibPixiDialog extends LibPixiBaseContainer {
47
47
  }
48
48
  /** @description 设置弹窗内容 */
49
49
  setDialogContent(content) {
50
+ var _a, _b;
50
51
  this._dialogContainer.addChild(content);
51
52
  const w = this._dialogContainer.width / 2;
52
53
  const h = this._dialogContainer.height / 2;
@@ -61,8 +62,10 @@ export class LibPixiDialog extends LibPixiBaseContainer {
61
62
  duration: LibPixiDialog.durationIn,
62
63
  alpha: 1,
63
64
  });
64
- const resize = new LibJsResizeWatcher(LibPixiDialog.adaptation);
65
- this._offResize = resize.on((w, h) => {
65
+ //部分场景需要重复调用此方法来重新更新布局重新监听尺寸变化,所以需要判断一下
66
+ (_a = this._resize) !== null && _a !== void 0 ? _a : (this._resize = new LibJsResizeWatcher(LibPixiDialog.adaptation));
67
+ (_b = this._offResize) === null || _b === void 0 ? void 0 : _b.call(this);
68
+ this._offResize = this._resize.on((w, h) => {
66
69
  const halfW = 1920 / 2;
67
70
  const halfH = 1080 / 2;
68
71
  if (w > h) {
package/lyb-pixi.js CHANGED
@@ -49360,6 +49360,7 @@ void main(void)\r
49360
49360
  scrollbarColor = "#ffffff",
49361
49361
  onScroll,
49362
49362
  bgColor,
49363
+ topMargin = 0,
49363
49364
  bottomMargin = 0
49364
49365
  } = params;
49365
49366
  super(width, height, bgColor);
@@ -49380,9 +49381,22 @@ void main(void)\r
49380
49381
  this._content = new Container();
49381
49382
  this.addChild(this._content);
49382
49383
  this._content.addChild(this._scrollContent);
49383
- const bottomMarginBox = new Sprite();
49384
- this._content.addChild(bottomMarginBox);
49385
- bottomMarginBox.height = this._content.height + bottomMargin;
49384
+ if (topMargin) {
49385
+ const topMarginBox = new Sprite();
49386
+ this._content.addChild(topMarginBox);
49387
+ topMarginBox.height = topMargin;
49388
+ requestAnimationFrame(() => {
49389
+ this._scrollContent.y += topMargin;
49390
+ });
49391
+ }
49392
+ if (bottomMargin) {
49393
+ const bottomMarginBox = new Sprite();
49394
+ this._content.addChild(bottomMarginBox);
49395
+ bottomMarginBox.height = bottomMargin;
49396
+ requestAnimationFrame(() => {
49397
+ bottomMarginBox.y = topMargin + this._scrollContent.height;
49398
+ });
49399
+ }
49386
49400
  this._maskGraphics = new LibPixiRectangle(width, height, "#000");
49387
49401
  this.addChild(this._maskGraphics);
49388
49402
  this.mask = this._maskGraphics;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyb-pixi-js",
3
- "version": "1.12.13",
3
+ "version": "1.12.15",
4
4
  "description": "自用Pixi.JS方法库",
5
5
  "license": "ISC",
6
6
  "exports": {