lyb-pixi-js 1.9.1 → 1.9.2

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 LibPixiScrollContainerYParams {
15
15
  scrollbarWidth?: number;
16
16
  /** 滚动条颜色 */
17
17
  scrollbarColor?: string;
18
+ /** 滚动触发 */
19
+ onScroll: (y: number) => void;
18
20
  }
19
21
  /** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
20
22
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y 轴滚动容器
@@ -46,6 +48,8 @@ export declare class LibPixiScrollContainerY extends LibPixiContainer {
46
48
  private _scrollbar;
47
49
  /** 滚动条颜色 */
48
50
  private _scrollbarColor;
51
+ /** 滚动触发 */
52
+ private _onScroll;
49
53
  constructor(params: LibPixiScrollContainerYParams);
50
54
  /** @description 设置滚动容器可视区宽高
51
55
  * @param width 宽度
@@ -1,14 +1,14 @@
1
1
  import { Container } from "pixi.js";
2
2
  import { gsap } from "gsap";
3
- import { LibPixiRectangle } from "../Base/LibPixiRectangle";
4
3
  import { libPixiEvent } from "../../Utils/LibPixiEvent";
5
4
  import { LibPixiContainer } from "../Base/LibPixiContainer";
5
+ import { LibPixiRectangle } from "../Base/LibPixiRectangle";
6
6
  /** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
7
7
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y 轴滚动容器
8
8
  */
9
9
  export class LibPixiScrollContainerY extends LibPixiContainer {
10
10
  constructor(params) {
11
- const { width, height, scrollbar = false, scrollContent, scrollbarRgiht, scrollbarWidth = 10, scrollbarColor = "#ffffff", } = params;
11
+ const { width, height, scrollbar = false, scrollContent, scrollbarRgiht, scrollbarWidth = 10, scrollbarColor = "#ffffff", onScroll, } = params;
12
12
  super(width, height);
13
13
  /** 开始位置 */
14
14
  this._startY = 0;
@@ -28,6 +28,7 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
28
28
  this._scrollbarDragOffset = 0;
29
29
  this._scrollContent = scrollContent;
30
30
  this._scrollbarColor = scrollbarColor;
31
+ this._onScroll = onScroll;
31
32
  // 创建内容容器
32
33
  this._content = new Container();
33
34
  this.addChild(this._content);
@@ -247,6 +248,7 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
247
248
  const scrollY = Math.min(Math.max(-this._content.y, 0), maxScrollY);
248
249
  const barY = (scrollY / maxScrollY) * (viewHeight - barHeight);
249
250
  this._scrollbar.y = barY;
251
+ this._onScroll(this._content.y);
250
252
  }
251
253
  /** @description 更新滚动条大小 */
252
254
  _updateScrollbarSize() {
package/lyb-pixi.js CHANGED
@@ -49265,7 +49265,8 @@ void main(void)\r
49265
49265
  scrollContent,
49266
49266
  scrollbarRgiht,
49267
49267
  scrollbarWidth = 10,
49268
- scrollbarColor = "#ffffff"
49268
+ scrollbarColor = "#ffffff",
49269
+ onScroll
49269
49270
  } = params;
49270
49271
  super(width, height);
49271
49272
  this._startY = 0;
@@ -49278,6 +49279,7 @@ void main(void)\r
49278
49279
  this._scrollbarDragOffset = 0;
49279
49280
  this._scrollContent = scrollContent;
49280
49281
  this._scrollbarColor = scrollbarColor;
49282
+ this._onScroll = onScroll;
49281
49283
  this._content = new Container();
49282
49284
  this.addChild(this._content);
49283
49285
  this._content.addChild(this._scrollContent);
@@ -49485,6 +49487,7 @@ void main(void)\r
49485
49487
  const scrollY = Math.min(Math.max(-this._content.y, 0), maxScrollY);
49486
49488
  const barY = scrollY / maxScrollY * (viewHeight - barHeight);
49487
49489
  this._scrollbar.y = barY;
49490
+ this._onScroll(this._content.y);
49488
49491
  }
49489
49492
  /** @description 更新滚动条大小 */
49490
49493
  _updateScrollbarSize() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyb-pixi-js",
3
- "version": "1.9.1",
3
+ "version": "1.9.2",
4
4
  "description": "自用Pixi.JS方法库",
5
5
  "license": "ISC",
6
6
  "exports": {