lyb-pixi-js 1.11.2 → 1.11.4

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.
@@ -30,6 +30,8 @@ export interface LibPixiSlideParams {
30
30
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiSlide-滑动页
31
31
  */
32
32
  export declare class LibPixiSlide extends LibPixiContainer {
33
+ /** 舞台 */
34
+ private _stage;
33
35
  /** 滑动加速度触发翻页 */
34
36
  private _SPEED_THRESHOLD;
35
37
  /** 滑动比例翻页 */
@@ -1,7 +1,7 @@
1
1
  import { Graphics } from "pixi.js";
2
2
  import gsap from "gsap";
3
- import { LibPixiContainer } from "../Base/LibPixiContainer";
4
3
  import { libPixiEvent } from "../../Utils/LibPixiEvent";
4
+ import { LibPixiContainer } from "../Base/LibPixiContainer";
5
5
  /** @description 滑动页
6
6
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiSlide-滑动页
7
7
  */
@@ -37,6 +37,7 @@ export class LibPixiSlide extends LibPixiContainer {
37
37
  this._startTime = new Date().getTime();
38
38
  /** 是否正在拖动 */
39
39
  this._isDragging = false;
40
+ this._stage = stage;
40
41
  const mask = new Graphics();
41
42
  mask.beginFill(0xffffff);
42
43
  mask.drawRect(0, 0, this.width, this.height);
@@ -67,7 +68,7 @@ export class LibPixiSlide extends LibPixiContainer {
67
68
  this._setDepth();
68
69
  libPixiEvent(this, "pointerdown", this._onDragStart.bind(this));
69
70
  libPixiEvent(stage, "pointermove", this._onDragMove.bind(this));
70
- window.addEventListener("pointerup", this._onDragEnd.bind(this));
71
+ libPixiEvent(stage, "pointerup", this._onDragEnd.bind(this));
71
72
  }
72
73
  /** @description 更新坐标 */
73
74
  updatePosition(v, index) {
@@ -180,15 +181,16 @@ export class LibPixiSlide extends LibPixiContainer {
180
181
  }
181
182
  /** @description 开始拖动 */
182
183
  _onDragStart(event) {
184
+ const { x, y } = this._stage.toLocal(event.global);
183
185
  this._isDragging = true;
184
186
  gsap.killTweensOf(this._slideArea);
185
187
  this._startTime = new Date().getTime();
186
188
  if (this._direction === "x") {
187
- this._startX = event.global.x;
189
+ this._startX = x;
188
190
  this._offsetX = this._slideArea.x;
189
191
  }
190
192
  else {
191
- this._startY = event.global.y;
193
+ this._startY = y;
192
194
  this._offsetY = this._slideArea.y;
193
195
  }
194
196
  }
@@ -196,12 +198,13 @@ export class LibPixiSlide extends LibPixiContainer {
196
198
  _onDragMove(event) {
197
199
  if (!this._isDragging)
198
200
  return;
201
+ const { x, y } = this._stage.toLocal(event.global);
199
202
  if (this._direction === "x") {
200
- const moveX = event.pageX - this._startX;
203
+ const moveX = x - this._startX;
201
204
  this._slideArea.x = this._offsetX + moveX;
202
205
  }
203
206
  else {
204
- const moveY = event.pageY - this._startY;
207
+ const moveY = y - this._startY;
205
208
  this._slideArea.y = this._offsetY + moveY;
206
209
  }
207
210
  this._onScroll();
@@ -219,6 +222,7 @@ export class LibPixiSlide extends LibPixiContainer {
219
222
  }
220
223
  /** @description 结束拖动 */
221
224
  _onDragEnd(event) {
225
+ const { x, y } = this._stage.toLocal(event.global);
222
226
  if (this._direction === "x") {
223
227
  if (!this._isDragging)
224
228
  return;
@@ -226,7 +230,7 @@ export class LibPixiSlide extends LibPixiContainer {
226
230
  //滑动耗时
227
231
  const slideTime = new Date().getTime() - this._startTime;
228
232
  //滑动距离
229
- const slide = this._startX - event.pageX;
233
+ const slide = this._startX - x;
230
234
  //滑动速度
231
235
  const slideSpeed = Math.abs(slide) / slideTime;
232
236
  //要滑动的页数
@@ -255,7 +259,7 @@ export class LibPixiSlide extends LibPixiContainer {
255
259
  //滑动耗时
256
260
  const slideTime = new Date().getTime() - this._startTime;
257
261
  //滑动距离
258
- const slide = this._startY - event.pageY;
262
+ const slide = this._startY - y;
259
263
  //滑动速度
260
264
  const slideSpeed = Math.abs(slide) / slideTime;
261
265
  //要滑动的页数
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) {
@@ -1340,25 +1340,25 @@
1340
1340
  return !toStringTag || !(typeof obj === "object" && (toStringTag in obj || typeof obj[toStringTag] !== "undefined"));
1341
1341
  }
1342
1342
  function isArray$3(obj) {
1343
- return toStr$1(obj) === "[object Array]" && canTrustToString(obj);
1343
+ return toStr(obj) === "[object Array]" && canTrustToString(obj);
1344
1344
  }
1345
1345
  function isDate(obj) {
1346
- return toStr$1(obj) === "[object Date]" && canTrustToString(obj);
1346
+ return toStr(obj) === "[object Date]" && canTrustToString(obj);
1347
1347
  }
1348
1348
  function isRegExp$1(obj) {
1349
- return toStr$1(obj) === "[object RegExp]" && canTrustToString(obj);
1349
+ return toStr(obj) === "[object RegExp]" && canTrustToString(obj);
1350
1350
  }
1351
1351
  function isError(obj) {
1352
- return toStr$1(obj) === "[object Error]" && canTrustToString(obj);
1352
+ return toStr(obj) === "[object Error]" && canTrustToString(obj);
1353
1353
  }
1354
1354
  function isString(obj) {
1355
- return toStr$1(obj) === "[object String]" && canTrustToString(obj);
1355
+ return toStr(obj) === "[object String]" && canTrustToString(obj);
1356
1356
  }
1357
1357
  function isNumber(obj) {
1358
- return toStr$1(obj) === "[object Number]" && canTrustToString(obj);
1358
+ return toStr(obj) === "[object Number]" && canTrustToString(obj);
1359
1359
  }
1360
1360
  function isBoolean(obj) {
1361
- return toStr$1(obj) === "[object Boolean]" && canTrustToString(obj);
1361
+ return toStr(obj) === "[object Boolean]" && canTrustToString(obj);
1362
1362
  }
1363
1363
  function isSymbol(obj) {
1364
1364
  if (hasShammedSymbols) {
@@ -1394,7 +1394,7 @@
1394
1394
  function has$3(obj, key) {
1395
1395
  return hasOwn$1.call(obj, key);
1396
1396
  }
1397
- function toStr$1(obj) {
1397
+ function toStr(obj) {
1398
1398
  return objectToString.call(obj);
1399
1399
  }
1400
1400
  function nameOf(f2) {
@@ -1703,7 +1703,7 @@
1703
1703
  var uri = URIError;
1704
1704
  var abs$2 = Math.abs;
1705
1705
  var floor$2 = Math.floor;
1706
- var max$3 = Math.max;
1706
+ var max$2 = Math.max;
1707
1707
  var min$2 = Math.min;
1708
1708
  var pow$2 = Math.pow;
1709
1709
  var round$3 = Math.round;
@@ -1836,78 +1836,102 @@
1836
1836
  Object_getPrototypeOf = $Object2.getPrototypeOf || null;
1837
1837
  return Object_getPrototypeOf;
1838
1838
  }
1839
- var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
1840
- var toStr = Object.prototype.toString;
1841
- var max$2 = Math.max;
1842
- var funcType = "[object Function]";
1843
- var concatty = function concatty2(a2, b2) {
1844
- var arr = [];
1845
- for (var i2 = 0; i2 < a2.length; i2 += 1) {
1846
- arr[i2] = a2[i2];
1847
- }
1848
- for (var j2 = 0; j2 < b2.length; j2 += 1) {
1849
- arr[j2 + a2.length] = b2[j2];
1850
- }
1851
- return arr;
1852
- };
1853
- var slicy = function slicy2(arrLike, offset) {
1854
- var arr = [];
1855
- for (var i2 = offset || 0, j2 = 0; i2 < arrLike.length; i2 += 1, j2 += 1) {
1856
- arr[j2] = arrLike[i2];
1857
- }
1858
- return arr;
1859
- };
1860
- var joiny = function(arr, joiner) {
1861
- var str = "";
1862
- for (var i2 = 0; i2 < arr.length; i2 += 1) {
1863
- str += arr[i2];
1864
- if (i2 + 1 < arr.length) {
1865
- str += joiner;
1839
+ var implementation;
1840
+ var hasRequiredImplementation;
1841
+ function requireImplementation() {
1842
+ if (hasRequiredImplementation)
1843
+ return implementation;
1844
+ hasRequiredImplementation = 1;
1845
+ var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
1846
+ var toStr2 = Object.prototype.toString;
1847
+ var max2 = Math.max;
1848
+ var funcType = "[object Function]";
1849
+ var concatty = function concatty2(a2, b2) {
1850
+ var arr = [];
1851
+ for (var i2 = 0; i2 < a2.length; i2 += 1) {
1852
+ arr[i2] = a2[i2];
1866
1853
  }
1867
- }
1868
- return str;
1869
- };
1870
- var implementation$1 = function bind2(that) {
1871
- var target = this;
1872
- if (typeof target !== "function" || toStr.apply(target) !== funcType) {
1873
- throw new TypeError(ERROR_MESSAGE + target);
1874
- }
1875
- var args = slicy(arguments, 1);
1876
- var bound;
1877
- var binder = function() {
1878
- if (this instanceof bound) {
1879
- var result = target.apply(
1880
- this,
1881
- concatty(args, arguments)
1882
- );
1883
- if (Object(result) === result) {
1884
- return result;
1854
+ for (var j2 = 0; j2 < b2.length; j2 += 1) {
1855
+ arr[j2 + a2.length] = b2[j2];
1856
+ }
1857
+ return arr;
1858
+ };
1859
+ var slicy = function slicy2(arrLike, offset) {
1860
+ var arr = [];
1861
+ for (var i2 = offset || 0, j2 = 0; i2 < arrLike.length; i2 += 1, j2 += 1) {
1862
+ arr[j2] = arrLike[i2];
1863
+ }
1864
+ return arr;
1865
+ };
1866
+ var joiny = function(arr, joiner) {
1867
+ var str = "";
1868
+ for (var i2 = 0; i2 < arr.length; i2 += 1) {
1869
+ str += arr[i2];
1870
+ if (i2 + 1 < arr.length) {
1871
+ str += joiner;
1885
1872
  }
1886
- return this;
1887
1873
  }
1888
- return target.apply(
1889
- that,
1890
- concatty(args, arguments)
1891
- );
1874
+ return str;
1892
1875
  };
1893
- var boundLength = max$2(0, target.length - args.length);
1894
- var boundArgs = [];
1895
- for (var i2 = 0; i2 < boundLength; i2++) {
1896
- boundArgs[i2] = "$" + i2;
1897
- }
1898
- bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
1899
- if (target.prototype) {
1900
- var Empty = function Empty2() {
1876
+ implementation = function bind2(that) {
1877
+ var target = this;
1878
+ if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
1879
+ throw new TypeError(ERROR_MESSAGE + target);
1880
+ }
1881
+ var args = slicy(arguments, 1);
1882
+ var bound;
1883
+ var binder = function() {
1884
+ if (this instanceof bound) {
1885
+ var result = target.apply(
1886
+ this,
1887
+ concatty(args, arguments)
1888
+ );
1889
+ if (Object(result) === result) {
1890
+ return result;
1891
+ }
1892
+ return this;
1893
+ }
1894
+ return target.apply(
1895
+ that,
1896
+ concatty(args, arguments)
1897
+ );
1901
1898
  };
1902
- Empty.prototype = target.prototype;
1903
- bound.prototype = new Empty();
1904
- Empty.prototype = null;
1905
- }
1906
- return bound;
1907
- };
1908
- var implementation = implementation$1;
1909
- var functionBind = Function.prototype.bind || implementation;
1910
- var functionCall = Function.prototype.call;
1899
+ var boundLength = max2(0, target.length - args.length);
1900
+ var boundArgs = [];
1901
+ for (var i2 = 0; i2 < boundLength; i2++) {
1902
+ boundArgs[i2] = "$" + i2;
1903
+ }
1904
+ bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
1905
+ if (target.prototype) {
1906
+ var Empty = function Empty2() {
1907
+ };
1908
+ Empty.prototype = target.prototype;
1909
+ bound.prototype = new Empty();
1910
+ Empty.prototype = null;
1911
+ }
1912
+ return bound;
1913
+ };
1914
+ return implementation;
1915
+ }
1916
+ var functionBind;
1917
+ var hasRequiredFunctionBind;
1918
+ function requireFunctionBind() {
1919
+ if (hasRequiredFunctionBind)
1920
+ return functionBind;
1921
+ hasRequiredFunctionBind = 1;
1922
+ var implementation2 = requireImplementation();
1923
+ functionBind = Function.prototype.bind || implementation2;
1924
+ return functionBind;
1925
+ }
1926
+ var functionCall;
1927
+ var hasRequiredFunctionCall;
1928
+ function requireFunctionCall() {
1929
+ if (hasRequiredFunctionCall)
1930
+ return functionCall;
1931
+ hasRequiredFunctionCall = 1;
1932
+ functionCall = Function.prototype.call;
1933
+ return functionCall;
1934
+ }
1911
1935
  var functionApply;
1912
1936
  var hasRequiredFunctionApply;
1913
1937
  function requireFunctionApply() {
@@ -1918,14 +1942,14 @@
1918
1942
  return functionApply;
1919
1943
  }
1920
1944
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
1921
- var bind$2 = functionBind;
1945
+ var bind$2 = requireFunctionBind();
1922
1946
  var $apply$1 = requireFunctionApply();
1923
- var $call$2 = functionCall;
1947
+ var $call$2 = requireFunctionCall();
1924
1948
  var $reflectApply = reflectApply;
1925
1949
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
1926
- var bind$1 = functionBind;
1950
+ var bind$1 = requireFunctionBind();
1927
1951
  var $TypeError$4 = type;
1928
- var $call$1 = functionCall;
1952
+ var $call$1 = requireFunctionCall();
1929
1953
  var $actualApply = actualApply;
1930
1954
  var callBindApplyHelpers = function callBindBasic2(args) {
1931
1955
  if (args.length < 1 || typeof args[0] !== "function") {
@@ -1994,7 +2018,7 @@
1994
2018
  hasRequiredHasown = 1;
1995
2019
  var call = Function.prototype.call;
1996
2020
  var $hasOwn = Object.prototype.hasOwnProperty;
1997
- var bind2 = functionBind;
2021
+ var bind2 = requireFunctionBind();
1998
2022
  hasown = bind2.call(call, $hasOwn);
1999
2023
  return hasown;
2000
2024
  }
@@ -2009,7 +2033,7 @@
2009
2033
  var $URIError = uri;
2010
2034
  var abs$1 = abs$2;
2011
2035
  var floor$1 = floor$2;
2012
- var max$1 = max$3;
2036
+ var max$1 = max$2;
2013
2037
  var min$1 = min$2;
2014
2038
  var pow$1 = pow$2;
2015
2039
  var round$2 = round$3;
@@ -2043,7 +2067,7 @@
2043
2067
  var $ObjectGPO = requireObject_getPrototypeOf();
2044
2068
  var $ReflectGPO = requireReflect_getPrototypeOf();
2045
2069
  var $apply = requireFunctionApply();
2046
- var $call = functionCall;
2070
+ var $call = requireFunctionCall();
2047
2071
  var needsEval = {};
2048
2072
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
2049
2073
  var INTRINSICS = {
@@ -2214,7 +2238,7 @@
2214
2238
  "%WeakMapPrototype%": ["WeakMap", "prototype"],
2215
2239
  "%WeakSetPrototype%": ["WeakSet", "prototype"]
2216
2240
  };
2217
- var bind = functionBind;
2241
+ var bind = requireFunctionBind();
2218
2242
  var hasOwn = requireHasown();
2219
2243
  var $concat = bind.call($call, Array.prototype.concat);
2220
2244
  var $spliceApply = bind.call($apply, Array.prototype.splice);
@@ -55196,6 +55220,7 @@ void main(void){
55196
55220
  this._pageNum = 0;
55197
55221
  this._startTime = (/* @__PURE__ */ new Date()).getTime();
55198
55222
  this._isDragging = false;
55223
+ this._stage = stage;
55199
55224
  const mask = new Graphics();
55200
55225
  mask.beginFill(16777215);
55201
55226
  mask.drawRect(0, 0, this.width, this.height);
@@ -55225,7 +55250,7 @@ void main(void){
55225
55250
  this._setDepth();
55226
55251
  libPixiEvent(this, "pointerdown", this._onDragStart.bind(this));
55227
55252
  libPixiEvent(stage, "pointermove", this._onDragMove.bind(this));
55228
- window.addEventListener("pointerup", this._onDragEnd.bind(this));
55253
+ libPixiEvent(stage, "pointerup", this._onDragEnd.bind(this));
55229
55254
  }
55230
55255
  /** @description 更新坐标 */
55231
55256
  updatePosition(v2, index) {
@@ -55319,14 +55344,15 @@ void main(void){
55319
55344
  }
55320
55345
  /** @description 开始拖动 */
55321
55346
  _onDragStart(event) {
55347
+ const { x: x2, y: y2 } = this._stage.toLocal(event.global);
55322
55348
  this._isDragging = true;
55323
55349
  gsapWithCSS.killTweensOf(this._slideArea);
55324
55350
  this._startTime = (/* @__PURE__ */ new Date()).getTime();
55325
55351
  if (this._direction === "x") {
55326
- this._startX = event.global.x;
55352
+ this._startX = x2;
55327
55353
  this._offsetX = this._slideArea.x;
55328
55354
  } else {
55329
- this._startY = event.global.y;
55355
+ this._startY = y2;
55330
55356
  this._offsetY = this._slideArea.y;
55331
55357
  }
55332
55358
  }
@@ -55334,11 +55360,12 @@ void main(void){
55334
55360
  _onDragMove(event) {
55335
55361
  if (!this._isDragging)
55336
55362
  return;
55363
+ const { x: x2, y: y2 } = this._stage.toLocal(event.global);
55337
55364
  if (this._direction === "x") {
55338
- const moveX = event.pageX - this._startX;
55365
+ const moveX = x2 - this._startX;
55339
55366
  this._slideArea.x = this._offsetX + moveX;
55340
55367
  } else {
55341
- const moveY = event.pageY - this._startY;
55368
+ const moveY = y2 - this._startY;
55342
55369
  this._slideArea.y = this._offsetY + moveY;
55343
55370
  }
55344
55371
  this._onScroll();
@@ -55355,12 +55382,13 @@ void main(void){
55355
55382
  }
55356
55383
  /** @description 结束拖动 */
55357
55384
  _onDragEnd(event) {
55385
+ const { x: x2, y: y2 } = this._stage.toLocal(event.global);
55358
55386
  if (this._direction === "x") {
55359
55387
  if (!this._isDragging)
55360
55388
  return;
55361
55389
  this._isDragging = false;
55362
55390
  const slideTime = (/* @__PURE__ */ new Date()).getTime() - this._startTime;
55363
- const slide = this._startX - event.pageX;
55391
+ const slide = this._startX - x2;
55364
55392
  const slideSpeed = Math.abs(slide) / slideTime;
55365
55393
  const pageChange = Math.round(slide / this._pageWidth);
55366
55394
  if (Math.abs(slide) > this._pageWidth * this._SCROLL_THRESHOLD) {
@@ -55380,7 +55408,7 @@ void main(void){
55380
55408
  return;
55381
55409
  this._isDragging = false;
55382
55410
  const slideTime = (/* @__PURE__ */ new Date()).getTime() - this._startTime;
55383
- const slide = this._startY - event.pageY;
55411
+ const slide = this._startY - y2;
55384
55412
  const slideSpeed = Math.abs(slide) / slideTime;
55385
55413
  const pageChange = Math.round(slide / this._pageHeight);
55386
55414
  if (Math.abs(slide) > this._pageHeight * this._SCROLL_THRESHOLD) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyb-pixi-js",
3
- "version": "1.11.2",
3
+ "version": "1.11.4",
4
4
  "description": "自用Pixi.JS方法库",
5
5
  "license": "ISC",
6
6
  "exports": {
@@ -22,5 +22,24 @@
22
22
  "lengyibai",
23
23
  "lyb",
24
24
  "lyb-pixi-js"
25
- ]
25
+ ],
26
+ "devDependencies": {
27
+ "@types/howler": "^2.2.12",
28
+ "@types/node": "^22.10.5",
29
+ "typescript": "^5.7.3"
30
+ },
31
+ "dependencies": {
32
+ "@pixi-spine/runtime-3.8": "^4.0.3",
33
+ "@pixi/filter-drop-shadow": "^5.2.0",
34
+ "@pixi/particle-emitter": "^5.0.8",
35
+ "@pixi/sound": "^5.2.3",
36
+ "dayjs": "^1.11.13",
37
+ "decimal.js": "^10.4.3",
38
+ "gsap": "^3.12.5",
39
+ "howler": "^2.2.4",
40
+ "lyb-js": "^1.6.4",
41
+ "pixi-spine": "^4.0.4",
42
+ "pixi.js": "^7.4.2",
43
+ "vite": "^4.5.5"
44
+ }
26
45
  }