lyb-pixi-js 1.12.56 → 1.12.58

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.
@@ -15,6 +15,8 @@ export interface LibPixiScrollContainerXParams {
15
15
  maskX?: number;
16
16
  /** 遮罩Y坐标 */
17
17
  maskY?: number;
18
+ /** 滚动触发 */
19
+ onScroll?: (x: number) => void;
18
20
  }
19
21
  /** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹 */
20
22
  export declare class LibPixiScrollContainerX extends LibPixiContainer {
@@ -42,6 +44,8 @@ export declare class LibPixiScrollContainerX extends LibPixiContainer {
42
44
  private _maskGraphics;
43
45
  /** 滚动的内容 */
44
46
  private _content;
47
+ /** 滚动触发 */
48
+ private _onScroll?;
45
49
  constructor(params: LibPixiScrollContainerXParams);
46
50
  /** @description 添加边距 */
47
51
  addMargin(leftMargin: number, rightMargin?: number): void;
@@ -6,7 +6,7 @@ import { LibPixiRectangle } from "../Base/LibPixiRectangle";
6
6
  /** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹 */
7
7
  export class LibPixiScrollContainerX extends LibPixiContainer {
8
8
  constructor(params) {
9
- const { width, height, scrollContent, bgColor, maskTexture, maskX = 0, maskY = 0, } = params;
9
+ const { width, height, scrollContent, bgColor, maskTexture, maskX = 0, maskY = 0, onScroll, } = params;
10
10
  super(width, height, bgColor);
11
11
  /** 开始位置 */
12
12
  this._startX = 0;
@@ -23,6 +23,7 @@ export class LibPixiScrollContainerX extends LibPixiContainer {
23
23
  /** 左边距 */
24
24
  this._leftMargin = 0;
25
25
  this._scrollContent = scrollContent;
26
+ this._onScroll = onScroll;
26
27
  // 创建内容容器
27
28
  this._content = new Container();
28
29
  this.addChild(this._content);
@@ -113,10 +114,12 @@ export class LibPixiScrollContainerX extends LibPixiContainer {
113
114
  }
114
115
  /** @description 拖动 */
115
116
  _onDragMove(event) {
117
+ var _a;
116
118
  if (this._isDragging) {
117
119
  const { x } = event.getLocalPosition(this);
118
120
  const newPosition = x - this._startX;
119
121
  this._content.x = newPosition;
122
+ (_a = this._onScroll) === null || _a === void 0 ? void 0 : _a.call(this, this._content.x);
120
123
  }
121
124
  }
122
125
  /** @description 拖动结束 */
@@ -164,6 +167,8 @@ export class LibPixiScrollContainerX extends LibPixiContainer {
164
167
  }
165
168
  /** @description 限制滚动范围 */
166
169
  _limitScrollRange() {
170
+ var _a;
171
+ (_a = this._onScroll) === null || _a === void 0 ? void 0 : _a.call(this, this._content.x);
167
172
  //如果内容顶部离开了滚动容器顶部,则归位
168
173
  if (this._content.x > 0) {
169
174
  //回弹
@@ -171,6 +176,10 @@ export class LibPixiScrollContainerX extends LibPixiContainer {
171
176
  duration: 0.2,
172
177
  ease: "power1.out",
173
178
  x: 0,
179
+ onUpdate: () => {
180
+ var _a;
181
+ (_a = this._onScroll) === null || _a === void 0 ? void 0 : _a.call(this, this._content.x);
182
+ },
174
183
  });
175
184
  }
176
185
  // 如果滚动距离大于内容高度减去遮罩高度
@@ -184,6 +193,10 @@ export class LibPixiScrollContainerX extends LibPixiContainer {
184
193
  duration: 0.2,
185
194
  ease: "power1.out",
186
195
  x,
196
+ onUpdate: () => {
197
+ var _a;
198
+ (_a = this._onScroll) === null || _a === void 0 ? void 0 : _a.call(this, this._content.x);
199
+ },
187
200
  });
188
201
  }
189
202
  // 否则静止不动
@@ -191,6 +204,10 @@ export class LibPixiScrollContainerX extends LibPixiContainer {
191
204
  gsap.to(this._content, {
192
205
  duration: 0.25,
193
206
  x: 0,
207
+ onUpdate: () => {
208
+ var _a;
209
+ (_a = this._onScroll) === null || _a === void 0 ? void 0 : _a.call(this, this._content.x);
210
+ },
194
211
  });
195
212
  }
196
213
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyb-pixi-js",
3
- "version": "1.12.56",
3
+ "version": "1.12.58",
4
4
  "description": "自用Pixi.JS方法库",
5
5
  "license": "ISC",
6
6
  "exports": {