lyb-pixi-js 1.8.10 → 1.8.11

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.
@@ -70,10 +70,14 @@ export declare class LibPixiScrollContainerY extends LibPixiContainer {
70
70
  private _limitScrollRange;
71
71
  /** @description 更新滚动位置 */
72
72
  private _updateScrollbar;
73
+ /** @description 更新滚动条大小 */
74
+ private _updateScrollbarSize;
73
75
  /** @description 滚动条按下 */
74
76
  private _onScrollbarDragStart;
75
77
  /** @description 滚动条移动 */
76
78
  private _onScrollbarDragMove;
77
79
  /** @description 滚动条松开 */
78
80
  private _onScrollbarDragEnd;
81
+ /** @description 滚动结束一秒后隐藏滚动条 */
82
+ private _hideScrollbar;
79
83
  }
@@ -1,8 +1,8 @@
1
1
  import { Container } from "pixi.js";
2
+ import { gsap } from "gsap";
3
+ import { LibPixiRectangle } from "../Base/LibPixiRectangle";
2
4
  import { libPixiEvent } from "../../Utils/LibPixiEvent";
3
5
  import { LibPixiContainer } from "../Base/LibPixiContainer";
4
- import { LibPixiRectangle } from "../Base/LibPixiRectangle";
5
- import { gsap } from "gsap";
6
6
  /** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
7
7
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y 轴滚动容器
8
8
  */
@@ -41,13 +41,28 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
41
41
  this._scrollbar.x = width - (scrollbarRgiht || scrollbarWidth);
42
42
  this.addChild(this._scrollbar);
43
43
  this._scrollbar.visible = scrollbar;
44
- this._updateScrollbar();
44
+ this._scrollbar.alpha = 0;
45
+ this._updateScrollbarSize();
46
+ //是否已经离开滚动条
45
47
  libPixiEvent(this._scrollbar, "pointerdown", this._onScrollbarDragStart.bind(this));
48
+ libPixiEvent(this._scrollbar, "pointerenter", () => {
49
+ gsap.killTweensOf(this._scrollbar);
50
+ this._scrollbar.alpha = 1;
51
+ this._updateScrollbarSize();
52
+ });
53
+ libPixiEvent(this._scrollbar, "pointerleave", () => {
54
+ gsap.to(this._scrollbar, {
55
+ duration: 0.5,
56
+ alpha: 0,
57
+ delay: 1,
58
+ });
59
+ });
46
60
  // 添加事件监听
47
61
  this.eventMode = "static";
48
62
  this.on("pointerdown", this._onDragStart, this);
49
63
  libPixiEvent(this, "pointerdown", (event) => {
50
64
  this._onDragStart(event);
65
+ this._updateScrollbarSize();
51
66
  });
52
67
  libPixiEvent(this, "pointermove", (event) => {
53
68
  this._onScrollbarDragMove(event);
@@ -59,6 +74,7 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
59
74
  });
60
75
  libPixiEvent(this, "wheel", (event) => {
61
76
  this._onWheelScroll(event);
77
+ this._updateScrollbarSize();
62
78
  });
63
79
  libPixiEvent(this, "pointerupoutside", () => {
64
80
  this._onDragEnd();
@@ -75,6 +91,7 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
75
91
  this._maskGraphics.drawRect(0, 0, width, height);
76
92
  this._maskGraphics.endFill();
77
93
  this.setSize(width, height);
94
+ this._scrollbar.x = width - 50;
78
95
  }
79
96
  /** @description 返回顶部 */
80
97
  scrollToTop() {
@@ -103,8 +120,8 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
103
120
  const position = event.getLocalPosition(this);
104
121
  const newPosition = position.y - this._startY;
105
122
  this._content.y = newPosition;
123
+ this._updateScrollbar();
106
124
  }
107
- this._updateScrollbar();
108
125
  }
109
126
  /** @description 拖动结束 */
110
127
  _onDragEnd() {
@@ -122,6 +139,11 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
122
139
  this._velocity = 0;
123
140
  }
124
141
  this._limitScrollRange();
