lyb-pixi-js 1.12.33 → 1.12.35
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/LibPixiHeadingParagraphLayout.d.ts +18 -0
- package/Components/Custom/LibPixiHeadingParagraphLayout.js +27 -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/README.md +6 -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 +134 -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,53 @@
|
|
|
1
|
+
import "@pixi/sound";
|
|
2
|
+
export declare class LibPixiAudio {
|
|
3
|
+
/** 是否启用音效 */
|
|
4
|
+
effectEnabled: boolean;
|
|
5
|
+
/** 是否启用音乐 */
|
|
6
|
+
musicEnabled: boolean;
|
|
7
|
+
/** 音乐是否处于暂停状态 */
|
|
8
|
+
private _isMusicPaused;
|
|
9
|
+
/** 是否已切换后台 */
|
|
10
|
+
private _isBackground;
|
|
11
|
+
/** 当前音乐播放器 */
|
|
12
|
+
private _musicPlayer?;
|
|
13
|
+
/** 当前正在播放的音效列表 */
|
|
14
|
+
private _playingList;
|
|
15
|
+
constructor();
|
|
16
|
+
/** @description 播放音效
|
|
17
|
+
* @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源
|
|
18
|
+
* @param end 倒数几秒位置播放,单位秒
|
|
19
|
+
*/
|
|
20
|
+
playEffect(key: string, end?: number): Promise<void>;
|
|
21
|
+
/** @description 播放音乐
|
|
22
|
+
* @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源
|
|
23
|
+
*/
|
|
24
|
+
playMusic(key: string): Promise<void>;
|
|
25
|
+
/** @description 暂停音乐 */
|
|
26
|
+
pauseMusic(): void;
|
|
27
|
+
/** @description 继续播放音乐 */
|
|
28
|
+
resumeMusic(): void;
|
|
29
|
+
/** @description 停止播放指定音效
|
|
30
|
+
* @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源进行停止
|
|
31
|
+
*/
|
|
32
|
+
stopEffect(key: string): void;
|
|
33
|
+
/** @description 设置启用音效
|
|
34
|
+
* @param enabled 启用状态,false为禁用
|
|
35
|
+
*/
|
|
36
|
+
setEffectEnabled(enabled: boolean): void;
|
|
37
|
+
/** @description 设置启用音乐
|
|
38
|
+
* @param enabled 启用状态,false为禁用
|
|
39
|
+
*/
|
|
40
|
+
setMusicEnabled(enabled: boolean): void;
|
|
41
|
+
/** @description 设置音效和音乐播放状态
|
|
42
|
+
* @param status 播放状态,false为暂停
|
|
43
|
+
*/
|
|
44
|
+
private _setPlayStatus;
|
|
45
|
+
/** @description 设置静音音乐
|
|
46
|
+
* @param disabled 静音状态,true为静音
|
|
47
|
+
*/
|
|
48
|
+
private _setMusicMute;
|
|
49
|
+
/** @description 设置静音音效
|
|
50
|
+
* @param disabled 静音状态,true为静音
|
|
51
|
+
*/
|
|
52
|
+
private _setEffectMute;
|
|
53
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
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 { Assets } from "pixi.js";
|
|
11
|
+
import { Howl } from "howler";
|
|
12
|
+
import "@pixi/sound";
|
|
13
|
+
import gsap from "gsap";
|
|
14
|
+
export class LibPixiAudio {
|
|
15
|
+
constructor() {
|
|
16
|
+
/** 是否启用音效 */
|
|
17
|
+
this.effectEnabled = true;
|
|
18
|
+
/** 是否启用音乐 */
|
|
19
|
+
this.musicEnabled = true;
|
|
20
|
+
/** 音乐是否处于暂停状态 */
|
|
21
|
+
this._isMusicPaused = false;
|
|
22
|
+
/** 是否已切换后台 */
|
|
23
|
+
this._isBackground = false;
|
|
24
|
+
/** 当前正在播放的音效列表 */
|
|
25
|
+
this._playingList = [];
|
|
26
|
+
/** @description 设置音效和音乐播放状态
|
|
27
|
+
* @param status 播放状态,false为暂停
|
|
28
|
+
*/
|
|
29
|
+
this._setPlayStatus = (status) => {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
if (status) {
|
|
32
|
+
!this._isMusicPaused && ((_a = this._musicPlayer) === null || _a === void 0 ? void 0 : _a.play());
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
(_b = this._musicPlayer) === null || _b === void 0 ? void 0 : _b.pause();
|
|
36
|
+
}
|
|
37
|
+
this._playingList.forEach((item) => {
|
|
38
|
+
if (status) {
|
|
39
|
+
item.audio.play();
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
item.audio.pause();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
document.addEventListener("visibilitychange", () => {
|
|
47
|
+
this._isBackground = document.hidden;
|
|
48
|
+
this._setPlayStatus(!document.hidden);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** @description 播放音效
|
|
52
|
+
* @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源
|
|
53
|
+
* @param end 倒数几秒位置播放,单位秒
|
|
54
|
+
*/
|
|
55
|
+
playEffect(key, end) {
|
|
56
|
+
return new Promise((resolve) => {
|
|
57
|
+
const id = Math.random();
|
|
58
|
+
const url = Assets.get(key).url;
|
|
59
|
+
const sound = new Howl({
|
|
60
|
+
src: url,
|
|
61
|
+
mute: this._isBackground || !this.effectEnabled,
|
|
62
|
+
});
|
|
63
|
+
sound.play();
|
|
64
|
+
sound.on("end", () => {
|
|
65
|
+
this._playingList = this._playingList.filter((item) => item.id !== id);
|
|
66
|
+
resolve();
|
|
67
|
+
});
|
|
68
|
+
//倒数几秒位置播放
|
|
69
|
+
if (end) {
|
|
70
|
+
const duration = sound.duration();
|
|
71
|
+
const start = duration - end;
|
|
72
|
+
sound.seek(start);
|
|
73
|
+
}
|
|
74
|
+
this._playingList.push({
|
|
75
|
+
id,
|
|
76
|
+
audio: sound,
|
|
77
|
+
url,
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/** @description 播放音乐
|
|
82
|
+
* @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源
|
|
83
|
+
*/
|
|
84
|
+
playMusic(key) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const url = Assets.get(key).url;
|
|
87
|
+
//如果有音乐正在播放,则停止
|
|
88
|
+
if (this._musicPlayer) {
|
|
89
|
+
gsap.killTweensOf(this._musicPlayer);
|
|
90
|
+
yield gsap.to(this._musicPlayer, {
|
|
91
|
+
volume: 0,
|
|
92
|
+
duration: 1,
|
|
93
|
+
ease: "linear",
|
|
94
|
+
});
|
|
95
|
+
this._musicPlayer.stop();
|
|
96
|
+
}
|
|
97
|
+
this._musicPlayer = new Howl({
|
|
98
|
+
src: url,
|
|
99
|
+
loop: true,
|
|
100
|
+
volume: 0,
|
|
101
|
+
mute: this._isBackground || !this.musicEnabled,
|
|
102
|
+
});
|
|
103
|
+
this._musicPlayer.play();
|
|
104
|
+
this._isMusicPaused = false;
|
|
105
|
+
gsap.killTweensOf(this._musicPlayer);
|
|
106
|
+
gsap.to(this._musicPlayer, {
|
|
107
|
+
volume: 1,
|
|
108
|
+
duration: 1,
|
|
109
|
+
ease: "linear",
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/** @description 暂停音乐 */
|
|
114
|
+
pauseMusic() {
|
|
115
|
+
var _a;
|
|
116
|
+
this._isMusicPaused = true;
|
|
117
|
+
(_a = this._musicPlayer) === null || _a === void 0 ? void 0 : _a.pause();
|
|
118
|
+
}
|
|
119
|
+
/** @description 继续播放音乐 */
|
|
120
|
+
resumeMusic() {
|
|
121
|
+
var _a, _b;
|
|
122
|
+
this._isMusicPaused = false;
|
|
123
|
+
if ((_a = this._musicPlayer) === null || _a === void 0 ? void 0 : _a.playing())
|
|
124
|
+
return;
|
|
125
|
+
(_b = this._musicPlayer) === null || _b === void 0 ? void 0 : _b.play();
|
|
126
|
+
}
|
|
127
|
+
/** @description 停止播放指定音效
|
|
128
|
+
* @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源进行停止
|
|
129
|
+
*/
|
|
130
|
+
stopEffect(key) {
|
|
131
|
+
const url = Assets.get(key).url;
|
|
132
|
+
this._playingList.forEach((item) => {
|
|
133
|
+
if (item.url === url) {
|
|
134
|
+
item.audio.stop();
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
this._playingList = this._playingList.filter((item) => item.url !== url);
|
|
138
|
+
}
|
|
139
|
+
/** @description 设置启用音效
|
|
140
|
+
* @param enabled 启用状态,false为禁用
|
|
141
|
+
*/
|
|
142
|
+
setEffectEnabled(enabled) {
|
|
143
|
+
this.effectEnabled = enabled;
|
|
144
|
+
this._setEffectMute(!enabled);
|
|
145
|
+
}
|
|
146
|
+
/** @description 设置启用音乐
|
|
147
|
+
* @param enabled 启用状态,false为禁用
|
|
148
|
+
*/
|
|
149
|
+
setMusicEnabled(enabled) {
|
|
150
|
+
this.musicEnabled = enabled;
|
|
151
|
+
this._setMusicMute(!enabled);
|
|
152
|
+
}
|
|
153
|
+
/** @description 设置静音音乐
|
|
154
|
+
* @param disabled 静音状态,true为静音
|
|
155
|
+
*/
|
|
156
|
+
_setMusicMute(disabled) {
|
|
157
|
+
var _a;
|
|
158
|
+
(_a = this._musicPlayer) === null || _a === void 0 ? void 0 : _a.mute(disabled || !this.musicEnabled);
|
|
159
|
+
}
|
|
160
|
+
/** @description 设置静音音效
|
|
161
|
+
* @param disabled 静音状态,true为静音
|
|
162
|
+
*/
|
|
163
|
+
_setEffectMute(disabled) {
|
|
164
|
+
this._playingList.forEach((item) => {
|
|
165
|
+
item.audio.mute(disabled || !this.effectEnabled);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NineSlicePlane, type Texture } from "pixi.js";
|
|
2
|
+
export interface LibPixiCreateNineGridParams {
|
|
3
|
+
/** 九宫格图片 */
|
|
4
|
+
texture: Texture;
|
|
5
|
+
/** 四个角的宽度 */
|
|
6
|
+
dotWidth: number | [number, number, number, number];
|
|
7
|
+
/** 宽度 */
|
|
8
|
+
width: number;
|
|
9
|
+
/** 高度 */
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
/** @description 九宫格图
|
|
13
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiCreateNineGrid-九宫格图
|
|
14
|
+
*/
|
|
15
|
+
export declare const libPixiCreateNineGrid: (params: LibPixiCreateNineGridParams) => NineSlicePlane;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NineSlicePlane } from "pixi.js";
|
|
2
|
+
/** @description 九宫格图
|
|
3
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiCreateNineGrid-九宫格图
|
|
4
|
+
*/
|
|
5
|
+
export const libPixiCreateNineGrid = (params) => {
|
|
6
|
+
const { texture, dotWidth, width, height } = params;
|
|
7
|
+
let slice_width = [];
|
|
8
|
+
// 四个角的宽度
|
|
9
|
+
if (Array.isArray(dotWidth)) {
|
|
10
|
+
slice_width = dotWidth;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
slice_width = [dotWidth, dotWidth, dotWidth, dotWidth];
|
|
14
|
+
}
|
|
15
|
+
const nineSlicePlane = new NineSlicePlane(texture, slice_width[0], slice_width[1], slice_width[2], slice_width[3]);
|
|
16
|
+
nineSlicePlane.width = width;
|
|
17
|
+
nineSlicePlane.height = height;
|
|
18
|
+
return nineSlicePlane;
|
|
19
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Container } from "pixi.js";
|
|
2
|
+
import type { LibPixiBaseContainer } from "./ui/LibPixiBaseContainer";
|
|
3
|
+
export { LibPixiBaseContainer } from "./ui/LibPixiBaseContainer";
|
|
4
|
+
export { LibPixiDialog } from "./ui/LibPixiDialog";
|
|
5
|
+
interface IViewCtor {
|
|
6
|
+
new (...args: any[]): LibPixiBaseContainer;
|
|
7
|
+
}
|
|
8
|
+
/** @description 弹窗管理器 */
|
|
9
|
+
export declare class LibPixiDialogManager {
|
|
10
|
+
/** 视图表 */
|
|
11
|
+
private views;
|
|
12
|
+
/** open时显示的元素的父容器 */
|
|
13
|
+
private _openContainer;
|
|
14
|
+
constructor(parent: Container);
|
|
15
|
+
/**
|
|
16
|
+
* 打开界面
|
|
17
|
+
* @param View 实例类型或构造方法
|
|
18
|
+
* @param args 实例参数
|
|
19
|
+
*/
|
|
20
|
+
open<T extends IViewCtor>(View: T, id: string, ...args: ConstructorParameters<T>): InstanceType<T>;
|
|
21
|
+
/** @description 关闭页面,会调用页面的 onBeforeUnmount 事件,里面会做关闭动画,动画结束后会自动销毁
|
|
22
|
+
* @param id 页面名称
|
|
23
|
+
*/
|
|
24
|
+
close(id: string): Promise<void>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
export { LibPixiBaseContainer } from "./ui/LibPixiBaseContainer";
|
|
11
|
+
export { LibPixiDialog } from "./ui/LibPixiDialog";
|
|
12
|
+
/** @description 弹窗管理器 */
|
|
13
|
+
export class LibPixiDialogManager {
|
|
14
|
+
constructor(parent) {
|
|
15
|
+
/** 视图表 */
|
|
16
|
+
this.views = {};
|
|
17
|
+
this._openContainer = parent;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 打开界面
|
|
21
|
+
* @param View 实例类型或构造方法
|
|
22
|
+
* @param args 实例参数
|
|
23
|
+
*/
|
|
24
|
+
open(View, id, ...args) {
|
|
25
|
+
const view = new View(...args);
|
|
26
|
+
this._openContainer.addChild(view);
|
|
27
|
+
this.views[id] = view;
|
|
28
|
+
return view;
|
|
29
|
+
}
|
|
30
|
+
/** @description 关闭页面,会调用页面的 onBeforeUnmount 事件,里面会做关闭动画,动画结束后会自动销毁
|
|
31
|
+
* @param id 页面名称
|
|
32
|
+
*/
|
|
33
|
+
close(id) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
var _a;
|
|
36
|
+
const view = this.views[id];
|
|
37
|
+
if (view) {
|
|
38
|
+
yield ((_a = view.destroy) === null || _a === void 0 ? void 0 : _a.call(view));
|
|
39
|
+
delete this.views[id];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
/** @description */
|
|
3
|
+
export declare class LibPixiBaseContainer extends Container {
|
|
4
|
+
/** 销毁之前 */
|
|
5
|
+
protected _onBeforeDestroy?: () => void | Promise<void>;
|
|
6
|
+
/** 已销毁 */
|
|
7
|
+
protected _onDestroyed?: () => void;
|
|
8
|
+
constructor();
|
|
9
|
+
/** @description 销毁 */
|
|
10
|
+
destroy(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
/** @description */
|
|
12
|
+
export class LibPixiBaseContainer extends Container {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
}
|
|
16
|
+
/** @description 销毁 */
|
|
17
|
+
destroy() {
|
|
18
|
+
const _super = Object.create(null, {
|
|
19
|
+
destroy: { get: () => super.destroy }
|
|
20
|
+
});
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
var _a;
|
|
23
|
+
yield ((_a = this._onBeforeDestroy) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
24
|
+
requestAnimationFrame(() => {
|
|
25
|
+
var _a;
|
|
26
|
+
_super.destroy.call(this, { children: true });
|
|
27
|
+
(_a = this._onDestroyed) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
import { LibPixiBaseContainer } from "./LibPixiBaseContainer";
|
|
3
|
+
interface Params {
|
|
4
|
+
/** 是否需要显示黑色背景 */
|
|
5
|
+
needBg?: boolean;
|
|
6
|
+
/** 竖版初始大小 */
|
|
7
|
+
size?: number;
|
|
8
|
+
/** 点击蒙版回调 */
|
|
9
|
+
onClickMask?: () => void;
|
|
10
|
+
}
|
|
11
|
+
/** @description 弹窗组件 */
|
|
12
|
+
export declare class LibPixiDialog extends LibPixiBaseContainer {
|
|
13
|
+
/** 黑色背景透明度 */
|
|
14
|
+
static bgAlpha: number;
|
|
15
|
+
/** 动画时长 */
|
|
16
|
+
static durationIn: number;
|
|
17
|
+
static durationOut: number;
|
|
18
|
+
/** 是否支持横竖版 */
|
|
19
|
+
static adaptation: "hv" | "h" | "v";
|
|
20
|
+
/** 蒙版UI */
|
|
21
|
+
private _maskUI;
|
|
22
|
+
/** 内容容器 */
|
|
23
|
+
private _dialogContainer;
|
|
24
|
+
/** 当前大小 */
|
|
25
|
+
private _size;
|
|
26
|
+
/** 竖版初始大小 */
|
|
27
|
+
private _initialSize;
|
|
28
|
+
/** 停止监听窗口 */
|
|
29
|
+
private _offResize?;
|
|
30
|
+
constructor(params?: Params);
|
|
31
|
+
/** @description 设置弹窗内容 */
|
|
32
|
+
setDialogContent(content: Container): void;
|
|
33
|
+
/** @description 重绘弹窗 */
|
|
34
|
+
redraw(w: number, h: number): void;
|
|
35
|
+
/** @description 关闭 */
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
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 { LibJsResizeWatcher } from "lyb-js/Base/LibJsResizeWatcher.js";
|
|
13
|
+
import { LibPixiRectangle } from "../../../Components/Base/LibPixiRectangle";
|
|
14
|
+
import { libPixiEvent } from "../../LibPixiEvent";
|
|
15
|
+
import { LibPixiBaseContainer } from "./LibPixiBaseContainer";
|
|
16
|
+
/** @description 弹窗组件 */
|
|
17
|
+
export class LibPixiDialog extends LibPixiBaseContainer {
|
|
18
|
+
constructor(params) {
|
|
19
|
+
super();
|
|
20
|
+
/** 当前大小 */
|
|
21
|
+
this._size = 1;
|
|
22
|
+
const { size = 1, onClickMask, needBg = true } = params || {};
|
|
23
|
+
this._initialSize = size;
|
|
24
|
+
//蒙版
|
|
25
|
+
this._maskUI = new LibPixiRectangle(2700, 1080, "#000");
|
|
26
|
+
this.addChild(this._maskUI);
|
|
27
|
+
this._maskUI.alpha = 0;
|
|
28
|
+
this._maskUI.eventMode = "static";
|
|
29
|
+
this._maskUI.visible = needBg;
|
|
30
|
+
if (onClickMask) {
|
|
31
|
+
libPixiEvent(this._maskUI, "pointertap", () => {
|
|
32
|
+
var _a;
|
|
33
|
+
onClickMask === null || onClickMask === void 0 ? void 0 : onClickMask();
|
|
34
|
+
(_a = this._offResize) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
35
|
+
}, {
|
|
36
|
+
once: true,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//弹窗内容容器
|
|
40
|
+
this._dialogContainer = new Container();
|
|
41
|
+
this.addChild(this._dialogContainer);
|
|
42
|
+
this._dialogContainer.eventMode = "static";
|
|
43
|
+
const resize = new LibJsResizeWatcher(LibPixiDialog.adaptation);
|
|
44
|
+
this._offResize = resize.on(this.redraw.bind(this));
|
|
45
|
+
}
|
|
46
|
+
/** @description 设置弹窗内容 */
|
|
47
|
+
setDialogContent(content) {
|
|
48
|
+
this._dialogContainer.addChild(content);
|
|
49
|
+
if (LibPixiDialog.adaptation === "h") {
|
|
50
|
+
this.redraw(1920, 1080);
|
|
51
|
+
}
|
|
52
|
+
else if (LibPixiDialog.adaptation === "v") {
|
|
53
|
+
this.redraw(1080, 1920);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
this.redraw(window.innerWidth, window.innerHeight);
|
|
57
|
+
}
|
|
58
|
+
this._dialogContainer.scale.set(0);
|
|
59
|
+
this._dialogContainer.alpha = 0;
|
|
60
|
+
gsap.to(this._maskUI, {
|
|
61
|
+
duration: LibPixiDialog.durationIn,
|
|
62
|
+
alpha: LibPixiDialog.bgAlpha,
|
|
63
|
+
});
|
|
64
|
+
gsap.to(this._dialogContainer, {
|
|
65
|
+
duration: LibPixiDialog.durationIn,
|
|
66
|
+
alpha: 1,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/** @description 重绘弹窗 */
|
|
70
|
+
redraw(w, h) {
|
|
71
|
+
const dialogW = this._dialogContainer.width / 2;
|
|
72
|
+
const dialogH = this._dialogContainer.height / 2;
|
|
73
|
+
this._dialogContainer.pivot.set(dialogW, dialogH);
|
|
74
|
+
const halfW = 1920 / 2;
|
|
75
|
+
const halfH = 1080 / 2;
|
|
76
|
+
if (w > h) {
|
|
77
|
+
this._maskUI.width = 2700;
|
|
78
|
+
this._maskUI.height = 1080;
|
|
79
|
+
this._maskUI.x = -(2700 - 1920) / 2;
|
|
80
|
+
this._dialogContainer.position.set(halfW, halfH);
|
|
81
|
+
this._size = 1;
|
|
82
|
+
if (this._dialogContainer.scale.x === this._initialSize) {
|
|
83
|
+
this._dialogContainer.scale.set(1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
this._maskUI.width = 1080;
|
|
88
|
+
this._maskUI.height = 2700;
|
|
89
|
+
this._maskUI.x = 0;
|
|
90
|
+
this._dialogContainer.position.set(halfH, halfW);
|
|
91
|
+
this._size = this._initialSize;
|
|
92
|
+
if (this._dialogContainer.scale.x === 1) {
|
|
93
|
+
this._dialogContainer.scale.set(this._initialSize);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
gsap.to(this._dialogContainer.scale, {
|
|
97
|
+
duration: LibPixiDialog.durationIn,
|
|
98
|
+
ease: "back.out",
|
|
99
|
+
x: this._size,
|
|
100
|
+
y: this._size,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/** @description 关闭 */
|
|
104
|
+
close() {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
var _a;
|
|
107
|
+
this._maskUI.eventMode = "none";
|
|
108
|
+
(_a = this._offResize) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
109
|
+
gsap.to(this._dialogContainer.scale, {
|
|
110
|
+
duration: LibPixiDialog.durationOut,
|
|
111
|
+
ease: "back.in",
|
|
112
|
+
x: 0,
|
|
113
|
+
y: 0,
|
|
114
|
+
});
|
|
115
|
+
gsap.to(this._dialogContainer, {
|
|
116
|
+
duration: LibPixiDialog.durationOut,
|
|
117
|
+
delay: LibPixiDialog.durationOut / 2,
|
|
118
|
+
alpha: 0,
|
|
119
|
+
});
|
|
120
|
+
yield gsap.to(this._maskUI, {
|
|
121
|
+
duration: LibPixiDialog.durationOut,
|
|
122
|
+
delay: LibPixiDialog.durationOut / 2,
|
|
123
|
+
alpha: 0,
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/** 黑色背景透明度 */
|
|
129
|
+
LibPixiDialog.bgAlpha = 0.5;
|
|
130
|
+
/** 动画时长 */
|
|
131
|
+
LibPixiDialog.durationIn = 0.5;
|
|
132
|
+
LibPixiDialog.durationOut = 0.5;
|
|
133
|
+
/** 是否支持横竖版 */
|
|
134
|
+
LibPixiDialog.adaptation = "hv";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface LibPixiDigitalIncreasingAnimationParams {
|
|
2
|
+
/** 目标值 */
|
|
3
|
+
value: number;
|
|
4
|
+
/** 开始值 */
|
|
5
|
+
startValue?: number;
|
|
6
|
+
/** 动画时长 */
|
|
7
|
+
duration?: number;
|
|
8
|
+
/** 值改变时触发 */
|
|
9
|
+
onChange: (value: string) => void;
|
|
10
|
+
/** 动画完成后触发 */
|
|
11
|
+
onComplete?: () => void;
|
|
12
|
+
}
|
|
13
|
+
/** @description 数值递增动画
|
|
14
|
+
* @param params 动画参数
|
|
15
|
+
* @returns 设置为目标值并停止动画
|
|
16
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiDigitalIncreasingAnimation-递增动画
|
|
17
|
+
*/
|
|
18
|
+
export declare const LibPixiDigitalIncreasingAnimation: (params: LibPixiDigitalIncreasingAnimationParams) => () => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { libJsNumComma } from "lyb-js/Formatter/LibJsNumComma.js";
|
|
2
|
+
import gsap from "gsap";
|
|
3
|
+
/** @description 数值递增动画
|
|
4
|
+
* @param params 动画参数
|
|
5
|
+
* @returns 设置为目标值并停止动画
|
|
6
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiDigitalIncreasingAnimation-递增动画
|
|
7
|
+
*/
|
|
8
|
+
export const LibPixiDigitalIncreasingAnimation = (params) => {
|
|
9
|
+
const { value, onChange, onComplete, startValue = 0, duration = 4 } = params;
|
|
10
|
+
// 动画递增的目标值
|
|
11
|
+
const animatedValue = { value: startValue };
|
|
12
|
+
// 使用 GSAP 创建递增动画
|
|
13
|
+
gsap.killTweensOf(animatedValue);
|
|
14
|
+
const amountAnimation = gsap.to(animatedValue, {
|
|
15
|
+
value,
|
|
16
|
+
duration,
|
|
17
|
+
ease: "linear",
|
|
18
|
+
onUpdate: () => {
|
|
19
|
+
onChange(libJsNumComma(animatedValue.value, 2));
|
|
20
|
+
},
|
|
21
|
+
onComplete: onComplete,
|
|
22
|
+
});
|
|
23
|
+
return () => {
|
|
24
|
+
amountAnimation.progress(1);
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
/** @description 按下放大
|
|
3
|
+
* @param container 要放大的容器
|
|
4
|
+
* @param type 缩放类型
|
|
5
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiDownScaleAnimation-按下放大
|
|
6
|
+
*/
|
|
7
|
+
export declare const LibPixiDownScaleAnimation: (container: Container, type?: "small" | "big") => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { libPixiEvent } from "./LibPixiEvent";
|
|
2
|
+
import gsap from "gsap";
|
|
3
|
+
/** @description 按下放大
|
|
4
|
+
* @param container 要放大的容器
|
|
5
|
+
* @param type 缩放类型
|
|
6
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiDownScaleAnimation-按下放大
|
|
7
|
+
*/
|
|
8
|
+
export const LibPixiDownScaleAnimation = (container, type = "big") => {
|
|
9
|
+
libPixiEvent(container, "pointerdown", () => {
|
|
10
|
+
gsap.to(container, {
|
|
11
|
+
duration: 0.1,
|
|
12
|
+
pixi: {
|
|
13
|
+
scale: type === "big" ? 1.1 : 0.9,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
libPixiEvent(container, "pointerup", () => {
|
|
18
|
+
gsap.to(container, {
|
|
19
|
+
duration: 0.1,
|
|
20
|
+
pixi: {
|
|
21
|
+
scale: 1,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
libPixiEvent(container, "pointerleave", () => {
|
|
26
|
+
gsap.to(container, {
|
|
27
|
+
duration: 0.1,
|
|
28
|
+
pixi: {
|
|
29
|
+
scale: 1,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @description 触发后代监听
|
|
2
|
+
* @param container 容器
|
|
3
|
+
* @param event 事件名称
|
|
4
|
+
* @param payload 事件携带数据
|
|
5
|
+
*/
|
|
6
|
+
export const LibPixiEmitContainerEvent = (container, event, payload) => {
|
|
7
|
+
container.children.forEach((child) => {
|
|
8
|
+
child.emit(event, payload);
|
|
9
|
+
if ("children" in child) {
|
|
10
|
+
LibPixiEmitContainerEvent(child, event, payload);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Container, DisplayObjectEvents, FederatedPointerEvent } from "pixi.js";
|
|
2
|
+
export interface LibPixiEventParams {
|
|
3
|
+
/** 是否只执行一次 */
|
|
4
|
+
once?: boolean;
|
|
5
|
+
/** 是否启用防抖 */
|
|
6
|
+
debounce?: boolean;
|
|
7
|
+
/** 防抖时长 */
|
|
8
|
+
debounceTime?: number;
|
|
9
|
+
/** 是否阻止拖动点击 */
|
|
10
|
+
preventDragClick?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** @description 事件注册
|
|
13
|
+
* @param v 事件容器
|
|
14
|
+
* @param eventName 事件名称
|
|
15
|
+
* @param callback 回调函数
|
|
16
|
+
* @returns 停止监听
|
|
17
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiEvent-事件注册
|
|
18
|
+
*/
|
|
19
|
+
export declare const libPixiEvent: (v: Container, eventName: keyof DisplayObjectEvents, callback: (event: FederatedPointerEvent) => void, params?: LibPixiEventParams) => () => void;
|