lyb-pixi-js 1.12.4 → 1.12.6
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.
- package/README.md +4 -0
- package/Utils/LibPixiEvent.js +5 -2
- package/Utils/LibPixiGridLayoutV2.d.ts +25 -0
- package/Utils/LibPixiGridLayoutV2.js +30 -0
- package/libPixiJs.d.ts +3 -0
- package/libPixiJs.js +3 -0
- package/lyb-pixi.js +148 -87
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1229,6 +1229,10 @@ LibPixiDownScaleAnimation(sprite);
|
|
|
1229
1229
|
LibPixiGridLayout(cardList, 20, 3); //间隔20,一行三个
|
|
1230
1230
|
```
|
|
1231
1231
|
|
|
1232
|
+
### LibPixiGridLayoutV2-网格布局V2
|
|
1233
|
+
|
|
1234
|
+
> 省略自己创建数组对组件进行 `push` ,内部做了 `push` 处理
|
|
1235
|
+
|
|
1232
1236
|
### LibPixiArrangeLinear-间隔布局
|
|
1233
1237
|
|
|
1234
1238
|
> 按照指定方向(水平或垂直)排列元素,支持固定间隔或自定义每个间隔
|
package/Utils/LibPixiEvent.js
CHANGED
|
@@ -21,7 +21,7 @@ const debounceImmediate = (func, wait) => {
|
|
|
21
21
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiEvent-事件注册
|
|
22
22
|
*/
|
|
23
23
|
export const libPixiEvent = (v, eventName, callback, params = {}) => {
|
|
24
|
-
const { once = false, debounce = false, debounceTime = 1000, preventDragClick = false } = params;
|
|
24
|
+
const { once = false, debounce = false, debounceTime = 1000, preventDragClick = false, } = params;
|
|
25
25
|
v.cursor = "pointer";
|
|
26
26
|
v.eventMode = "static";
|
|
27
27
|
let lastX = 0;
|
|
@@ -32,8 +32,11 @@ export const libPixiEvent = (v, eventName, callback, params = {}) => {
|
|
|
32
32
|
isDragging = false;
|
|
33
33
|
lastX = e.globalX;
|
|
34
34
|
lastY = e.globalY;
|
|
35
|
+
const threshold = 10; // 阈值像素
|
|
35
36
|
const moveHandler = (ev) => {
|
|
36
|
-
|
|
37
|
+
const dx = ev.globalX - lastX;
|
|
38
|
+
const dy = ev.globalY - lastY;
|
|
39
|
+
if (dx * dx + dy * dy > threshold * threshold) {
|
|
37
40
|
isDragging = true;
|
|
38
41
|
}
|
|
39
42
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface GridLayoutParams {
|
|
2
|
+
/** 列数 */
|
|
3
|
+
colNum?: number;
|
|
4
|
+
/** 列间隔 */
|
|
5
|
+
colGap?: number;
|
|
6
|
+
/** 行间隔 */
|
|
7
|
+
rowGap?: number;
|
|
8
|
+
/** 元素列表 */
|
|
9
|
+
elementList?: any[];
|
|
10
|
+
}
|
|
11
|
+
import { Container } from "pixi.js";
|
|
12
|
+
/** @description 网格布局 */
|
|
13
|
+
export declare class LibPixiGridLayoutV2<T extends Container> extends Container {
|
|
14
|
+
/** 参数 */
|
|
15
|
+
private _params;
|
|
16
|
+
/** 元素列表 */
|
|
17
|
+
private _elementList;
|
|
18
|
+
constructor(params?: GridLayoutParams);
|
|
19
|
+
/** @description 追加元素 */
|
|
20
|
+
push(element: T): void;
|
|
21
|
+
/** @description 布局 */
|
|
22
|
+
layout(): void;
|
|
23
|
+
/** @description 获取列表元素 */
|
|
24
|
+
getList(): T[];
|
|
25
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
/** @description 网格布局 */
|
|
3
|
+
export class LibPixiGridLayoutV2 extends Container {
|
|
4
|
+
constructor(params) {
|
|
5
|
+
super();
|
|
6
|
+
/** 元素列表 */
|
|
7
|
+
this._elementList = [];
|
|
8
|
+
this._params = params || {};
|
|
9
|
+
this._elementList = this._params.elementList || [];
|
|
10
|
+
}
|
|
11
|
+
/** @description 追加元素 */
|
|
12
|
+
push(element) {
|
|
13
|
+
this.addChild(element);
|
|
14
|
+
this._elementList.push(element);
|
|
15
|
+
}
|
|
16
|
+
/** @description 布局 */
|
|
17
|
+
layout() {
|
|
18
|
+
const { colNum = 3, colGap = 325, rowGap = 75 } = this._params;
|
|
19
|
+
this._elementList.forEach((item, index) => {
|
|
20
|
+
const col = index % colNum;
|
|
21
|
+
const row = Math.floor(index / colNum);
|
|
22
|
+
item.x = col * colGap;
|
|
23
|
+
item.y = row * rowGap;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** @description 获取列表元素 */
|
|
27
|
+
getList() {
|
|
28
|
+
return this._elementList;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/libPixiJs.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ import { LibPixiOval } from "./Components/Base/LibPixiOval";
|
|
|
33
33
|
import { LibPixiRound } from "./Components/Base/LibPixiRound";
|
|
34
34
|
import { LibPixiRoundedRect } from "./Components/Base/LibPixiRoundedRect";
|
|
35
35
|
import { LibPixiInput } from "./Components/Custom/LibPixiInput";
|
|
36
|
+
import { LibPixiGridLayoutV2 } from "./Utils/LibPixiGridLayoutV2";
|
|
36
37
|
/** @description 组件 */
|
|
37
38
|
export declare const Components: {
|
|
38
39
|
Base: {
|
|
@@ -267,6 +268,8 @@ export declare const Utils: {
|
|
|
267
268
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiGridLayout-网格布局
|
|
268
269
|
*/
|
|
269
270
|
LibPixiGridLayout: (items: import("pixi.js").Container[], gap: number, cols?: number, direction?: "row" | "col") => void;
|
|
271
|
+
/** @description 网格布局V2 */
|
|
272
|
+
LibPixiGridLayoutV2: typeof LibPixiGridLayoutV2;
|
|
270
273
|
/**
|
|
271
274
|
* @description 按照指定方向(水平或垂直)排列元素,支持固定间隔或自定义每个间隔。
|
|
272
275
|
* @param items 要排列的元素数组。
|
package/libPixiJs.js
CHANGED
|
@@ -52,6 +52,7 @@ import { LibPixiOval } from "./Components/Base/LibPixiOval";
|
|
|
52
52
|
import { LibPixiRound } from "./Components/Base/LibPixiRound";
|
|
53
53
|
import { LibPixiRoundedRect } from "./Components/Base/LibPixiRoundedRect";
|
|
54
54
|
import { LibPixiInput } from "./Components/Custom/LibPixiInput";
|
|
55
|
+
import { LibPixiGridLayoutV2 } from "./Utils/LibPixiGridLayoutV2";
|
|
55
56
|
/** @description 组件 */
|
|
56
57
|
export const Components = {
|
|
57
58
|
Base: {
|
|
@@ -286,6 +287,8 @@ export const Utils = {
|
|
|
286
287
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiGridLayout-网格布局
|
|
287
288
|
*/
|
|
288
289
|
LibPixiGridLayout,
|
|
290
|
+
/** @description 网格布局V2 */
|
|
291
|
+
LibPixiGridLayoutV2,
|
|
289
292
|
/**
|
|
290
293
|
* @description 按照指定方向(水平或垂直)排列元素,支持固定间隔或自定义每个间隔。
|
|
291
294
|
* @param items 要排列的元素数组。
|
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
|
|
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, """);
|
|
1338
1338
|
}
|
|
1339
1339
|
function isArray$3(obj) {
|
|
1340
|
-
return toStr
|
|
1340
|
+
return toStr(obj) === "[object Array]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1341
1341
|
}
|
|
1342
1342
|
function isDate(obj) {
|
|
1343
|
-
return toStr
|
|
1343
|
+
return toStr(obj) === "[object Date]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1344
1344
|
}
|
|
1345
1345
|
function isRegExp$1(obj) {
|
|
1346
|
-
return toStr
|
|
1346
|
+
return toStr(obj) === "[object RegExp]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1347
1347
|
}
|
|
1348
1348
|
function isError(obj) {
|
|
1349
|
-
return toStr
|
|
1349
|
+
return toStr(obj) === "[object Error]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1350
1350
|
}
|
|
1351
1351
|
function isString(obj) {
|
|
1352
|
-
return toStr
|
|
1352
|
+
return toStr(obj) === "[object String]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1353
1353
|
}
|
|
1354
1354
|
function isNumber(obj) {
|
|
1355
|
-
return toStr
|
|
1355
|
+
return toStr(obj) === "[object Number]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1356
1356
|
}
|
|
1357
1357
|
function isBoolean(obj) {
|
|
1358
|
-
return toStr
|
|
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
|
|
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$
|
|
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
|
|
1837
|
-
var
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
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
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
if (
|
|
1881
|
-
|
|
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
|
|
1886
|
-
that,
|
|
1887
|
-
concatty(args, arguments)
|
|
1888
|
-
);
|
|
1871
|
+
return str;
|
|
1889
1872
|
};
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
var
|
|
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
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
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 =
|
|
1942
|
+
var bind$2 = requireFunctionBind();
|
|
1919
1943
|
var $apply$1 = requireFunctionApply();
|
|
1920
|
-
var $call$2 =
|
|
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 =
|
|
1947
|
+
var bind$1 = requireFunctionBind();
|
|
1924
1948
|
var $TypeError$4 = type;
|
|
1925
|
-
var $call$1 =
|
|
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 =
|
|
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$
|
|
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 =
|
|
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 =
|
|
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);
|
|
@@ -48776,7 +48800,12 @@ void main(void)\r
|
|
|
48776
48800
|
};
|
|
48777
48801
|
};
|
|
48778
48802
|
const libPixiEvent = (v2, eventName, callback, params = {}) => {
|
|
48779
|
-
const {
|
|
48803
|
+
const {
|
|
48804
|
+
once = false,
|
|
48805
|
+
debounce = false,
|
|
48806
|
+
debounceTime = 1e3,
|
|
48807
|
+
preventDragClick = false
|
|
48808
|
+
} = params;
|
|
48780
48809
|
v2.cursor = "pointer";
|
|
48781
48810
|
v2.eventMode = "static";
|
|
48782
48811
|
let lastX = 0;
|
|
@@ -48787,8 +48816,11 @@ void main(void)\r
|
|
|
48787
48816
|
isDragging = false;
|
|
48788
48817
|
lastX = e2.globalX;
|
|
48789
48818
|
lastY = e2.globalY;
|
|
48819
|
+
const threshold = 10;
|
|
48790
48820
|
const moveHandler = (ev) => {
|
|
48791
|
-
|
|
48821
|
+
const dx = ev.globalX - lastX;
|
|
48822
|
+
const dy = ev.globalY - lastY;
|
|
48823
|
+
if (dx * dx + dy * dy > threshold * threshold) {
|
|
48792
48824
|
isDragging = true;
|
|
48793
48825
|
}
|
|
48794
48826
|
};
|
|
@@ -58290,6 +58322,33 @@ void main(void){
|
|
|
58290
58322
|
}
|
|
58291
58323
|
}
|
|
58292
58324
|
}
|
|
58325
|
+
class LibPixiGridLayoutV2 extends Container {
|
|
58326
|
+
constructor(params) {
|
|
58327
|
+
super();
|
|
58328
|
+
this._elementList = [];
|
|
58329
|
+
this._params = params || {};
|
|
58330
|
+
this._elementList = this._params.elementList || [];
|
|
58331
|
+
}
|
|
58332
|
+
/** @description 追加元素 */
|
|
58333
|
+
push(element) {
|
|
58334
|
+
this.addChild(element);
|
|
58335
|
+
this._elementList.push(element);
|
|
58336
|
+
}
|
|
58337
|
+
/** @description 布局 */
|
|
58338
|
+
layout() {
|
|
58339
|
+
const { colNum = 3, colGap = 325, rowGap = 75 } = this._params;
|
|
58340
|
+
this._elementList.forEach((item, index) => {
|
|
58341
|
+
const col = index % colNum;
|
|
58342
|
+
const row = Math.floor(index / colNum);
|
|
58343
|
+
item.x = col * colGap;
|
|
58344
|
+
item.y = row * rowGap;
|
|
58345
|
+
});
|
|
58346
|
+
}
|
|
58347
|
+
/** @description 获取列表元素 */
|
|
58348
|
+
getList() {
|
|
58349
|
+
return this._elementList;
|
|
58350
|
+
}
|
|
58351
|
+
}
|
|
58293
58352
|
const Components = {
|
|
58294
58353
|
Base: {
|
|
58295
58354
|
/** (已废弃)
|
|
@@ -58522,6 +58581,8 @@ void main(void){
|
|
|
58522
58581
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiGridLayout-网格布局
|
|
58523
58582
|
*/
|
|
58524
58583
|
LibPixiGridLayout,
|
|
58584
|
+
/** @description 网格布局V2 */
|
|
58585
|
+
LibPixiGridLayoutV2,
|
|
58525
58586
|
/**
|
|
58526
58587
|
* @description 按照指定方向(水平或垂直)排列元素,支持固定间隔或自定义每个间隔。
|
|
58527
58588
|
* @param items 要排列的元素数组。
|