142
+ gsap.to(this._scrollbar, {
143
+ duration: 0.5,
144
+ alpha: 0,
145
+ delay: 0.25,
146
+ });
125
147
  }
126
148
  /** @description 滚轮滚动 */
127
149
  _onWheelScroll(event) {
@@ -144,6 +166,9 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
144
166
  onUpdate: () => {
145
167
  this._updateScrollbar();
146
168
  },
169
+ onComplete: () => {
170
+ this._hideScrollbar();
171
+ },
147
172
  });
148
173
  }
149
174
  /** @description 惯性动画 */
@@ -156,6 +181,9 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
156
181
  this._limitScrollRange();
157
182
  this._updateScrollbar();
158
183
  },
184
+ onComplete: () => {
185
+ this._hideScrollbar();
186
+ },
159
187
  });
160
188
  }
161
189
  /** @description 限制滚动范围 */
@@ -169,6 +197,9 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
169
197
  onUpdate: () => {
170
198
  this._updateScrollbar();
171
199
  },
200
+ onComplete: () => {
201
+ this._hideScrollbar();
202
+ },
172
203
  });
173
204
  }
174
205
  // 如果滚动距离大于内容高度减去遮罩高度
@@ -184,6 +215,9 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
184
215
  onUpdate: () => {
185
216
  this._updateScrollbar();
186
217
  },
218
+ onComplete: () => {
219
+ this._hideScrollbar();
220
+ },
187
221
  });
188
222
  }
189
223
  // 否则静止不动
@@ -194,29 +228,36 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
194
228
  onUpdate: () => {
195
229
  this._updateScrollbar();
196
230
  },
231
+ onComplete: () => {
232
+ this._hideScrollbar();
233
+ },
197
234
  });
198
235
  }
199
236
  }
200
237
  }
201
238
  /** @description 更新滚动位置 */
202
239
  _updateScrollbar() {
240
+ this._scrollbar.alpha = 1;
241
+ gsap.killTweensOf(this._scrollbar);
203
242
  const viewHeight = this._maskGraphics.height;
204
243
  const contentHeight = this._content.height;
205
- if (contentHeight <= viewHeight) {
206
- this._scrollbar.alpha = 0;
207
- return;
208
- }
209
- this._scrollbar.alpha = 1;
210
244
  const ratio = viewHeight / contentHeight;
211
245
  const barHeight = viewHeight * ratio;
212
246
  const maxScrollY = contentHeight - viewHeight;
213
247
  const scrollY = Math.min(Math.max(-this._content.y, 0), maxScrollY);
214
248
  const barY = (scrollY / maxScrollY) * (viewHeight - barHeight);
249
+ this._scrollbar.y = barY;
250
+ }
251
+ /** @description 更新滚动条大小 */
252
+ _updateScrollbarSize() {
253
+ const viewHeight = this._maskGraphics.height;
254
+ const contentHeight = this._content.height;
255
+ const ratio = viewHeight / contentHeight;
256
+ const barHeight = viewHeight * ratio;
215
257
  this._scrollbar.clear();
216
258
  this._scrollbar.beginFill(this._scrollbarColor);
217
259
  this._scrollbar.drawRect(0, 0, 10, barHeight);
218
260
  this._scrollbar.endFill();
219
- this._scrollbar.y = barY;
220
261
  }
221
262
  /** @description 滚动条按下 */
222
263
  _onScrollbarDragStart(event) {
@@ -246,4 +287,12 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
246
287
  event.stopPropagation();
247
288
  this._scrollbarDragging = false;
248
289
  }
290
+ /** @description 滚动结束一秒后隐藏滚动条 */
291
+ _hideScrollbar() {
292
+ gsap.to(this._scrollbar, {
293
+ duration: 0.5,
294
+ alpha: 0,
295
+ delay: 0.25,
296
+ });
297
+ }
249
298
  }
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 tag = 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$1 = Math.abs;
1702
1702
  var floor$1 = Math.floor;
1703
- var max$2 = Math.max;
1703
+ var max$1 = Math.max;
1704
1704
  var min$1 = Math.min;
1705
1705
  var pow$1 = Math.pow;
