lyb-pixi-js 1.12.33 → 1.12.34
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/Components/Base/LibPixiArc.d.ts +16 -0
- package/Components/Base/LibPixiArc.js +14 -0
- package/Components/Base/LibPixiBitText.d.ts +20 -0
- package/Components/Base/LibPixiBitText.js +26 -0
- package/Components/Base/LibPixiCircular.d.ts +7 -0
- package/Components/Base/LibPixiCircular.js +12 -0
- package/Components/Base/LibPixiContainer.d.ts +22 -0
- package/Components/Base/LibPixiContainer.js +51 -0
- package/Components/Base/LibPixiHtmlText.d.ts +31 -0
- package/Components/Base/LibPixiHtmlText.js +30 -0
- package/Components/Base/LibPixiOval.d.ts +5 -0
- package/Components/Base/LibPixiOval.js +10 -0
- package/Components/Base/LibPixiParticleMove.d.ts +101 -0
- package/Components/Base/LibPixiParticleMove.js +136 -0
- package/Components/Base/LibPixiPolygon.d.ts +7 -0
- package/Components/Base/LibPixiPolygon.js +15 -0
- package/Components/Base/LibPixiRectBgColor.d.ts +41 -0
- package/Components/Base/LibPixiRectBgColor.js +95 -0
- package/Components/Base/LibPixiRectangle.d.ts +7 -0
- package/Components/Base/LibPixiRectangle.js +15 -0
- package/Components/Base/LibPixiRound.d.ts +5 -0
- package/Components/Base/LibPixiRound.js +9 -0
- package/Components/Base/LibPixiRoundedRect.d.ts +5 -0
- package/Components/Base/LibPixiRoundedRect.js +10 -0
- package/Components/Base/LibPixiSpine.d.ts +58 -0
- package/Components/Base/LibPixiSpine.js +128 -0
- package/Components/Base/LibPixiText.d.ts +37 -0
- package/Components/Base/LibPixiText.js +35 -0
- package/Components/Custom/LibPixiAreaClick.d.ts +6 -0
- package/Components/Custom/LibPixiAreaClick.js +16 -0
- package/Components/Custom/LibPixiArrangeLinearV2.d.ts +25 -0
- package/Components/Custom/LibPixiArrangeLinearV2.js +80 -0
- package/Components/Custom/LibPixiButtonHover.d.ts +40 -0
- package/Components/Custom/LibPixiButtonHover.js +53 -0
- package/Components/Custom/LibPixiCapsule.d.ts +5 -0
- package/Components/Custom/LibPixiCapsule.js +10 -0
- package/Components/Custom/LibPixiCloseBtn.d.ts +14 -0
- package/Components/Custom/LibPixiCloseBtn.js +36 -0
- package/Components/Custom/LibPixiDragLocate.d.ts +36 -0
- package/Components/Custom/LibPixiDragLocate.js +230 -0
- package/Components/Custom/LibPixiDrawer.d.ts +16 -0
- package/Components/Custom/LibPixiDrawer.js +59 -0
- package/Components/Custom/LibPixiGridLayoutV2.d.ts +27 -0
- package/Components/Custom/LibPixiGridLayoutV2.js +37 -0
- package/Components/Custom/LibPixiInput.d.ts +77 -0
- package/Components/Custom/LibPixiInput.js +198 -0
- package/Components/Custom/LibPixiLabelValue.d.ts +30 -0
- package/Components/Custom/LibPixiLabelValue.js +26 -0
- package/Components/Custom/LibPixiPerforMon.d.ts +47 -0
- package/Components/Custom/LibPixiPerforMon.js +166 -0
- package/Components/Custom/LibPixiProgress.d.ts +33 -0
- package/Components/Custom/LibPixiProgress.js +47 -0
- package/Components/Custom/LibPixiPuzzleBg.d.ts +7 -0
- package/Components/Custom/LibPixiPuzzleBg.js +46 -0
- package/Components/Custom/LibPixiScrollContainerX.d.ts +71 -0
- package/Components/Custom/LibPixiScrollContainerX.js +198 -0
- package/Components/Custom/LibPixiScrollContainerY.d.ts +109 -0
- package/Components/Custom/LibPixiScrollContainerY.js +340 -0
- package/Components/Custom/LibPixiScrollNum.d.ts +67 -0
- package/Components/Custom/LibPixiScrollNum.js +184 -0
- package/Components/Custom/LibPixiSlide.d.ts +94 -0
- package/Components/Custom/LibPixiSlide.js +285 -0
- package/Components/Custom/LibPixiSlider.d.ts +82 -0
- package/Components/Custom/LibPixiSlider.js +165 -0
- package/Components/Custom/LibPixiTable.d.ts +64 -0
- package/Components/Custom/LibPixiTable.js +76 -0
- package/Components/Custom/LibPixiTextGroupWrap.d.ts +20 -0
- package/Components/Custom/LibPixiTextGroupWrap.js +50 -0
- package/Components/Custom/LibPixiTriangle.d.ts +5 -0
- package/Components/Custom/LibPixiTriangle.js +12 -0
- package/Components/Custom/LibPixiTurntable.d.ts +6 -0
- package/Components/Custom/LibPixiTurntable.js +14 -0
- package/Utils/LibContainerCenter.d.ts +3 -0
- package/Utils/LibContainerCenter.js +10 -0
- package/Utils/LibControlledDelayedCall.d.ts +5 -0
- package/Utils/LibControlledDelayedCall.js +20 -0
- package/Utils/LibPixiArrangeLinear.d.ts +16 -0
- package/Utils/LibPixiArrangeLinear.js +62 -0
- package/Utils/LibPixiAudio.d.ts +53 -0
- package/Utils/LibPixiAudio.js +168 -0
- package/Utils/LibPixiCreateNineGrid.d.ts +15 -0
- package/Utils/LibPixiCreateNineGrid.js +19 -0
- package/Utils/LibPixiDialogManager/index.d.ts +25 -0
- package/Utils/LibPixiDialogManager/index.js +43 -0
- package/Utils/LibPixiDialogManager/ui/LibPixiBaseContainer.d.ts +11 -0
- package/Utils/LibPixiDialogManager/ui/LibPixiBaseContainer.js +31 -0
- package/Utils/LibPixiDialogManager/ui/LibPixiDialog.d.ts +38 -0
- package/Utils/LibPixiDialogManager/ui/LibPixiDialog.js +133 -0
- package/Utils/LibPixiDigitalIncreasingAnimation.d.ts +18 -0
- package/Utils/LibPixiDigitalIncreasingAnimation.js +26 -0
- package/Utils/LibPixiDownScaleAnimation.d.ts +7 -0
- package/Utils/LibPixiDownScaleAnimation.js +33 -0
- package/Utils/LibPixiEmitContainerEvent.d.ts +7 -0
- package/Utils/LibPixiEmitContainerEvent.js +13 -0
- package/Utils/LibPixiEvent.d.ts +19 -0
- package/Utils/LibPixiEvent.js +68 -0
- package/Utils/LibPixiFilter.d.ts +9 -0
- package/Utils/LibPixiFilter.js +34 -0
- package/Utils/LibPixiGlobalUpdater.d.ts +15 -0
- package/Utils/LibPixiGlobalUpdater.js +21 -0
- package/Utils/LibPixiGridLayout.d.ts +10 -0
- package/Utils/LibPixiGridLayout.js +27 -0
- package/Utils/LibPixiHVCenter.d.ts +7 -0
- package/Utils/LibPixiHVCenter.js +14 -0
- package/Utils/LibPixiHVGap.d.ts +8 -0
- package/Utils/LibPixiHVGap.js +26 -0
- package/Utils/LibPixiIntervalTrigger.d.ts +7 -0
- package/Utils/LibPixiIntervalTrigger.js +35 -0
- package/Utils/LibPixiOutsideClick.d.ts +8 -0
- package/Utils/LibPixiOutsideClick.js +22 -0
- package/Utils/LibPixiOverflowHidden.d.ts +6 -0
- package/Utils/LibPixiOverflowHidden.js +14 -0
- package/Utils/LibPixiPolygonDrawTool.d.ts +44 -0
- package/Utils/LibPixiPolygonDrawTool.js +114 -0
- package/Utils/LibPixiPromiseTickerTimeout.d.ts +6 -0
- package/Utils/LibPixiPromiseTickerTimeout.js +22 -0
- package/Utils/LibPixiScaleContainer.d.ts +8 -0
- package/Utils/LibPixiScaleContainer.js +14 -0
- package/Utils/LibPixiShadow.d.ts +17 -0
- package/Utils/LibPixiShadow.js +18 -0
- package/Utils/LibPixiSlideInput.d.ts +55 -0
- package/Utils/LibPixiSlideInput.js +61 -0
- package/Utils/LibPixiTicker.d.ts +14 -0
- package/Utils/LibPixiTicker.js +49 -0
- package/Utils/LibPixiTickerTimeout.d.ts +6 -0
- package/Utils/LibPixiTickerTimeout.js +22 -0
- package/package.json +1 -2
- package/index.js +0 -5
- package/lyb-pixi.js +0 -58890
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { Container, Ticker } from "pixi.js";
|
|
2
|
+
import gsap from "gsap";
|
|
3
|
+
import { libPixiFilter } from "../../Utils/LibPixiFilter";
|
|
4
|
+
import { libJsCopy } from "lyb-js/Browser/LibJsCopy.js";
|
|
5
|
+
/** @description 元素拖拽定位 */
|
|
6
|
+
export class LibPixiDragLocate extends Container {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
/** 当前坐标值 */
|
|
10
|
+
this._positionValue = "";
|
|
11
|
+
/** 是否处于定位状态 */
|
|
12
|
+
this._isLocalte = false;
|
|
13
|
+
/** 是否显示输入框 */
|
|
14
|
+
this._showInput = false;
|
|
15
|
+
/** 是否允许移动 */
|
|
16
|
+
this._allowMove = false;
|
|
17
|
+
/** 按下坐标 */
|
|
18
|
+
this._downPos = { x: 0, y: 0 };
|
|
19
|
+
window.addEventListener("keydown", (e) => {
|
|
20
|
+
if (e.ctrlKey && e.key.toLowerCase() === "q" && e.shiftKey) {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
if (this._isLocalte)
|
|
23
|
+
return;
|
|
24
|
+
this._showInput = !this._showInput;
|
|
25
|
+
}
|
|
26
|
+
if (e.key === "Escape") {
|
|
27
|
+
this._showInput = false;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
this._createInput();
|
|
31
|
+
this._createResultList();
|
|
32
|
+
this._createStatusBar();
|
|
33
|
+
LibPixiDragLocate.stage.on("pointerdown", (event) => {
|
|
34
|
+
if (!this._currentMoveContainer)
|
|
35
|
+
return;
|
|
36
|
+
this._allowMove = true;
|
|
37
|
+
const { x, y } = LibPixiDragLocate.stage.toLocal(event.global);
|
|
38
|
+
this._downPos = { x, y };
|
|
39
|
+
});
|
|
40
|
+
LibPixiDragLocate.stage.on("pointermove", (event) => {
|
|
41
|
+
if (!this._allowMove || !this._currentMoveContainer)
|
|
42
|
+
return;
|
|
43
|
+
const { x, y } = LibPixiDragLocate.stage.toLocal(event.global);
|
|
44
|
+
const dx = x - this._downPos.x;
|
|
45
|
+
const dy = y - this._downPos.y;
|
|
46
|
+
this._currentMoveContainer.x += dx;
|
|
47
|
+
this._currentMoveContainer.y += dy;
|
|
48
|
+
this._downPos = { x, y };
|
|
49
|
+
const posX = Math.round(this._currentMoveContainer.x);
|
|
50
|
+
const posY = Math.round(this._currentMoveContainer.y);
|
|
51
|
+
this._positionEl.textContent = `X: ${posX}, Y: ${posY}`;
|
|
52
|
+
this._positionValue = `xxx.position.set(${posX}, ${posY})`;
|
|
53
|
+
});
|
|
54
|
+
LibPixiDragLocate.stage.on("pointerup", () => {
|
|
55
|
+
this._allowMove = false;
|
|
56
|
+
}, this);
|
|
57
|
+
Ticker.shared.add(() => {
|
|
58
|
+
if (this._showInput) {
|
|
59
|
+
if (this._isLocalte) {
|
|
60
|
+
this._inputEl.style.display = "none";
|
|
61
|
+
this._resultEl.style.display = "none";
|
|
62
|
+
this._statusBarEl.style.display = "flex";
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this._inputEl.style.display = "block";
|
|
66
|
+
this._resultEl.style.display = "flex";
|
|
67
|
+
this._statusBarEl.style.display = "none";
|
|
68
|
+
this._inputEl.focus();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
this._inputEl.style.display = "none";
|
|
73
|
+
this._resultEl.style.display = "none";
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/** @description 创建输入框 */
|
|
78
|
+
_createInput() {
|
|
79
|
+
this._inputEl = document.createElement("input");
|
|
80
|
+
this._inputEl.type = "text";
|
|
81
|
+
this._inputEl.style.cssText = `
|
|
82
|
+
background-color: rgba(0,0,0,0.75);
|
|
83
|
+
border: 2px solid rgba(255,255,255,0.5);
|
|
84
|
+
color: #fff;
|
|
85
|
+
display: none;
|
|
86
|
+
font-size: 25px;
|
|
87
|
+
height: 50px;
|
|
88
|
+
left: 50%;
|
|
89
|
+
outline: none;
|
|
90
|
+
position: fixed;
|
|
91
|
+
text-align: center;
|
|
92
|
+
top: 25%;
|
|
93
|
+
transform: translate(-50%, -50%);
|
|
94
|
+
width: 50vw;
|
|
95
|
+
`;
|
|
96
|
+
document.body.appendChild(this._inputEl);
|
|
97
|
+
this._inputEl.addEventListener("input", () => {
|
|
98
|
+
const results = this._findByName(LibPixiDragLocate.stage, this._inputEl.value);
|
|
99
|
+
//创建搜索结果列表
|
|
100
|
+
this._resultEl.innerHTML = "";
|
|
101
|
+
const renderNode = (item) => {
|
|
102
|
+
const resultEl = this._createResultEl(item.node.constructor.name, item.node.name, item.depth);
|
|
103
|
+
this._resultEl.appendChild(resultEl);
|
|
104
|
+
gsap.killTweensOf(item.node);
|
|
105
|
+
//悬浮结果列表元素闪烁
|
|
106
|
+
resultEl.addEventListener("mouseenter", () => {
|
|
107
|
+
gsap.to(item.node, {
|
|
108
|
+
alpha: 0,
|
|
109
|
+
duration: 0.25,
|
|
110
|
+
yoyo: true,
|
|
111
|
+
ease: "none",
|
|
112
|
+
repeat: -1,
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
//离开结果后停止闪烁
|
|
116
|
+
resultEl.addEventListener("mouseleave", () => {
|
|
117
|
+
gsap.killTweensOf(item.node);
|
|
118
|
+
item.node.alpha = 1;
|
|
119
|
+
});
|
|
120
|
+
resultEl.addEventListener("click", () => {
|
|
121
|
+
gsap.killTweensOf(item.node);
|
|
122
|
+
this._currentMoveContainer = item.node;
|
|
123
|
+
item.node.alpha = 1;
|
|
124
|
+
item.node.filters = [libPixiFilter("desaturate", 0)];
|
|
125
|
+
this._isLocalte = true;
|
|
126
|
+
});
|
|
127
|
+
item.children.forEach(renderNode);
|
|
128
|
+
};
|
|
129
|
+
results.forEach(renderNode);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/** @description 创建用于展示搜索结果的列表 */
|
|
133
|
+
_createResultList() {
|
|
134
|
+
this._resultEl = document.createElement("div");
|
|
135
|
+
this._resultEl.style.cssText = `
|
|
136
|
+
background-color: rgba(0,0,0,0.75);
|
|
137
|
+
border: 2px solid rgba(255,255,255,0.5);
|
|
138
|
+
left: 50%;
|
|
139
|
+
transform: translateX(-50%);
|
|
140
|
+
height: 300px;
|
|
141
|
+
overflow-y: auto;
|
|
142
|
+
position: fixed;
|
|
143
|
+
display: none;
|
|
144
|
+
gap: 10px;
|
|
145
|
+
flex-direction: column;
|
|
146
|
+
top: calc(25% + 50px);
|
|
147
|
+
width: 50vw;
|
|
148
|
+
`;
|
|
149
|
+
document.body.appendChild(this._resultEl);
|
|
150
|
+
}
|
|
151
|
+
/** @description 创建搜索结果元素 */
|
|
152
|
+
_createResultEl(className, tagName, depth) {
|
|
153
|
+
const resultItem = document.createElement("div");
|
|
154
|
+
resultItem.style.cssText = `
|
|
155
|
+
display: flex;
|
|
156
|
+
justify-content: space-between;
|
|
157
|
+
padding: 5px 10px;
|
|
158
|
+
align-items: center;
|
|
159
|
+
width: 100%;
|
|
160
|
+
font-size: 25px;
|
|
161
|
+
background-color: rgba(255,255,255,0.1);
|
|
162
|
+
color: #fff;
|
|
163
|
+
padding-left: ${depth * 20}px;
|
|
164
|
+
`;
|
|
165
|
+
const classNameEl = document.createElement("div");
|
|
166
|
+
classNameEl.textContent = className;
|
|
167
|
+
resultItem.appendChild(classNameEl);
|
|
168
|
+
const tagNameEl = document.createElement("div");
|
|
169
|
+
tagNameEl.textContent = tagName;
|
|
170
|
+
resultItem.appendChild(tagNameEl);
|
|
171
|
+
return resultItem;
|
|
172
|
+
}
|
|
173
|
+
/** @description 创建状态栏 */
|
|
174
|
+
_createStatusBar() {
|
|
175
|
+
this._statusBarEl = document.createElement("div");
|
|
176
|
+
this._statusBarEl.style.cssText = `
|
|
177
|
+
align-items: center;
|
|
178
|
+
background-color: rgba(0,0,0,0.75);
|
|
179
|
+
border: 2px solid rgba(0, 255, 13, 0.5);
|
|
180
|
+
color: #fff;
|
|
181
|
+
display: none;
|
|
182
|
+
font-size: 25px;
|
|
183
|
+
justify-content: center;
|
|
184
|
+
position: fixed;
|
|
185
|
+
top: 25%;
|
|
186
|
+
height: 50px;
|
|
187
|
+
left: 50%;
|
|
188
|
+
transform: translate(-50%, -50%);
|
|
189
|
+
width: 50vw;
|
|
190
|
+
`;
|
|
191
|
+
this._positionEl = document.createElement("div");
|
|
192
|
+
this._statusBarEl.appendChild(this._positionEl);
|
|
193
|
+
document.body.appendChild(this._statusBarEl);
|
|
194
|
+
this._statusBarEl.addEventListener("click", () => {
|
|
195
|
+
this._isLocalte = false;
|
|
196
|
+
libJsCopy(this._positionValue);
|
|
197
|
+
if (this._currentMoveContainer) {
|
|
198
|
+
this._currentMoveContainer.filters = [];
|
|
199
|
+
this._currentMoveContainer = undefined;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/** @description 递归搜索 */
|
|
204
|
+
_findByName(root, keyword) {
|
|
205
|
+
if (!keyword)
|
|
206
|
+
return [];
|
|
207
|
+
const match = (node) => {
|
|
208
|
+
var _a;
|
|
209
|
+
return ((_a = node.name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(keyword.toLowerCase())) ||
|
|
210
|
+
node.constructor.name.toLowerCase().includes(keyword.toLowerCase());
|
|
211
|
+
};
|
|
212
|
+
const dfs = (node, depth) => {
|
|
213
|
+
const children = node.children
|
|
214
|
+
.filter((c) => c instanceof Container)
|
|
215
|
+
.flatMap((c) => dfs(c, depth + 1));
|
|
216
|
+
if (match(node) || children.length > 0) {
|
|
217
|
+
return [
|
|
218
|
+
{
|
|
219
|
+
node,
|
|
220
|
+
depth,
|
|
221
|
+
children,
|
|
222
|
+
expanded: true,
|
|
223
|
+
},
|
|
224
|
+
];
|
|
225
|
+
}
|
|
226
|
+
return [];
|
|
227
|
+
};
|
|
228
|
+
return dfs(root, 0);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
/** @description 底部弹出抽屉
|
|
3
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiDrawer-抽屉
|
|
4
|
+
*/
|
|
5
|
+
export declare class LibPixiDrawer extends Container {
|
|
6
|
+
/** 蒙版UI */
|
|
7
|
+
private _maskUI;
|
|
8
|
+
/** 抽屉容器 */
|
|
9
|
+
private _drawerContainer;
|
|
10
|
+
/**
|
|
11
|
+
* @param content 抽屉内容
|
|
12
|
+
*/
|
|
13
|
+
constructor(content: Container);
|
|
14
|
+
/** @description 关闭 */
|
|
15
|
+
close(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Container } from "pixi.js";
|
|
11
|
+
import gsap from "gsap";
|
|
12
|
+
import { LibPixiRectBgColor } from '../Base/LibPixiRectBgColor';
|
|
13
|
+
/** @description 底部弹出抽屉
|
|
14
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiDrawer-抽屉
|
|
15
|
+
*/
|
|
16
|
+
export class LibPixiDrawer extends Container {
|
|
17
|
+
/**
|
|
18
|
+
* @param content 抽屉内容
|
|
19
|
+
*/
|
|
20
|
+
constructor(content) {
|
|
21
|
+
super();
|
|
22
|
+
//蒙版
|
|
23
|
+
this._maskUI = new LibPixiRectBgColor({
|
|
24
|
+
bgColor: "#000",
|
|
25
|
+
width: 1080,
|
|
26
|
+
height: 1920,
|
|
27
|
+
});
|
|
28
|
+
this.addChild(this._maskUI);
|
|
29
|
+
this._maskUI.alpha = 0;
|
|
30
|
+
this._maskUI.eventMode = "static";
|
|
31
|
+
//弹窗内容容器
|
|
32
|
+
this._drawerContainer = content;
|
|
33
|
+
this.addChild(this._drawerContainer);
|
|
34
|
+
this._drawerContainer.y = this._maskUI.height;
|
|
35
|
+
gsap.to(this._maskUI, {
|
|
36
|
+
duration: 0.25,
|
|
37
|
+
alpha: 0.5,
|
|
38
|
+
});
|
|
39
|
+
gsap.to(this._drawerContainer, {
|
|
40
|
+
duration: 0.25,
|
|
41
|
+
ease: "power1.out",
|
|
42
|
+
y: this._maskUI.height - this._drawerContainer.height,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/** @description 关闭 */
|
|
46
|
+
close() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
gsap.to(this._drawerContainer, {
|
|
49
|
+
duration: 0.25,
|
|
50
|
+
y: this._maskUI.height,
|
|
51
|
+
});
|
|
52
|
+
yield gsap.to(this._maskUI, {
|
|
53
|
+
duration: 0.25,
|
|
54
|
+
delay: 0.125,
|
|
55
|
+
alpha: 0,
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
/** @description 销毁列表元素 */
|
|
26
|
+
destroyList(): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 = this._elementList.length, 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
|
+
/** @description 销毁列表元素 */
|
|
31
|
+
destroyList() {
|
|
32
|
+
this._elementList.forEach((item) => {
|
|
33
|
+
item.destroy();
|
|
34
|
+
});
|
|
35
|
+
this._elementList = [];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
import { LibPixiContainer } from "../Base/LibPixiContainer";
|
|
3
|
+
interface Params {
|
|
4
|
+
/** 宽度 */
|
|
5
|
+
width: number;
|
|
6
|
+
/** 高度 */
|
|
7
|
+
height: number;
|
|
8
|
+
/** 字体与高度比 */
|
|
9
|
+
fontSizeRatio: number;
|
|
10
|
+
/** 使用字体 */
|
|
11
|
+
fontFamily?: string;
|
|
12
|
+
/** 是否加粗 */
|
|
13
|
+
bold?: boolean;
|
|
14
|
+
/** 是否需要placeholder */
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
/** placeholder颜色 */
|
|
17
|
+
placeholderColor?: string;
|
|
18
|
+
/** 背景色,用于调试输入框的位置 */
|
|
19
|
+
bgColor?: string;
|
|
20
|
+
/** 输入类型 */
|
|
21
|
+
type?: "number" | "text" | "password";
|
|
22
|
+
/** 字体颜色 */
|
|
23
|
+
color?: string;
|
|
24
|
+
/** 初始值 */
|
|
25
|
+
value?: string;
|
|
26
|
+
/** 是否整数 */
|
|
27
|
+
integer?: boolean;
|
|
28
|
+
/** 是否允许输入负数 */
|
|
29
|
+
isNegative?: boolean;
|
|
30
|
+
/** 最小值 */
|
|
31
|
+
min?: number;
|
|
32
|
+
/** 最大值 */
|
|
33
|
+
max?: number;
|
|
34
|
+
/** 最大长度 */
|
|
35
|
+
maxLength?: number;
|
|
36
|
+
/** 对齐方式 */
|
|
37
|
+
align?: "left" | "center";
|
|
38
|
+
/** 输入回调 */
|
|
39
|
+
onInput?: (text: number | string) => void;
|
|
40
|
+
/** 失去焦点回调 */
|
|
41
|
+
onValue?: (text: number | string) => void;
|
|
42
|
+
/** 格式化显示值 */
|
|
43
|
+
onFormatValue?: (text: number | string) => string;
|
|
44
|
+
}
|
|
45
|
+
/** @description 动态缩放移动输入框 */
|
|
46
|
+
export declare class LibPixiInput extends LibPixiContainer {
|
|
47
|
+
/** 舞台 */
|
|
48
|
+
static stage: Container;
|
|
49
|
+
/** 参数 */
|
|
50
|
+
private _params;
|
|
51
|
+
/** 只读输入框 */
|
|
52
|
+
private _readonlyInput;
|
|
53
|
+
/** placeholder */
|
|
54
|
+
private _placeholder;
|
|
55
|
+
/** 输入框dom */
|
|
56
|
+
private _input;
|
|
57
|
+
/** 当前输入的值 */
|
|
58
|
+
private _value;
|
|
59
|
+
constructor(params: Params);
|
|
60
|
+
/** @description 设置值 */
|
|
61
|
+
setValue(v: string): void;
|
|
62
|
+
/** @description 创建输入框 */
|
|
63
|
+
private _createInput;
|
|
64
|
+
/** @description 创建只读输入框 */
|
|
65
|
+
private _createReadOnlyInput;
|
|
66
|
+
/** @description 聚焦 */
|
|
67
|
+
private _focus;
|
|
68
|
+
/** @description 失焦 */
|
|
69
|
+
private _blur;
|
|
70
|
+
/** @description 失去焦点处理 */
|
|
71
|
+
private _onBlurHandler;
|
|
72
|
+
/** @description 实时更新输入框位置 */
|
|
73
|
+
private _updateInputPosition;
|
|
74
|
+
/** @description 设置输入框类型 */
|
|
75
|
+
toggleType(type: "text" | "password"): void;
|
|
76
|
+
}
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { Ticker } from "pixi.js";
|
|
2
|
+
import Decimal from "decimal.js";
|
|
3
|
+
import { libPixiEvent } from "../../Utils/LibPixiEvent";
|
|
4
|
+
import { libPixiScaleContainer } from "../../Utils/LibPixiScaleContainer";
|
|
5
|
+
import { LibPixiContainer } from "../Base/LibPixiContainer";
|
|
6
|
+
import { LibPixiText } from "../Base/LibPixiText";
|
|
7
|
+
/** @description 动态缩放移动输入框 */
|
|
8
|
+
export class LibPixiInput extends LibPixiContainer {
|
|
9
|
+
constructor(params) {
|
|
10
|
+
const { width, height, bgColor, value = "" } = params;
|
|
11
|
+
super(width, height, bgColor);
|
|
12
|
+
/** 当前输入的值 */
|
|
13
|
+
this._value = "";
|
|
14
|
+
/** @description 失去焦点处理 */
|
|
15
|
+
this._onBlurHandler = () => {
|
|
16
|
+
const { type = "text", integer = false, min = 1, max = Infinity, } = this._params;
|
|
17
|
+
let text = this._input.value.trim();
|
|
18
|
+
//如果类型为字符串,则不参与校验
|
|
19
|
+
if (["text", "password"].includes(type))
|
|
20
|
+
return text;
|
|
21
|
+
//如果为空,则使用最小值
|
|
22
|
+
if (this._input.value === "")
|
|
23
|
+
text = min.toString();
|
|
24
|
+
//如果不能为负数,输入值小于最小值,则使用最小值
|
|
25
|
+
if (Number(text) < min)
|
|
26
|
+
text = min.toString();
|
|
27
|
+
//如果存在最大值,且输入值大于最大值,则使用最大值
|
|
28
|
+
if (max && Number(text) > max)
|
|
29
|
+
text = max.toString();
|
|
30
|
+
//如果要求整数,则取整
|
|
31
|
+
if (integer)
|
|
32
|
+
text = parseInt(text).toString();
|
|
33
|
+
//保留两位小数且不四舍五入
|
|
34
|
+
const value = new Decimal(Number(text));
|
|
35
|
+
text = value.toFixed(2, Decimal.ROUND_DOWN);
|
|
36
|
+
return text;
|
|
37
|
+
};
|
|
38
|
+
this.cursor = "text";
|
|
39
|
+
this._params = params;
|
|
40
|
+
this._value = value;
|
|
41
|
+
this._createInput();
|
|
42
|
+
this._createReadOnlyInput();
|
|
43
|
+
//聚焦
|
|
44
|
+
libPixiEvent(this, "pointertap", this._focus.bind(this));
|
|
45
|
+
const ticker = new Ticker();
|
|
46
|
+
ticker.add(() => {
|
|
47
|
+
if (this.destroyed) {
|
|
48
|
+
ticker.stop();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this._updateInputPosition();
|
|
52
|
+
});
|
|
53
|
+
ticker.start();
|
|
54
|
+
}
|
|
55
|
+
/** @description 设置值 */
|
|
56
|
+
setValue(v) {
|
|
57
|
+
const { onFormatValue, type = "text" } = this._params;
|
|
58
|
+
const value = v;
|
|
59
|
+
this._value = value;
|
|
60
|
+
if (type === "password") {
|
|
61
|
+
this._readonlyInput.text =
|
|
62
|
+
(onFormatValue === null || onFormatValue === void 0 ? void 0 : onFormatValue(value)) || "●".repeat(value.length);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this._readonlyInput.text = (onFormatValue === null || onFormatValue === void 0 ? void 0 : onFormatValue(value)) || value;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** @description 创建输入框 */
|
|
69
|
+
_createInput() {
|
|
70
|
+
const { color = "#fff", maxLength = 999999, align = "left", type = "text", onInput = () => { }, fontFamily = "", bold = false, } = this._params;
|
|
71
|
+
this._input = document.createElement("input");
|
|
72
|
+
this._input.type = type;
|
|
73
|
+
this._input.maxLength = maxLength;
|
|
74
|
+
this._input.style.cssText = `
|
|
75
|
+
position: absolute;
|
|
76
|
+
border: none;
|
|
77
|
+
outline: none;
|
|
78
|
+
display: none;
|
|
79
|
+
background-color: transparent;
|
|
80
|
+
color: ${color};
|
|
81
|
+
text-align: ${align};
|
|
82
|
+
font-family: ${fontFamily};
|
|
83
|
+
font-weight: ${bold ? "bold" : "normal"}
|
|
84
|
+
`;
|
|
85
|
+
document.querySelector("#game").appendChild(this._input);
|
|
86
|
+
this._input.addEventListener("input", function () {
|
|
87
|
+
if (this.value.length > maxLength && type === "number") {
|
|
88
|
+
this.value = this.value.slice(0, maxLength);
|
|
89
|
+
}
|
|
90
|
+
onInput(this.value.trim());
|
|
91
|
+
});
|
|
92
|
+
this._input.addEventListener("paste", function (e) {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
const paste = (_b = (_a = e.clipboardData) === null || _a === void 0 ? void 0 : _a.getData("text")) !== null && _b !== void 0 ? _b : "";
|
|
95
|
+
if (paste.length > maxLength) {
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
this.value = paste.slice(0, maxLength);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
this._input.addEventListener("blur", this._blur.bind(this));
|
|
101
|
+
}
|
|
102
|
+
/** @description 创建只读输入框 */
|
|
103
|
+
_createReadOnlyInput() {
|
|
104
|
+
const { color = "#fff", value = "", width, height, fontSizeRatio = 0.5, align = "left", placeholder = "", placeholderColor, fontFamily = "", bold = false, } = this._params;
|
|
105
|
+
//创建描述
|
|
106
|
+
this._placeholder = new LibPixiText({
|
|
107
|
+
text: placeholder,
|
|
108
|
+
fontColor: placeholderColor,
|
|
109
|
+
fontSize: height * fontSizeRatio,
|
|
110
|
+
fontFamily,
|
|
111
|
+
fontWeight: bold ? "bold" : "normal",
|
|
112
|
+
});
|
|
113
|
+
this.addChild(this._placeholder);
|
|
114
|
+
this._placeholder.visible = !value;
|
|
115
|
+
this._placeholder.anchor.set(align === "left" ? 0 : 0.5, 0.5);
|
|
116
|
+
this._placeholder.position.set(align === "left" ? 0 : width / 2, height / 2);
|
|
117
|
+
//创建实际显示的文本
|
|
118
|
+
this._readonlyInput = new LibPixiText({
|
|
119
|
+
text: value,
|
|
120
|
+
fontColor: color,
|
|
121
|
+
fontSize: height * fontSizeRatio,
|
|
122
|
+
fontFamily,
|
|
123
|
+
fontWeight: bold ? "bold" : "normal",
|
|
124
|
+
});
|
|
125
|
+
this.addChild(this._readonlyInput);
|
|
126
|
+
this._readonlyInput.visible = !!value;
|
|
127
|
+
this._readonlyInput.anchor.set(align === "left" ? 0 : 0.5, 0.5);
|
|
128
|
+
this._readonlyInput.position.set(align === "left" ? 0 : width / 2, height / 2);
|
|
129
|
+
}
|
|
130
|
+
/** @description 聚焦 */
|
|
131
|
+
_focus() {
|
|
132
|
+
const { type } = this._params;
|
|
133
|
+
this._input.style.display = "block";
|
|
134
|
+
this._input.focus();
|
|
135
|
+
this._readonlyInput.visible = false;
|
|
136
|
+
this._placeholder.visible = false;
|
|
137
|
+
if (type === "number") {
|
|
138
|
+
this._input.value = this._value && Number(this._value).toString();
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
this._input.value = this._value;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** @description 失焦 */
|
|
145
|
+
_blur() {
|
|
146
|
+
const { onValue, width } = this._params;
|
|
147
|
+
const value = this._onBlurHandler();
|
|
148
|
+
this.setValue(value);
|
|
149
|
+
this._input.style.display = "none";
|
|
150
|
+
libPixiScaleContainer(this._readonlyInput, width);
|
|
151
|
+
if (this._params.type === "number") {
|
|
152
|
+
this._readonlyInput.visible = true;
|
|
153
|
+
onValue === null || onValue === void 0 ? void 0 : onValue(Number(value));
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
onValue === null || onValue === void 0 ? void 0 : onValue(value);
|
|
157
|
+
//如果输入的值为空,并且启用了描述,并且没有默认值,则显示描述
|
|
158
|
+
if (value === "" && this._placeholder) {
|
|
159
|
+
this._placeholder.visible = true;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
this._readonlyInput.visible = true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/** @description 实时更新输入框位置 */
|
|
167
|
+
_updateInputPosition() {
|
|
168
|
+
const { width, height, x, y } = this.getBounds();
|
|
169
|
+
const { fontSizeRatio = 0.5 } = this._params;
|
|
170
|
+
this._input.style.width = `${width}px`;
|
|
171
|
+
this._input.style.height = `${height}px`;
|
|
172
|
+
this._input.style.fontSize = `${height * fontSizeRatio}px`;
|
|
173
|
+
if (LibPixiInput.stage.rotation === 0) {
|
|
174
|
+
this._input.style.left = `${x}px`;
|
|
175
|
+
this._input.style.top = `${y}px`;
|
|
176
|
+
this._input.style.width = `${width}px`;
|
|
177
|
+
this._input.style.height = `${height}px`;
|
|
178
|
+
this._input.style.fontSize = `${height * fontSizeRatio}px`;
|
|
179
|
+
this._input.style.transform = `rotate(0deg)`;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
const centerX = x + width / 2;
|
|
183
|
+
const centerY = y + height / 2;
|
|
184
|
+
this._input.style.left = `${centerX - height / 2}px`;
|
|
185
|
+
this._input.style.top = `${centerY - width / 2}px`;
|
|
186
|
+
this._input.style.width = `${height}px`;
|
|
187
|
+
this._input.style.height = `${width}px`;
|
|
188
|
+
this._input.style.fontSize = `${width * fontSizeRatio}px`;
|
|
189
|
+
this._input.style.transform = `rotate(90deg)`;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/** @description 设置输入框类型 */
|
|
193
|
+
toggleType(type) {
|
|
194
|
+
this._input.type = type;
|
|
195
|
+
this._params.type = type;
|
|
196
|
+
this.setValue(this._value);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BitmapText, Container, Sprite } from "pixi.js";
|
|
2
|
+
import { LibPixiText } from "../Base/LibPixiText";
|
|
3
|
+
type T = Sprite | LibPixiText | BitmapText;
|
|
4
|
+
interface LabelValueParams {
|
|
5
|
+
/** 描述 */
|
|
6
|
+
label: T;
|
|
7
|
+
/** 值 */
|
|
8
|
+
value: T;
|
|
9
|
+
/** 最大宽度 */
|
|
10
|
+
maxWidth?: number;
|
|
11
|
+
/** 间隔 */
|
|
12
|
+
gap?: number;
|
|
13
|
+
}
|
|
14
|
+
/** @description 自适应宽度的标签和值组件
|
|
15
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiLabelValue-标签值
|
|
16
|
+
*/
|
|
17
|
+
export declare class LibPixiLabelValue extends Container {
|
|
18
|
+
/** 描述 */
|
|
19
|
+
private _label;
|
|
20
|
+
/** 值 */
|
|
21
|
+
private _value;
|
|
22
|
+
/** 间隔 */
|
|
23
|
+
private _gap;
|
|
24
|
+
/** 最大宽度 */
|
|
25
|
+
private _maxWidth?;
|
|
26
|
+
constructor(params: LabelValueParams);
|
|
27
|
+
/** @description 更新坐标 */
|
|
28
|
+
updatePosition(): void;
|
|
29
|
+
}
|
|
30
|
+
export {};
|