lyb-pixi-js 1.12.28 → 1.12.29

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,4 +1,4 @@
1
- import { Container } from "pixi.js";
1
+ import { Container, Texture } from "pixi.js";
2
2
  import { LibPixiContainer } from "../Base/LibPixiContainer";
3
3
  export interface LibPixiScrollContainerXParams {
4
4
  /** 宽度 */
@@ -9,13 +9,17 @@ export interface LibPixiScrollContainerXParams {
9
9
  scrollContent: Container;
10
10
  /** 背景色,用于定位 */
11
11
  bgColor?: string;
12
- /** 右边距 */
13
- rightMargin?: number;
12
+ /** 自定义遮罩贴图 */
13
+ maskTexture?: Texture;
14
+ /** 遮罩X坐标 */
15
+ maskX?: number;
16
+ /** 遮罩Y坐标 */
17
+ maskY?: number;
14
18
  }
15
- /** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
16
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerX-X轴滚动容器
17
- */
19
+ /** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹 */
18
20
  export declare class LibPixiScrollContainerX extends LibPixiContainer {
21
+ /** 舞台 */
22
+ static stage: Container;
19
23
  /** 开始位置 */
20
24
  private _startX;
21
25
  /** 惯性速度 */
@@ -28,6 +32,10 @@ export declare class LibPixiScrollContainerX extends LibPixiContainer {
28
32
  private _scrollSpeed;
29
33
  /** 是否处于拖动状态 */
30
34
  private _isDragging;
35
+ /** 左边距 */
36
+ private _leftMargin;
37
+ /** 右边距元素 */
38
+ private _rightMarginBox;
31
39
  /** 滚动容器 */
32
40
  _scrollContent: Container;
33
41
  /** 遮罩 */
@@ -35,6 +43,8 @@ export declare class LibPixiScrollContainerX extends LibPixiContainer {
35
43
  /** 滚动的内容 */
36
44
  private _content;
37
45
  constructor(params: LibPixiScrollContainerXParams);
46
+ /** @description 添加边距 */
47
+ addMargin(leftMargin: number, rightMargin?: number): void;
38
48
  /** @description 设置滚动容器可视区宽高
39
49
  * @param width 宽度
40
50
  * @param height 高度
@@ -44,6 +54,8 @@ export declare class LibPixiScrollContainerX extends LibPixiContainer {
44
54
  scrollToTop(): void;
45
55
  /** @description 往滚动内容添加元素 */
46
56
  addContent(container: Container): void;
57
+ /** @description 更新右边距坐标 */
58
+ private _updateRightMargin;
47
59
  /** @description 按下 */
48
60
  private _onDragStart;
49
61
  /** @description 拖动 */
@@ -1,12 +1,12 @@
1
- import { Container, Graphics, Sprite, } from "pixi.js";
1
+ import { Container, Sprite, } from "pixi.js";
2
2
  import { gsap } from "gsap";
3
+ import { libPixiEvent } from "../../Utils/LibPixiEvent";
3
4
  import { LibPixiContainer } from "../Base/LibPixiContainer";
4
- /** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
5
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerX-X轴滚动容器
6
- */
5
+ import { LibPixiRectangle } from "../Base/LibPixiRectangle";
6
+ /** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹 */
7
7
  export class LibPixiScrollContainerX extends LibPixiContainer {
8
8
  constructor(params) {
9
- const { width, height, scrollContent, bgColor, rightMargin = 0 } = params;
9
+ const { width, height, scrollContent, bgColor, maskTexture, maskX = 0, maskY = 0, } = params;
10
10
  super(width, height, bgColor);
11
11
  /** 开始位置 */
12
12
  this._startX = 0;
@@ -20,42 +20,69 @@ export class LibPixiScrollContainerX extends LibPixiContainer {
20
20
  this._scrollSpeed = 200;
21
21
  /** 是否处于拖动状态 */
22
22
  this._isDragging = false;
23
+ /** 左边距 */
24
+ this._leftMargin = 0;
23
25
  this._scrollContent = scrollContent;
24
26
  // 创建内容容器
25
27
  this._content = new Container();
26
28
  this.addChild(this._content);
27
29
  this._content.addChild(this._scrollContent);
28
- //创建右边距
29
- const rightMarginBox = new Sprite();
30
- this._content.addChild(rightMarginBox);
31
- rightMarginBox.width = this._content.width + rightMargin;
32
- // 创建遮罩
33
- this._maskGraphics = new Graphics();
34
- this.addChild(this._maskGraphics);
35
- this._maskGraphics.clear();
36
- this._maskGraphics.beginFill(0x000000);
37
- this._maskGraphics.drawRect(0, 0, width, height);
38
- this._maskGraphics.endFill();
39
- this.mask = this._maskGraphics;
30
+ //自定义遮罩
31
+ if (maskTexture) {
32
+ this._maskGraphics = new Sprite(maskTexture);
33
+ this.addChild(this._maskGraphics);
34
+ this._maskGraphics.width = width;
35
+ this._maskGraphics.height = height;
36
+ this._maskGraphics.position.set(maskX, maskY);
37
+ this.mask = this._maskGraphics;
38
+ }
39
+ else {
40
+ this._maskGraphics = new LibPixiRectangle(width, height, "#000");
41
+ this.addChild(this._maskGraphics);
42
+ this.mask = this._maskGraphics;
43
+ }
40
44
  // 添加事件监听
41
- this.eventMode = "static";
42
- this.on("pointerdown", this._onDragStart, this);
43
- this.on("pointermove", this._onDragMove, this);
44
- this.on("pointerup", this._onDragEnd, this);
45
- this.on("pointerupoutside", this._onDragEnd, this);
46
- this.on("wheel", this._onWheelScroll, this);
45
+ libPixiEvent(this, "pointerdown", (event) => {
46
+ this._onDragStart(event);
47
+ });
48
+ libPixiEvent(LibPixiScrollContainerX.stage, "pointermove", (event) => {
49
+ this._onDragMove(event);
50
+ });
51
+ libPixiEvent(this, "pointerup", () => {
52
+ this._onDragEnd();
53
+ });
54
+ libPixiEvent(this, "wheel", (event) => {
55
+ this._onWheelScroll(event);
56
+ });
57
+ libPixiEvent(this, "pointerupoutside", () => {
58
+ this._onDragEnd();
59
+ });
60
+ }
61
+ /** @description 添加边距 */
62
+ addMargin(leftMargin, rightMargin = leftMargin) {
63
+ this._leftMargin = leftMargin;
64
+ if (leftMargin) {
65
+ const leftMarginBox = new Sprite();
66
+ this._content.addChild(leftMarginBox);
67
+ leftMarginBox.width = leftMargin;
68
+ this._scrollContent.x += leftMargin;
69
+ }
70
+ if (rightMargin) {
71
+ this._rightMarginBox = new Sprite();
72
+ this._content.addChild(this._rightMarginBox);
73
+ this._rightMarginBox.height = rightMargin;
74
+ this._rightMarginBox.x = leftMargin + this._scrollContent.width;
75
+ }
47
76
  }
48
77
  /** @description 设置滚动容器可视区宽高
49
78
  * @param width 宽度
50
79
  * @param height 高度
51
80
  */
52
81
  setDimensions(width, height) {
53
- // 更新遮罩尺寸
54
- this._maskGraphics.clear();
55
- this._maskGraphics.beginFill(0x000000);
56
- this._maskGraphics.drawRect(0, 0, width, height);
57
- this._maskGraphics.endFill();
82
+ this._maskGraphics.width = width;
83
+ this._maskGraphics.height = height;
58
84
  this.setSize(width, height);
85
+ this._updateRightMargin();
59
86
  }
60
87
  /** @description 返回顶部 */
61
88
  scrollToTop() {
@@ -66,12 +93,16 @@ export class LibPixiScrollContainerX extends LibPixiContainer {
66
93
  addContent(container) {
67
94
  this._scrollContent.addChild(container);
68
95
  }
96
+ /** @description 更新右边距坐标 */
97
+ _updateRightMargin() {
98
+ this._rightMarginBox.x = this._leftMargin + this._scrollContent.width;
99
+ }
69
100
  /** @description 按下 */
70
101
  _onDragStart(event) {
71
102
  if (this._content.width <= this._maskGraphics.width)
72
103
  return;
73
- const position = event.getLocalPosition(this);
74
- this._startX = position.x - this._content.x;
104
+ const { x } = event.getLocalPosition(this);
105
+ this._startX = x - this._content.x;
75
106
  this._isDragging = true;
76
107
  this._velocity = 0;
77
108
  this._startTime = Date.now();
@@ -81,8 +112,8 @@ export class LibPixiScrollContainerX extends LibPixiContainer {
81
112
  /** @description 拖动 */
82
113
  _onDragMove(event) {
83
114
  if (this._isDragging) {
84
- const position = event.getLocalPosition(this);
85
- const newPosition = position.x - this._startX;
115
+ const { x } = event.getLocalPosition(this);
116
+ const newPosition = x - this._startX;
86
117
  this._content.x = newPosition;
87
118
  }
88
119
  }
@@ -133,10 +164,11 @@ export class LibPixiScrollContainerX extends LibPixiContainer {
133
164
  _limitScrollRange() {
134
165
  //如果内容顶部离开了滚动容器顶部,则归位
135
166
  if (this._content.x > 0) {
167
+ //回弹
136
168
  gsap.to(this._content, {
137
- duration: 0.75,
169
+ duration: 0.2,
170
+ ease: "power1.out",
138
171
  x: 0,
139
- ease: "elastic.out",
140
172
  });
141
173
  }
142
174
  // 如果滚动距离大于内容高度减去遮罩高度
@@ -144,18 +176,12 @@ export class LibPixiScrollContainerX extends LibPixiContainer {
144
176
  this._content.width - this._maskGraphics.width) {
145
177
  // 如果内容高度大于遮罩高度,则滚动到底部
146
178
  if (this._content.width > this._maskGraphics.width) {
179
+ //回弹
147
180
  const x = -(this._content.width - this._maskGraphics.width);
148
181
  gsap.to(this._content, {
149
- duration: 0.75,
182
+ duration: 0.2,
183
+ ease: "power1.out",
150
184
  x,
151
- ease: "elastic.out",
152
- });
153
- }
154
- // 否则静止不动
155
- else {
156
- gsap.to(this._content, {
157
- duration: 0.25,
158
- x: 0,
159
185
  });
160
186
  }
161
187
  }
@@ -26,10 +26,10 @@ export interface LibPixiScrollContainerYParams {
26
26
  /** 滚动触发 */
27
27
  onScroll?: (y: number) => void;
28
28
  }
29
- /** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
30
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y轴滚动容器
31
- */
29
+ /** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹 */
32
30
  export declare class LibPixiScrollContainerY extends LibPixiContainer {
31
+ /** 舞台 */
32
+ static stage: Container;
33
33
  /** 开始位置 */
34
34
  private _startY;
35
35
  /** 惯性速度 */
@@ -3,9 +3,7 @@ import { gsap } from "gsap";
3
3
  import { libPixiEvent } from "../../Utils/LibPixiEvent";
4
4
  import { LibPixiContainer } from "../Base/LibPixiContainer";
5
5
  import { LibPixiRectangle } from "../Base/LibPixiRectangle";
6
- /** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
7
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y轴滚动容器
8
- */
6
+ /** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹 */
9
7
  export class LibPixiScrollContainerY extends LibPixiContainer {
10
8
  constructor(params) {
11
9
  const { width, height, scrollbar = false, scrollContent, scrollbarRgiht = 0, scrollbarWidth = 10, scrollbarColor = "#ffffff", onScroll, bgColor, maskTexture, maskX = 0, maskY = 0, } = params;
@@ -74,13 +72,11 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
74
72
  });
75
73
  });
76
74
  // 添加事件监听
77
- this.eventMode = "static";
78
- this.on("pointerdown", this._onDragStart, this);
79
75
  libPixiEvent(this, "pointerdown", (event) => {
80
76
  this._onDragStart(event);
81
77
  this._updateScrollbarSize();
82
78
  });
83
- libPixiEvent(this, "pointermove", (event) => {
79
+ libPixiEvent(LibPixiScrollContainerY.stage, "pointermove", (event) => {
84
80
  this._onScrollbarDragMove(event);
85
81
  this._onDragMove(event);
86
82
  });
package/lyb-pixi.js CHANGED
@@ -1315,7 +1315,7 @@
1315
1315
  var ys = arrObjKeys(obj, inspect2);
1316
1316
  var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
1317
1317
  var protoTag = obj instanceof Object ? "" : "null prototype";
1318
- var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr$1(obj), 8, -1) : protoTag ? "Object" : "";
1318
+ var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
1319
1319
  var constructorTag = isPlainObject || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
1320
1320
  var tag2 = constructorTag + (stringTag || protoTag ? "[" + $join.call($concat$1.call([], stringTag || [], protoTag || []), ": ") + "] " : "");
1321
1321
  if (ys.length === 0) {
@@ -1337,25 +1337,25 @@
1337
1337
  return $replace$1.call(String(s2), /"/g, "&quot;");
1338
1338
  }
1339
1339
  function isArray$3(obj) {
1340
- return toStr$1(obj) === "[object Array]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1340
+ return toStr(obj) === "[object Array]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1341
1341
  }
1342
1342
  function isDate(obj) {
1343
- return toStr$1(obj) === "[object Date]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1343
+ return toStr(obj) === "[object Date]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1344
1344
  }
1345
1345
  function isRegExp$1(obj) {
1346
- return toStr$1(obj) === "[object RegExp]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1346
+ return toStr(obj) === "[object RegExp]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1347
1347
  }
1348
1348
  function isError(obj) {
1349
- return toStr$1(obj) === "[object Error]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1349
+ return toStr(obj) === "[object Error]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1350
1350
  }
1351
1351
  function isString(obj) {
1352
- return toStr$1(obj) === "[object String]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1352
+ return toStr(obj) === "[object String]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1353
1353
  }
1354
1354
  function isNumber(obj) {
1355
- return toStr$1(obj) === "[object Number]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1355
+ return toStr(obj) === "[object Number]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1356
1356
  }
1357
1357
  function isBoolean(obj) {
1358
- return toStr$1(obj) === "[object Boolean]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1358
+ return toStr(obj) === "[object Boolean]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1359
1359
  }
1360
1360
  function isSymbol(obj) {
1361
1361
  if (hasShammedSymbols) {
@@ -1391,7 +1391,7 @@
1391
1391
  function has$3(obj, key) {
1392
1392
  return hasOwn$1.call(obj, key);
1393
1393
  }
1394
- function toStr$1(obj) {
1394
+ function toStr(obj) {
1395
1395
  return objectToString.call(obj);
1396
1396
  }
1397
1397
  function nameOf(f2) {
@@ -1700,7 +1700,7 @@
1700
1700
  var uri = URIError;
1701
1701
  var abs$2 = Math.abs;
1702
1702
  var floor$2 = Math.floor;
1703
- var max$3 = Math.max;
1703
+ var max$2 = Math.max;
1704
1704
  var min$2 = Math.min;
1705
1705
  var pow$2 = Math.pow;
1706
1706
  var round$3 = Math.round;
@@ -1833,78 +1833,102 @@
1833
1833
  Object_getPrototypeOf = $Object2.getPrototypeOf || null;
1834
1834
  return Object_getPrototypeOf;
1835
1835
  }
1836
- var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
1837
- var toStr = Object.prototype.toString;
1838
- var max$2 = Math.max;
1839
- var funcType = "[object Function]";
1840
- var concatty = function concatty2(a2, b2) {
1841
- var arr = [];
1842
- for (var i2 = 0; i2 < a2.length; i2 += 1) {
1843
- arr[i2] = a2[i2];
1844
- }
1845
- for (var j2 = 0; j2 < b2.length; j2 += 1) {
1846
- arr[j2 + a2.length] = b2[j2];
1847
- }
1848
- return arr;
1849
- };
1850
- var slicy = function slicy2(arrLike, offset) {
1851
- var arr = [];
1852
- for (var i2 = offset || 0, j2 = 0; i2 < arrLike.length; i2 += 1, j2 += 1) {
1853
- arr[j2] = arrLike[i2];
1854
- }
1855
- return arr;
1856
- };
1857
- var joiny = function(arr, joiner) {
1858
- var str = "";
1859
- for (var i2 = 0; i2 < arr.length; i2 += 1) {
1860
- str += arr[i2];
1861
- if (i2 + 1 < arr.length) {
1862
- str += joiner;
1836
+ var implementation;
1837
+ var hasRequiredImplementation;
1838
+ function requireImplementation() {
1839
+ if (hasRequiredImplementation)
1840
+ return implementation;
1841
+ hasRequiredImplementation = 1;
1842
+ var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
1843
+ var toStr2 = Object.prototype.toString;
1844
+ var max2 = Math.max;
1845
+ var funcType = "[object Function]";
1846
+ var concatty = function concatty2(a2, b2) {
1847
+ var arr = [];
1848
+ for (var i2 = 0; i2 < a2.length; i2 += 1) {
1849
+ arr[i2] = a2[i2];
1863
1850
  }
1864
- }
1865
- return str;
1866
- };
1867
- var implementation$1 = function bind2(that) {
1868
- var target = this;
1869
- if (typeof target !== "function" || toStr.apply(target) !== funcType) {
1870
- throw new TypeError(ERROR_MESSAGE + target);
1871
- }
1872
- var args = slicy(arguments, 1);
1873
- var bound;
1874
- var binder = function() {
1875
- if (this instanceof bound) {
1876
- var result = target.apply(
1877
- this,
1878
- concatty(args, arguments)
1879
- );
1880
- if (Object(result) === result) {
1881
- return result;
1851
+ for (var j2 = 0; j2 < b2.length; j2 += 1) {
1852
+ arr[j2 + a2.length] = b2[j2];
1853
+ }
1854
+ return arr;
1855
+ };
1856
+ var slicy = function slicy2(arrLike, offset) {
1857
+ var arr = [];
1858
+ for (var i2 = offset || 0, j2 = 0; i2 < arrLike.length; i2 += 1, j2 += 1) {
1859
+ arr[j2] = arrLike[i2];
1860
+ }
1861
+ return arr;
1862
+ };
1863
+ var joiny = function(arr, joiner) {
1864
+ var str = "";
1865
+ for (var i2 = 0; i2 < arr.length; i2 += 1) {
1866
+ str += arr[i2];
1867
+ if (i2 + 1 < arr.length) {
1868
+ str += joiner;
1882
1869
  }
1883
- return this;
1884
1870
  }
1885
- return target.apply(
1886
- that,
1887
- concatty(args, arguments)
1888
- );
1871
+ return str;
1889
1872
  };
1890
- var boundLength = max$2(0, target.length - args.length);
1891
- var boundArgs = [];
1892
- for (var i2 = 0; i2 < boundLength; i2++) {
1893
- boundArgs[i2] = "$" + i2;
1894
- }
1895
- bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
1896
- if (target.prototype) {
1897
- var Empty = function Empty2() {
1873
+ implementation = function bind2(that) {
1874
+ var target = this;
1875
+ if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
1876
+ throw new TypeError(ERROR_MESSAGE + target);
1877
+ }
1878
+ var args = slicy(arguments, 1);
1879
+ var bound;
1880
+ var binder = function() {
1881
+ if (this instanceof bound) {
1882
+ var result = target.apply(
1883
+ this,
1884
+ concatty(args, arguments)
1885
+ );
1886
+ if (Object(result) === result) {
1887
+ return result;
1888
+ }
1889
+ return this;
1890
+ }
1891
+ return target.apply(
1892
+ that,
1893
+ concatty(args, arguments)
1894
+ );
1898
1895
  };
1899
- Empty.prototype = target.prototype;
1900
- bound.prototype = new Empty();
1901
- Empty.prototype = null;
1902
- }
1903
- return bound;
1904
- };
1905
- var implementation = implementation$1;
1906
- var functionBind = Function.prototype.bind || implementation;
1907
- var functionCall = Function.prototype.call;
1896
+ var boundLength = max2(0, target.length - args.length);
1897
+ var boundArgs = [];
1898
+ for (var i2 = 0; i2 < boundLength; i2++) {
1899
+ boundArgs[i2] = "$" + i2;
1900
+ }
1901
+ bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
1902
+ if (target.prototype) {
1903
+ var Empty = function Empty2() {
1904
+ };
1905
+ Empty.prototype = target.prototype;
1906
+ bound.prototype = new Empty();
1907
+ Empty.prototype = null;
1908
+ }
1909
+ return bound;
1910
+ };
1911
+ return implementation;
1912
+ }
1913
+ var functionBind;
1914
+ var hasRequiredFunctionBind;
1915
+ function requireFunctionBind() {
1916
+ if (hasRequiredFunctionBind)
1917
+ return functionBind;
1918
+ hasRequiredFunctionBind = 1;
1919
+ var implementation2 = requireImplementation();
1920
+ functionBind = Function.prototype.bind || implementation2;
1921
+ return functionBind;
1922
+ }
1923
+ var functionCall;
1924
+ var hasRequiredFunctionCall;
1925
+ function requireFunctionCall() {
1926
+ if (hasRequiredFunctionCall)
1927
+ return functionCall;
1928
+ hasRequiredFunctionCall = 1;
1929
+ functionCall = Function.prototype.call;
1930
+ return functionCall;
1931
+ }
1908
1932
  var functionApply;
1909
1933
  var hasRequiredFunctionApply;
1910
1934
  function requireFunctionApply() {
@@ -1915,14 +1939,14 @@
1915
1939
  return functionApply;
1916
1940
  }
1917
1941
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
1918
- var bind$2 = functionBind;
1942
+ var bind$2 = requireFunctionBind();
1919
1943
  var $apply$1 = requireFunctionApply();
1920
- var $call$2 = functionCall;
1944
+ var $call$2 = requireFunctionCall();
1921
1945
  var $reflectApply = reflectApply;
1922
1946
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
1923
- var bind$1 = functionBind;
1947
+ var bind$1 = requireFunctionBind();
1924
1948
  var $TypeError$4 = type;
1925
- var $call$1 = functionCall;
1949
+ var $call$1 = requireFunctionCall();
1926
1950
  var $actualApply = actualApply;
1927
1951
  var callBindApplyHelpers = function callBindBasic2(args) {
1928
1952
  if (args.length < 1 || typeof args[0] !== "function") {
@@ -1991,7 +2015,7 @@
1991
2015
  hasRequiredHasown = 1;
1992
2016
  var call = Function.prototype.call;
1993
2017
  var $hasOwn = Object.prototype.hasOwnProperty;
1994
- var bind2 = functionBind;
2018
+ var bind2 = requireFunctionBind();
1995
2019
  hasown = bind2.call(call, $hasOwn);
1996
2020
  return hasown;
1997
2021
  }
@@ -2006,7 +2030,7 @@
2006
2030
  var $URIError = uri;
2007
2031
  var abs$1 = abs$2;
2008
2032
  var floor$1 = floor$2;
2009
- var max$1 = max$3;
2033
+ var max$1 = max$2;
2010
2034
  var min$1 = min$2;
2011
2035
  var pow$1 = pow$2;
2012
2036
  var round$2 = round$3;
@@ -2040,7 +2064,7 @@
2040
2064
  var $ObjectGPO = requireObject_getPrototypeOf();
2041
2065
  var $ReflectGPO = requireReflect_getPrototypeOf();
2042
2066
  var $apply = requireFunctionApply();
2043
- var $call = functionCall;
2067
+ var $call = requireFunctionCall();
2044
2068
  var needsEval = {};
2045
2069
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
2046
2070
  var INTRINSICS = {
@@ -2210,7 +2234,7 @@
2210
2234
  "%WeakMapPrototype%": ["WeakMap", "prototype"],
2211
2235
  "%WeakSetPrototype%": ["WeakSet", "prototype"]
2212
2236
  };
2213
- var bind = functionBind;
2237
+ var bind = requireFunctionBind();
2214
2238
  var hasOwn = requireHasown();
2215
2239
  var $concat = bind.call($call, Array.prototype.concat);
2216
2240
  var $spliceApply = bind.call($apply, Array.prototype.splice);
@@ -49201,7 +49225,15 @@ void main(void)\r
49201
49225
  }
49202
49226
  class LibPixiScrollContainerX extends LibPixiContainer {
49203
49227
  constructor(params) {
49204
- const { width, height, scrollContent, bgColor, rightMargin = 0 } = params;
49228
+ const {
49229
+ width,
49230
+ height,
49231
+ scrollContent,
49232
+ bgColor,
49233
+ maskTexture,
49234
+ maskX = 0,
49235
+ maskY = 0
49236
+ } = params;
49205
49237
  super(width, height, bgColor);
49206
49238
  this._startX = 0;
49207
49239
  this._velocity = 0;
@@ -49209,37 +49241,64 @@ void main(void)\r
49209
49241
  this._startPosition = 0;
49210
49242
  this._scrollSpeed = 200;
49211
49243
  this._isDragging = false;
49244
+ this._leftMargin = 0;
49212
49245
  this._scrollContent = scrollContent;
49213
49246
  this._content = new Container();
49214
49247
  this.addChild(this._content);
49215
49248
  this._content.addChild(this._scrollContent);
49216
- const rightMarginBox = new Sprite();
49217
- this._content.addChild(rightMarginBox);
49218
- rightMarginBox.width = this._content.width + rightMargin;
49219
- this._maskGraphics = new Graphics();
49220
- this.addChild(this._maskGraphics);
49221
- this._maskGraphics.clear();
49222
- this._maskGraphics.beginFill(0);
49223
- this._maskGraphics.drawRect(0, 0, width, height);
49224
- this._maskGraphics.endFill();
49225
- this.mask = this._maskGraphics;
49226
- this.eventMode = "static";
49227
- this.on("pointerdown", this._onDragStart, this);
49228
- this.on("pointermove", this._onDragMove, this);
49229
- this.on("pointerup", this._onDragEnd, this);
49230
- this.on("pointerupoutside", this._onDragEnd, this);
49231
- this.on("wheel", this._onWheelScroll, this);
49249
+ if (maskTexture) {
49250
+ this._maskGraphics = new Sprite(maskTexture);
49251
+ this.addChild(this._maskGraphics);
49252
+ this._maskGraphics.width = width;
49253
+ this._maskGraphics.height = height;
49254
+ this._maskGraphics.position.set(maskX, maskY);
49255
+ this.mask = this._maskGraphics;
49256
+ } else {
49257
+ this._maskGraphics = new LibPixiRectangle(width, height, "#000");
49258
+ this.addChild(this._maskGraphics);
49259
+ this.mask = this._maskGraphics;
49260
+ }
49261
+ libPixiEvent(this, "pointerdown", (event) => {
49262
+ this._onDragStart(event);
49263
+ });
49264
+ libPixiEvent(LibPixiScrollContainerX.stage, "pointermove", (event) => {
49265
+ this._onDragMove(event);
49266
+ });
49267
+ libPixiEvent(this, "pointerup", () => {
49268
+ this._onDragEnd();
49269
+ });
49270
+ libPixiEvent(this, "wheel", (event) => {
49271
+ this._onWheelScroll(event);
49272
+ });
49273
+ libPixiEvent(this, "pointerupoutside", () => {
49274
+ this._onDragEnd();
49275
+ });
49276
+ }
49277
+ /** @description 添加边距 */
49278
+ addMargin(leftMargin, rightMargin = leftMargin) {
49279
+ this._leftMargin = leftMargin;
49280
+ if (leftMargin) {
49281
+ const leftMarginBox = new Sprite();
49282
+ this._content.addChild(leftMarginBox);
49283
+ leftMarginBox.width = leftMargin;
49284
+ this._scrollContent.x += leftMargin;
49285
+ }
49286
+ if (rightMargin) {
49287
+ this._rightMarginBox = new Sprite();
49288
+ this._content.addChild(this._rightMarginBox);
49289
+ this._rightMarginBox.height = rightMargin;
49290
+ this._rightMarginBox.x = leftMargin + this._scrollContent.width;
49291
+ }
49232
49292
  }
49233
49293
  /** @description 设置滚动容器可视区宽高
49234
49294
  * @param width 宽度
49235
49295
  * @param height 高度
49236
49296
  */
49237
49297
  setDimensions(width, height) {
49238
- this._maskGraphics.clear();
49239
- this._maskGraphics.beginFill(0);
49240
- this._maskGraphics.drawRect(0, 0, width, height);
49241
- this._maskGraphics.endFill();
49298
+ this._maskGraphics.width = width;
49299
+ this._maskGraphics.height = height;
49242
49300
  this.setSize(width, height);
49301
+ this._updateRightMargin();
49243
49302
  }
49244
49303
  /** @description 返回顶部 */
49245
49304
  scrollToTop() {
@@ -49250,12 +49309,16 @@ void main(void)\r
49250
49309
  addContent(container) {
49251
49310
  this._scrollContent.addChild(container);
49252
49311
  }
49312
+ /** @description 更新右边距坐标 */
49313
+ _updateRightMargin() {
49314
+ this._rightMarginBox.x = this._leftMargin + this._scrollContent.width;
49315
+ }
49253
49316
  /** @description 按下 */
49254
49317
  _onDragStart(event) {
49255
49318
  if (this._content.width <= this._maskGraphics.width)
49256
49319
  return;
49257
- const position = event.getLocalPosition(this);
49258
- this._startX = position.x - this._content.x;
49320
+ const { x: x2 } = event.getLocalPosition(this);
49321
+ this._startX = x2 - this._content.x;
49259
49322
  this._isDragging = true;
49260
49323
  this._velocity = 0;
49261
49324
  this._startTime = Date.now();
@@ -49265,8 +49328,8 @@ void main(void)\r
49265
49328
  /** @description 拖动 */
49266
49329
  _onDragMove(event) {
49267
49330
  if (this._isDragging) {
49268
- const position = event.getLocalPosition(this);
49269
- const newPosition = position.x - this._startX;
49331
+ const { x: x2 } = event.getLocalPosition(this);
49332
+ const newPosition = x2 - this._startX;
49270
49333
  this._content.x = newPosition;
49271
49334
  }
49272
49335
  }
@@ -49312,22 +49375,17 @@ void main(void)\r
49312
49375
  _limitScrollRange() {
49313
49376
  if (this._content.x > 0) {
49314
49377
  gsapWithCSS.to(this._content, {
49315
- duration: 0.75,
49316
- x: 0,
49317
- ease: "elastic.out"
49378
+ duration: 0.2,
49379
+ ease: "power1.out",
49380
+ x: 0
49318
49381
  });
49319
49382
  } else if (Math.abs(this._content.x) >= this._content.width - this._maskGraphics.width) {
49320
49383
  if (this._content.width > this._maskGraphics.width) {
49321
49384
  const x2 = -(this._content.width - this._maskGraphics.width);
49322
49385
  gsapWithCSS.to(this._content, {
49323
- duration: 0.75,
49324
- x: x2,
49325
- ease: "elastic.out"
49326
- });
49327
- } else {
49328
- gsapWithCSS.to(this._content, {
49329
- duration: 0.25,
49330
- x: 0
49386
+ duration: 0.2,
49387
+ ease: "power1.out",
49388
+ x: x2
49331
49389
  });
49332
49390
  }
49333
49391
  }
@@ -49407,13 +49465,11 @@ void main(void)\r
49407
49465
  delay: 1
49408
49466
  });
49409
49467
  });
49410
- this.eventMode = "static";
49411
- this.on("pointerdown", this._onDragStart, this);
49412
49468
  libPixiEvent(this, "pointerdown", (event) => {
49413
49469
  this._onDragStart(event);
49414
49470
  this._updateScrollbarSize();
49415
49471
  });
49416
- libPixiEvent(this, "pointermove", (event) => {
49472
+ libPixiEvent(LibPixiScrollContainerY.stage, "pointermove", (event) => {
49417
49473
  this._onScrollbarDragMove(event);
49418
49474
  this._onDragMove(event);
49419
49475
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyb-pixi-js",
3
- "version": "1.12.28",
3
+ "version": "1.12.29",
4
4
  "description": "自用Pixi.JS方法库",
5
5
  "license": "ISC",
6
6
  "exports": {