1706
1706
  var round$2 = 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$1 = 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$1(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 = abs$1;
2008
2032
  var floor = floor$1;
2009
- var max = max$2;
2033
+ var max = max$1;
2010
2034
  var min = min$1;
2011
2035
  var pow = pow$1;
2012
2036
  var round$1 = round$2;
@@ -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);
@@ -49268,16 +49292,30 @@ void main(void)\r
49268
49292
  this._scrollbar.x = width - (scrollbarRgiht || scrollbarWidth);
49269
49293
  this.addChild(this._scrollbar);
49270
49294
  this._scrollbar.visible = scrollbar;
49271
- this._updateScrollbar();
49295
+ this._scrollbar.alpha = 0;
49296
+ this._updateScrollbarSize();
49272
49297
  libPixiEvent(
49273
49298
  this._scrollbar,
49274
49299
  "pointerdown",
49275
49300
  this._onScrollbarDragStart.bind(this)
49276
49301
  );
49302
+ libPixiEvent(this._scrollbar, "pointerenter", () => {
49303
+ gsapWithCSS.killTweensOf(this._scrollbar);
49304
+ this._scrollbar.alpha = 1;
49305
+ this._updateScrollbarSize();
49306
+ });
49307
+ libPixiEvent(this._scrollbar, "pointerleave", () => {
49308
+ gsapWithCSS.to(this._scrollbar, {
49309
+ duration: 0.5,
49310
+ alpha: 0,
49311
+ delay: 1
49312
+ });
49313
+ });
49277
49314
  this.eventMode = "static";
49278
49315
  this.on("pointerdown", this._onDragStart, this);
49279
49316
  libPixiEvent(this, "pointerdown", (event) => {
49280
49317
  this._onDragStart(event);
49318
+ this._updateScrollbarSize();
49281
49319
  });
49282
49320
  libPixiEvent(this, "pointermove", (event) => {
49283
49321
  this._onScrollbarDragMove(event);
@@ -49289,6 +49327,7 @@ void main(void)\r
49289
49327
  });
49290
49328
  libPixiEvent(this, "wheel", (event) => {
49291
49329
  this._onWheelScroll(event);
49330
+ this._updateScrollbarSize();
49292
49331
  });
49293
49332
  libPixiEvent(this, "pointerupoutside", () => {
49294
49333
  this._onDragEnd();
@@ -49304,6 +49343,7 @@ void main(void)\r
49304
49343
  this._maskGraphics.drawRect(0, 0, width, height);
49305
49344
  this._maskGraphics.endFill();
49306
49345
  this.setSize(width, height);
49346
+ this._scrollbar.x = width - 50;
49307
49347
  }
49308
49348
  /** @description 返回顶部 */
49309
49349
  scrollToTop() {
@@ -49332,8 +49372,8 @@ void main(void)\r
49332
49372
  const position = event.getLocalPosition(this);
49333
49373
  const newPosition = position.y - this._startY;
49334
49374
  this._content.y = newPosition;
49375
+ this._updateScrollbar();
49335
49376
  }
49336
- this._updateScrollbar();
49337
49377
  }
49338
49378
  /** @description 拖动结束 */
49339
49379
  _onDragEnd() {
@@ -49348,6 +49388,11 @@ void main(void)\r
49348
49388
  this._velocity = 0;
49349
49389
  }
49350
49390
  this._limitScrollRange();
49391
+ gsapWithCSS.to(this._scrollbar, {
49392
+ duration: 0.5,
49393
+ alpha: 0,
49394
+ delay: 0.25
49395
+ });
49351
49396
  }
49352
49397
  /** @description 滚轮滚动 */
49353
49398
  _onWheelScroll(event) {
@@ -49365,6 +49410,9 @@ void main(void)\r
49365
49410
  y: y2,
49366
49411
  onUpdate: () => {
49367
49412
  this._updateScrollbar();
49413
+ },
49414
+ onComplete: () => {
49415
+ this._hideScrollbar();
49368
49416
  }
49369
49417
  });
49370
49418
  }
@@ -49377,6 +49425,9 @@ void main(void)\r
49377
49425
  onUpdate: () => {
49378
49426
  this._limitScrollRange();
49379
49427
  this._updateScrollbar();
49428
+ },
49429
+ onComplete: () => {
49430
+ this._hideScrollbar();
49380
49431
  }
49381
49432
  });
49382
49433
  }
@@ -49389,6 +49440,9 @@ void main(void)\r
49389
49440
  ease: "elastic.out",
49390
49441
  onUpdate: () => {
49391
49442
  this._updateScrollbar();
49443
+ },
49444
+ onComplete: () => {
49445
+ this._hideScrollbar();
49392
49446
  }
49393
49447
  });
49394
49448
  } else if (Math.abs(this._content.y) >= this._content.height - this._maskGraphics.height) {
@@ -49400,6 +49454,9 @@ void main(void)\r
49400
49454
  ease: "elastic.out",
49401
49455
  onUpdate: () => {
49402
49456
  this._updateScrollbar();
49457
+ },
49458
+ onComplete: () => {
49459
+ this._hideScrollbar();
49403
49460
  }
49404
49461
  });
49405
49462
  } else {
@@ -49408,6 +49465,9 @@ void main(void)\r
49408
49465
  y: 0,
49409
49466
  onUpdate: () => {
49410
49467
  this._updateScrollbar();
49468
+ },
49469
+ onComplete: () => {
49470
+ this._hideScrollbar();
49411
49471
  }
49412
49472
  });
49413
49473
  }
@@ -49415,23 +49475,27 @@ void main(void)\r
49415
49475
  }
49416
49476
  /** @description 更新滚动位置 */
49417
49477
  _updateScrollbar() {
49478
+ this._scrollbar.alpha = 1;
49479
+ gsapWithCSS.killTweensOf(this._scrollbar);
49418
49480
  const viewHeight = this._maskGraphics.height;
49419
49481
  const contentHeight = this._content.height;
49420
- if (contentHeight <= viewHeight) {
49421
- this._scrollbar.alpha = 0;
49422
- return;
49423
- }
49424
- this._scrollbar.alpha = 1;
49425
49482
  const ratio = viewHeight / contentHeight;
49426
49483
  const barHeight = viewHeight * ratio;
49427
49484
  const maxScrollY = contentHeight - viewHeight;
49428
49485
  const scrollY = Math.min(Math.max(-this._content.y, 0), maxScrollY);
49429
49486
  const barY = scrollY / maxScrollY * (viewHeight - barHeight);
49487
+ this._scrollbar.y = barY;
49488
+ }
49489
+ /** @description 更新滚动条大小 */
49490
+ _updateScrollbarSize() {
49491
+ const viewHeight = this._maskGraphics.height;
49492
+ const contentHeight = this._content.height;
49493
+ const ratio = viewHeight / contentHeight;
49494
+ const barHeight = viewHeight * ratio;
49430
49495
  this._scrollbar.clear();
49431
49496
  this._scrollbar.beginFill(this._scrollbarColor);
49432
49497
  this._scrollbar.drawRect(0, 0, 10, barHeight);
49433
49498
  this._scrollbar.endFill();
49434
- this._scrollbar.y = barY;
49435
49499
  }
49436
49500
  /** @description 滚动条按下 */
49437
49501
  _onScrollbarDragStart(event) {
@@ -49464,6 +49528,14 @@ void main(void)\r
49464
49528
  event.stopPropagation();
49465
49529
  this._scrollbarDragging = false;
49466
49530
  }
49531
+ /** @description 滚动结束一秒后隐藏滚动条 */
49532
+ _hideScrollbar() {
49533
+ gsapWithCSS.to(this._scrollbar, {
49534
+ duration: 0.5,
49535
+ alpha: 0,
49536
+ delay: 0.25
49537
+ });
49538
+ }
49467
49539
  }
49468
49540
  const LibJsLerp = (start, end, value) => {
49469
49541
  const t2 = Math.min(Math.max(value, 0), 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyb-pixi-js",
3
- "version": "1.8.10",
3
+ "version": "1.8.11",
4
4
  "description": "自用Pixi.JS方法库",
5
5
  "license": "ISC",
6
6
  "exports": {