lyb-pixi-js 1.12.31 → 1.12.33

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.
Files changed (137) hide show
  1. package/README.md +50 -85
  2. package/index.js +5 -2
  3. package/lyb-pixi.js +209 -197
  4. package/package.json +1 -1
  5. package/Components/Base/LibDestroyContainer.d.ts +0 -11
  6. package/Components/Base/LibDestroyContainer.js +0 -28
  7. package/Components/Base/LibPixiArc.d.ts +0 -16
  8. package/Components/Base/LibPixiArc.js +0 -14
  9. package/Components/Base/LibPixiBitText.d.ts +0 -20
  10. package/Components/Base/LibPixiBitText.js +0 -26
  11. package/Components/Base/LibPixiCircular.d.ts +0 -7
  12. package/Components/Base/LibPixiCircular.js +0 -12
  13. package/Components/Base/LibPixiContainer.d.ts +0 -22
  14. package/Components/Base/LibPixiContainer.js +0 -51
  15. package/Components/Base/LibPixiHtmlText.d.ts +0 -31
  16. package/Components/Base/LibPixiHtmlText.js +0 -30
  17. package/Components/Base/LibPixiOval.d.ts +0 -5
  18. package/Components/Base/LibPixiOval.js +0 -10
  19. package/Components/Base/LibPixiParticleMove.d.ts +0 -101
  20. package/Components/Base/LibPixiParticleMove.js +0 -136
  21. package/Components/Base/LibPixiPolygon.d.ts +0 -7
  22. package/Components/Base/LibPixiPolygon.js +0 -15
  23. package/Components/Base/LibPixiRectBgColor.d.ts +0 -41
  24. package/Components/Base/LibPixiRectBgColor.js +0 -95
  25. package/Components/Base/LibPixiRectangle.d.ts +0 -7
  26. package/Components/Base/LibPixiRectangle.js +0 -15
  27. package/Components/Base/LibPixiRound.d.ts +0 -5
  28. package/Components/Base/LibPixiRound.js +0 -9
  29. package/Components/Base/LibPixiRoundedRect.d.ts +0 -5
  30. package/Components/Base/LibPixiRoundedRect.js +0 -10
  31. package/Components/Base/LibPixiSpine.d.ts +0 -58
  32. package/Components/Base/LibPixiSpine.js +0 -128
  33. package/Components/Base/LibPixiText.d.ts +0 -37
  34. package/Components/Base/LibPixiText.js +0 -35
  35. package/Components/Custom/LibPixiArrangeLinearV2.d.ts +0 -25
  36. package/Components/Custom/LibPixiArrangeLinearV2.js +0 -80
  37. package/Components/Custom/LibPixiButtonHover.d.ts +0 -40
  38. package/Components/Custom/LibPixiButtonHover.js +0 -53
  39. package/Components/Custom/LibPixiCapsule.d.ts +0 -5
  40. package/Components/Custom/LibPixiCapsule.js +0 -10
  41. package/Components/Custom/LibPixiCloseBtn.d.ts +0 -14
  42. package/Components/Custom/LibPixiCloseBtn.js +0 -36
  43. package/Components/Custom/LibPixiDragLocate.d.ts +0 -36
  44. package/Components/Custom/LibPixiDragLocate.js +0 -230
  45. package/Components/Custom/LibPixiDrawer.d.ts +0 -16
  46. package/Components/Custom/LibPixiDrawer.js +0 -59
  47. package/Components/Custom/LibPixiInput.d.ts +0 -75
  48. package/Components/Custom/LibPixiInput.js +0 -186
  49. package/Components/Custom/LibPixiLabelValue.d.ts +0 -30
  50. package/Components/Custom/LibPixiLabelValue.js +0 -26
  51. package/Components/Custom/LibPixiPerforMon.d.ts +0 -47
  52. package/Components/Custom/LibPixiPerforMon.js +0 -166
  53. package/Components/Custom/LibPixiProgress.d.ts +0 -33
  54. package/Components/Custom/LibPixiProgress.js +0 -47
  55. package/Components/Custom/LibPixiPuzzleBg.d.ts +0 -7
  56. package/Components/Custom/LibPixiPuzzleBg.js +0 -46
  57. package/Components/Custom/LibPixiScrollContainerX.d.ts +0 -71
  58. package/Components/Custom/LibPixiScrollContainerX.js +0 -189
  59. package/Components/Custom/LibPixiScrollContainerY.d.ts +0 -109
  60. package/Components/Custom/LibPixiScrollContainerY.js +0 -338
  61. package/Components/Custom/LibPixiScrollNum.d.ts +0 -67
  62. package/Components/Custom/LibPixiScrollNum.js +0 -184
  63. package/Components/Custom/LibPixiSlide.d.ts +0 -94
  64. package/Components/Custom/LibPixiSlide.js +0 -285
  65. package/Components/Custom/LibPixiSlider.d.ts +0 -82
  66. package/Components/Custom/LibPixiSlider.js +0 -165
  67. package/Components/Custom/LibPixiSubAddMinMax.d.ts +0 -40
  68. package/Components/Custom/LibPixiSubAddMinMax.js +0 -56
  69. package/Components/Custom/LibPixiTable.d.ts +0 -64
  70. package/Components/Custom/LibPixiTable.js +0 -76
  71. package/Components/Custom/LibPixiTextGroup.d.ts +0 -20
  72. package/Components/Custom/LibPixiTextGroup.js +0 -50
  73. package/Components/Custom/LibPixiTextGroupWrap.d.ts +0 -20
  74. package/Components/Custom/LibPixiTextGroupWrap.js +0 -50
  75. package/Components/Custom/LibPixiTriangle.d.ts +0 -5
  76. package/Components/Custom/LibPixiTriangle.js +0 -12
  77. package/Components/Custom/LibPixiTurntable.d.ts +0 -6
  78. package/Components/Custom/LibPixiTurntable.js +0 -14
  79. package/Utils/LibContainerCenter.d.ts +0 -3
  80. package/Utils/LibContainerCenter.js +0 -10
  81. package/Utils/LibControlledDelayedCall.d.ts +0 -5
  82. package/Utils/LibControlledDelayedCall.js +0 -20
  83. package/Utils/LibPixiArrangeLinear.d.ts +0 -16
  84. package/Utils/LibPixiArrangeLinear.js +0 -62
  85. package/Utils/LibPixiAudio.d.ts +0 -53
  86. package/Utils/LibPixiAudio.js +0 -168
  87. package/Utils/LibPixiCreateNineGrid.d.ts +0 -15
  88. package/Utils/LibPixiCreateNineGrid.js +0 -19
  89. package/Utils/LibPixiDialogManager/index.d.ts +0 -25
  90. package/Utils/LibPixiDialogManager/index.js +0 -43
  91. package/Utils/LibPixiDialogManager/ui/LibPixiBaseContainer.d.ts +0 -11
  92. package/Utils/LibPixiDialogManager/ui/LibPixiBaseContainer.js +0 -31
  93. package/Utils/LibPixiDialogManager/ui/LibPixiDialog.d.ts +0 -38
  94. package/Utils/LibPixiDialogManager/ui/LibPixiDialog.js +0 -133
  95. package/Utils/LibPixiDigitalIncreasingAnimation.d.ts +0 -18
  96. package/Utils/LibPixiDigitalIncreasingAnimation.js +0 -26
  97. package/Utils/LibPixiDownScaleAnimation.d.ts +0 -7
  98. package/Utils/LibPixiDownScaleAnimation.js +0 -33
  99. package/Utils/LibPixiEmitContainerEvent.d.ts +0 -7
  100. package/Utils/LibPixiEmitContainerEvent.js +0 -13
  101. package/Utils/LibPixiEvent.d.ts +0 -19
  102. package/Utils/LibPixiEvent.js +0 -68
  103. package/Utils/LibPixiFilter.d.ts +0 -9
  104. package/Utils/LibPixiFilter.js +0 -34
  105. package/Utils/LibPixiGlobalUpdater.d.ts +0 -15
  106. package/Utils/LibPixiGlobalUpdater.js +0 -21
  107. package/Utils/LibPixiGridLayout.d.ts +0 -10
  108. package/Utils/LibPixiGridLayout.js +0 -27
  109. package/Utils/LibPixiGridLayoutV2.d.ts +0 -27
  110. package/Utils/LibPixiGridLayoutV2.js +0 -37
  111. package/Utils/LibPixiHVCenter.d.ts +0 -7
  112. package/Utils/LibPixiHVCenter.js +0 -14
  113. package/Utils/LibPixiHVGap.d.ts +0 -8
  114. package/Utils/LibPixiHVGap.js +0 -26
  115. package/Utils/LibPixiIntervalTrigger.d.ts +0 -7
  116. package/Utils/LibPixiIntervalTrigger.js +0 -35
  117. package/Utils/LibPixiOutsideClick.d.ts +0 -8
  118. package/Utils/LibPixiOutsideClick.js +0 -22
  119. package/Utils/LibPixiOverflowHidden.d.ts +0 -6
  120. package/Utils/LibPixiOverflowHidden.js +0 -14
  121. package/Utils/LibPixiPolygonDrawTool.d.ts +0 -44
  122. package/Utils/LibPixiPolygonDrawTool.js +0 -114
  123. package/Utils/LibPixiPromiseTickerTimeout.d.ts +0 -6
  124. package/Utils/LibPixiPromiseTickerTimeout.js +0 -22
  125. package/Utils/LibPixiScaleContainer.d.ts +0 -8
  126. package/Utils/LibPixiScaleContainer.js +0 -14
  127. package/Utils/LibPixiShadow.d.ts +0 -17
  128. package/Utils/LibPixiShadow.js +0 -18
  129. package/Utils/LibPixiSlideInput.d.ts +0 -55
  130. package/Utils/LibPixiSlideInput.js +0 -61
  131. package/Utils/LibPixiTicker.d.ts +0 -14
  132. package/Utils/LibPixiTicker.js +0 -49
  133. package/Utils/LibPixiTickerTimeout.d.ts +0 -6
  134. package/Utils/LibPixiTickerTimeout.js +0 -22
  135. package/index.d.ts +0 -1
  136. package/libPixiJs.d.ts +0 -296
  137. package/libPixiJs.js +0 -315
@@ -1,94 +0,0 @@
1
- import { Container } from "pixi.js";
2
- import { LibPixiContainer } from "../Base/LibPixiContainer";
3
- export interface LibPixiSlideParams {
4
- /** 舞台 */
5
- stage: Container;
6
- /** 当前方向 */
7
- direction: "x" | "y";
8
- /** 滚动区域宽度 */
9
- width: number;
10
- /** 滚动区域高度 */
11
- height: number;
12
- /** 一页宽度 */
13
- pageWidth?: number;
14
- /** 一页高度 */
15
- pageHeight?: number;
16
- /** 滚动的容器 */
17
- content: Container;
18
- /** 元素列表 */
19
- itemList: Container[];
20
- /** 是否启用循环 */
21
- loop?: boolean;
22
- /** 景深定制回调,第二参数函数参数景深衰减值,可视区三个元素时,建议0.5,五个元素时,建议0.2 */
23
- depthCallback?: (container: Container, getValue: (depthAtten: number) => number) => void;
24
- /** 松手回调 */
25
- slideCallback?: (index: number) => void;
26
- /** 滚动回调 */
27
- scrollCallback?: (x: number, index: number) => void;
28
- }
29
- /** @description 滑动页
30
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiSlide-滑动页
31
- */
32
- export declare class LibPixiSlide extends LibPixiContainer {
33
- /** 舞台 */
34
- private _stage;
35
- /** 滑动加速度触发翻页 */
36
- private _SPEED_THRESHOLD;
37
- /** 滑动比例翻页 */
38
- private _SCROLL_THRESHOLD;
39
- /** 当前方向 */
40
- private _direction;
41
- /** 元素列表 */
42
- private _itemList;
43
- /** 一页宽度 */
44
- private _pageWidth;
45
- /** 一页高度 */
46
- private _pageHeight;
47
- /** 是否循环 */
48
- private _loop;
49
- /** 两侧预留格数,如可视区有三个,则两侧预留为1 */
50
- private _freeGridNum;
51
- /** 当前幻灯片索引 */
52
- private _currentIndex;
53
- /** 记录拖动开始时的X坐标 */
54
- private _startX;
55
- /** 记录拖动开始时的Y坐标 */
56
- private _startY;
57
- /** 偏移量 */
58
- private _offsetX;
59
- /** 偏移量 */
60
- private _offsetY;
61
- /** 最大索引 */
62
- private _pageNum;
63
- /** 记录开始时间 */
64
- private _startTime;
65
- /** 是否正在拖动 */
66
- private _isDragging;
67
- /** 滑动内容 */
68
- private _slideArea;
69
- /** 景深定制回调 */
70
- private _depthCallback?;
71
- /** 滑动回调 */
72
- private _slideCallback?;
73
- /** 滚动回调 */
74
- private _scrollCallback?;
75
- constructor(params: LibPixiSlideParams);
76
- /** @description 更新坐标 */
77
- updatePosition(v: number, index: number): void;
78
- /** @description 上一页 */
79
- prev(): void;
80
- /** @description 下一页 */
81
- next(): void;
82
- /** @description 滑动到指定索引 */
83
- slideTo(index: number): void;
84
- /** @description 设置滚动景深 */
85
- private _setDepth;
86
- /** @description 开始拖动 */
87
- private _onDragStart;
88
- /** @description 拖动中 */
89
- private _onDragMove;
90
- /** @description 滚动触发 */
91
- private _onScroll;
92
- /** @description 结束拖动 */
93
- private _onDragEnd;
94
- }
@@ -1,285 +0,0 @@
1
- import { Graphics } from "pixi.js";
2
- import gsap from "gsap";
3
- import { libPixiEvent } from "../../Utils/LibPixiEvent";
4
- import { LibPixiContainer } from "../Base/LibPixiContainer";
5
- /** @description 滑动页
6
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiSlide-滑动页
7
- */
8
- export class LibPixiSlide extends LibPixiContainer {
9
- constructor(params) {
10
- const { stage, width, height, content, depthCallback, slideCallback, scrollCallback, pageWidth = 0, pageHeight = 0, itemList, loop = false, direction, } = params;
11
- super(width, height);
12
- /** 滑动加速度触发翻页 */
13
- this._SPEED_THRESHOLD = 0.35;
14
- /** 滑动比例翻页 */
15
- this._SCROLL_THRESHOLD = 0.5;
16
- /** 一页宽度 */
17
- this._pageWidth = 0;
18
- /** 一页高度 */
19
- this._pageHeight = 0;
20
- /** 是否循环 */
21
- this._loop = false;
22
- /** 两侧预留格数,如可视区有三个,则两侧预留为1 */
23
- this._freeGridNum = 0;
24
- /** 当前幻灯片索引 */
25
- this._currentIndex = 0;
26
- /** 记录拖动开始时的X坐标 */
27
- this._startX = 0;
28
- /** 记录拖动开始时的Y坐标 */
29
- this._startY = 0;
30
- /** 偏移量 */
31
- this._offsetX = 0;
32
- /** 偏移量 */
33
- this._offsetY = 0;
34
- /** 最大索引 */
35
- this._pageNum = 0;
36
- /** 记录开始时间 */
37
- this._startTime = new Date().getTime();
38
- /** 是否正在拖动 */
39
- this._isDragging = false;
40
- this._stage = stage;
41
- const mask = new Graphics();
42
- mask.beginFill(0xffffff);
43
- mask.drawRect(0, 0, this.width, this.height);
44
- mask.endFill();
45
- this.addChild(mask);
46
- this.mask = mask;
47
- this._direction = direction;
48
- this._pageWidth = pageWidth;
49
- this._pageHeight = pageHeight;
50
- this._slideArea = content;
51
- this._itemList = itemList;
52
- this._loop = loop;
53
- this._depthCallback = depthCallback;
54
- this._slideCallback = slideCallback;
55
- this._scrollCallback = scrollCallback;
56
- this._pageNum = itemList.length;
57
- this.addChild(this._slideArea);
58
- if (this._direction === "x") {
59
- this._freeGridNum = Math.floor(width / this._pageWidth / 2);
60
- this._slideArea.x = this._pageWidth * this._freeGridNum;
61
- }
62
- else {
63
- this._freeGridNum = Math.floor(height / pageHeight / 2);
64
- this._slideArea.y = this._pageHeight * this._freeGridNum;
65
- }
66
- this.eventMode = "static";
67
- this.cursor = "pointer";
68
- this._setDepth();
69
- libPixiEvent(this, "pointerdown", this._onDragStart.bind(this));
70
- libPixiEvent(stage, "pointermove", this._onDragMove.bind(this));
71
- libPixiEvent(stage, "pointerup", this._onDragEnd.bind(this));
72
- }
73
- /** @description 更新坐标 */
74
- updatePosition(v, index) {
75
- this._currentIndex = index;
76
- this._setDepth();
77
- if (this._direction === "x") {
78
- this._slideArea.x = v;
79
- }
80
- else {
81
- this._slideArea.y = v;
82
- }
83
- }
84
- /** @description 上一页 */
85
- prev() {
86
- this.slideTo(this._currentIndex - 1);
87
- }
88
- /** @description 下一页 */
89
- next() {
90
- this.slideTo(this._currentIndex + 1);
91
- }
92
- /** @description 滑动到指定索引 */
93
- slideTo(index) {
94
- var _a;
95
- this._currentIndex = index;
96
- //首尾限制
97
- if (this._currentIndex < 0) {
98
- if (this._loop) {
99
- this._currentIndex = this._pageNum - 1;
100
- }
101
- else {
102
- this._currentIndex = 0;
103
- }
104
- }
105
- else if (this._currentIndex >= this._pageNum) {
106
- this._currentIndex = this._pageNum;
107
- if (this._loop) {
108
- this._currentIndex = 0;
109
- }
110
- else {
111
- this._currentIndex--;
112
- }
113
- }
114
- if (this._direction === "x") {
115
- gsap.to(this._slideArea, {
116
- x: -this._currentIndex * this._pageWidth +
117
- this._pageWidth * this._freeGridNum,
118
- duration: 0.25,
119
- onUpdate: () => {
120
- this._onScroll();
121
- },
122
- });
123
- }
124
- else {
125
- gsap.to(this._slideArea, {
126
- y: -this._currentIndex * this._pageHeight +
127
- this._pageHeight * this._freeGridNum,
128
- duration: 0.25,
129
- onUpdate: () => {
130
- this._onScroll();
131
- },
132
- });
133
- }
134
- // 触发滑动结束回调
135
- (_a = this._slideCallback) === null || _a === void 0 ? void 0 : _a.call(this, this._currentIndex);
136
- }
137
- /** @description 设置滚动景深 */
138
- _setDepth() {
139
- if (!this._depthCallback)
140
- return;
141
- let t = 0;
142
- let currentIndex = 0;
143
- if (this._direction === "x") {
144
- const x = this._slideArea.x;
145
- const startX = this._freeGridNum * this._pageWidth;
146
- //设置起始位置,获取当前绝对坐标
147
- const absX = Math.abs(x - startX);
148
- // 根据滑动宽度计算出当前位置对应的索引
149
- currentIndex = Math.floor(absX / this._pageWidth);
150
- // 计算当前索引在一页中的比例,越靠近当前索引的x坐标,值越小,范围0-1
151
- t = (absX % this._pageWidth) / this._pageWidth;
152
- //如果在起点的时候还在向左滑,则取反,避免distance显示效果计算错误
153
- if (x - startX > 0) {
154
- t = -t;
155
- currentIndex = -currentIndex;
156
- }
157
- }
158
- else {
159
- const y = this._slideArea.y;
160
- const startY = this._freeGridNum * this._pageHeight;
161
- //设置起始位置,获取当前绝对坐标
162
- const absY = Math.abs(y - startY);
163
- // 根据滑动宽度计算出当前位置对应的索引
164
- currentIndex = Math.floor(absY / this._pageHeight);
165
- // 计算当前索引在一页中的比例,越靠近当前索引的x坐标,值越小,范围0-1
166
- t = (absY % this._pageHeight) / this._pageHeight;
167
- //如果在起点的时候还在向左滑,则取反,避免distance显示效果计算错误
168
- if (y - startY > 0) {
169
- t = -t;
170
- currentIndex = -currentIndex;
171
- }
172
- }
173
- this._itemList.forEach((item, i) => {
174
- var _a;
175
- // 计算当前项与目标索引之间的索引距离
176
- const distance = Math.abs(i - currentIndex - t);
177
- (_a = this._depthCallback) === null || _a === void 0 ? void 0 : _a.call(this, item, (depthAtten) => {
178
- return Math.max(0, 1 - distance * depthAtten);
179
- });
180
- });
181
- }
182
- /** @description 开始拖动 */
183
- _onDragStart(event) {
184
- const { x, y } = this._stage.toLocal(event.global);
185
- this._isDragging = true;
186
- gsap.killTweensOf(this._slideArea);
187
- this._startTime = new Date().getTime();
188
- if (this._direction === "x") {
189
- this._startX = x;
190
- this._offsetX = this._slideArea.x;
191
- }
192
- else {
193
- this._startY = y;
194
- this._offsetY = this._slideArea.y;
195
- }
196
- }
197
- /** @description 拖动中 */
198
- _onDragMove(event) {
199
- if (!this._isDragging)
200
- return;
201
- const { x, y } = this._stage.toLocal(event.global);
202
- if (this._direction === "x") {
203
- const moveX = x - this._startX;
204
- this._slideArea.x = this._offsetX + moveX;
205
- }
206
- else {
207
- const moveY = y - this._startY;
208
- this._slideArea.y = this._offsetY + moveY;
209
- }
210
- this._onScroll();
211
- }
212
- /** @description 滚动触发 */
213
- _onScroll() {
214
- var _a, _b;
215
- this._setDepth();
216
- if (this._direction === "x") {
217
- (_a = this._scrollCallback) === null || _a === void 0 ? void 0 : _a.call(this, this._slideArea.x, this._currentIndex);
218
- }
219
- else {
220
- (_b = this._scrollCallback) === null || _b === void 0 ? void 0 : _b.call(this, this._slideArea.y, this._currentIndex);
221
- }
222
- }
223
- /** @description 结束拖动 */
224
- _onDragEnd(event) {
225
- const { x, y } = this._stage.toLocal(event.global);
226
- if (this._direction === "x") {
227
- if (!this._isDragging)
228
- return;
229
- this._isDragging = false;
230
- //滑动耗时
231
- const slideTime = new Date().getTime() - this._startTime;
232
- //滑动距离
233
- const slide = this._startX - x;
234
- //滑动速度
235
- const slideSpeed = Math.abs(slide) / slideTime;
236
- //要滑动的页数
237
- const pageChange = Math.round(slide / this._pageWidth);
238
- //如果滑动超过阈值,则翻页
239
- if (Math.abs(slide) > this._pageWidth * this._SCROLL_THRESHOLD) {
240
- this._currentIndex += pageChange;
241
- }
242
- //如果滑动速度大于阈值,则翻页
243
- else if (slideSpeed > this._SPEED_THRESHOLD) {
244
- let addIndex = slide / this._pageWidth;
245
- if (addIndex > 0) {
246
- addIndex = Math.ceil(addIndex);
247
- }
248
- else {
249
- addIndex = Math.floor(addIndex);
250
- }
251
- this._currentIndex += addIndex;
252
- }
253
- this.slideTo(this._currentIndex);
254
- }
255
- else {
256
- if (!this._isDragging)
257
- return;
258
- this._isDragging = false;
259
- //滑动耗时
260
- const slideTime = new Date().getTime() - this._startTime;
261
- //滑动距离
262
- const slide = this._startY - y;
263
- //滑动速度
264
- const slideSpeed = Math.abs(slide) / slideTime;
265
- //要滑动的页数
266
- const pageChange = Math.round(slide / this._pageHeight);
267
- //如果滑动超过阈值,则翻页
268
- if (Math.abs(slide) > this._pageHeight * this._SCROLL_THRESHOLD) {
269
- this._currentIndex += pageChange;
270
- }
271
- //如果滑动速度大于阈值,则翻页
272
- else if (slideSpeed > this._SPEED_THRESHOLD) {
273
- let addIndex = slide / this._pageHeight;
274
- if (addIndex > 0) {
275
- addIndex = Math.ceil(addIndex);
276
- }
277
- else {
278
- addIndex = Math.floor(addIndex);
279
- }
280
- this._currentIndex += addIndex;
281
- }
282
- this.slideTo(this._currentIndex);
283
- }
284
- }
285
- }
@@ -1,82 +0,0 @@
1
- import { Container } from "pixi.js";
2
- import { LibPixiContainer } from "../Base/LibPixiContainer";
3
- interface LibPixiSliderParams {
4
- /** 滑动区域宽度 */
5
- width: number;
6
- /** 滑动区域高度 */
7
- height: number;
8
- /** 滑动页列表 */
9
- slideList: Container[];
10
- /** 是否启用循环滑动 */
11
- loop?: boolean;
12
- /** 是否启用景深 */
13
- enableDepth?: boolean;
14
- /** 景深透明度 */
15
- depthAlpha?: number;
16
- /** 景深缩放 */
17
- depthScale?: number;
18
- /** 滑动回调 */
19
- slideCallback: (pageIndex: number, _pageNum: number) => void;
20
- }
21
- /** @description 类似轮播图,但是不会自动轮播
22
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiSlider-横向滑动图
23
- */
24
- export declare class LibPixiSlider extends LibPixiContainer {
25
- /** 当前幻灯片索引 */
26
- private _currentIndex;
27
- /** 滑动区域宽度 */
28
- private _slideWidth;
29
- /** 滑动区域高度 */
30
- private _slideHeight;
31
- /** 是否启用循环 */
32
- private _loop;
33
- /** 记录拖动开始时的X坐标 */
34
- private _startX;
35
- /** 偏移量 */
36
- private _offsetX;
37
- /** 最大索引 */
38
- private _pageNum;
39
- /** 记录开始时间 */
40
- private _startTime;
41
- private _isDragging;
42
- /** 滑动内容 */
43
- private _slideArea;
44
- /** 是否启用景深 */
45
- private _enableDepth;
46
- /** 景深透明度 */
47
- private _depthAlpha;
48
- /** 景深缩放 */
49
- private _depthScale;
50
- /** 滑动容器列表 */
51
- private _slideList;
52
- /** @description 滑动回调 */
53
- private slideCallback;
54
- /**
55
- * @param width 宽度
56
- * @param height 高度
57
- * @param content 内容
58
- * @param slideCallback 滑动结束回调
59
- */
60
- constructor(params: LibPixiSliderParams);
61
- /** @description 上一页 */
62
- prev(): void;
63
- /** @description 下一页 */
64
- next(): void;
65
- /** @description 滑动到指定索引
66
- * @param index 索引
67
- */
68
- private _slideTo;
69
- /** @description 开始拖动 */
70
- private _onDragStart;
71
- /** @description 拖动中 */
72
- private _onDragMove;
73
- /** @description 结束拖动 */
74
- private _onDragEnd;
75
- /** @description 设置滚动景深
76
- * @param containerList 元素列表
77
- * @param y 拖动Y坐标
78
- * @param startY 内部将y - startY进行计算
79
- */
80
- private _setDepth;
81
- }
82
- export {};
@@ -1,165 +0,0 @@
1
- import { Container } from "pixi.js";
2
- import gsap from "gsap";
3
- import { LibJsLerp } from "lyb-js/Math/LibJsLerp.js";
4
- import { libPixiOverflowHidden } from "../../Utils/LibPixiOverflowHidden";
5
- import { LibPixiContainer } from "../Base/LibPixiContainer";
6
- import { libPixiEvent } from "../../Utils/LibPixiEvent";
7
- /** @description 类似轮播图,但是不会自动轮播
8
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiSlider-横向滑动图
9
- */
10
- export class LibPixiSlider extends LibPixiContainer {
11
- /**
12
- * @param width 宽度
13
- * @param height 高度
14
- * @param content 内容
15
- * @param slideCallback 滑动结束回调
16
- */
17
- constructor(params) {
18
- const { width, height, slideList, slideCallback, loop = false, enableDepth = false, depthAlpha = 0.5, depthScale = 0.5, } = params;
19
- super(width, height);
20
- /** 当前幻灯片索引 */
21
- this._currentIndex = 0;
22
- /** 滑动区域宽度 */
23
- this._slideWidth = 0;
24
- /** 滑动区域高度 */
25
- this._slideHeight = 0;
26
- /** 是否启用循环 */
27
- this._loop = false;
28
- /** 记录拖动开始时的X坐标 */
29
- this._startX = 0;
30
- /** 偏移量 */
31
- this._offsetX = 0;
32
- /** 最大索引 */
33
- this._pageNum = 0;
34
- /** 记录开始时间 */
35
- this._startTime = new Date().getTime();
36
- /* 是否正在拖动 */
37
- this._isDragging = false;
38
- libPixiOverflowHidden(this);
39
- this._slideArea = new Container();
40
- this._slideWidth = width;
41
- this._slideHeight = height;
42
- this._loop = loop;
43
- this._slideList = slideList;
44
- this._enableDepth = enableDepth;
45
- this._depthAlpha = depthAlpha;
46
- this._depthScale = depthScale;
47
- this.slideCallback = slideCallback;
48
- this._pageNum = slideList.length - 1;
49
- this._slideList.forEach((item, index) => {
50
- this._slideArea.addChild(item);
51
- item.x = index * width + this._slideWidth / 2;
52
- item.y = this._slideHeight / 2;
53
- item.pivot.set(this._slideWidth / 2, this._slideHeight / 2);
54
- });
55
- this.addChild(this._slideArea);
56
- libPixiEvent(this, "pointerdown", this._onDragStart.bind(this));
57
- window.addEventListener("pointermove", this._onDragMove.bind(this));
58
- window.addEventListener("pointerup", this._onDragEnd.bind(this));
59
- }
60
- /** @description 上一页 */
61
- prev() {
62
- this._slideTo(this._currentIndex - 1);
63
- }
64
- /** @description 下一页 */
65
- next() {
66
- this._slideTo(this._currentIndex + 1);
67
- }
68
- /** @description 滑动到指定索引
69
- * @param index 索引
70
- */
71
- _slideTo(index) {
72
- let x = 0;
73
- if (this._loop) {
74
- this._currentIndex =
75
- (index + this._slideList.length) % this._slideList.length;
76
- x = -this._currentIndex * this._slideWidth;
77
- }
78
- else {
79
- if (index < 0) {
80
- // 回弹到第一张
81
- x = 0;
82
- this._currentIndex = 0;
83
- }
84
- else if (index > this._pageNum) {
85
- // 回弹到最后一张
86
- x = -this._pageNum * this._slideWidth;
87
- this._currentIndex = this._pageNum;
88
- }
89
- else {
90
- // 正常滑动
91
- x = -index * this._slideWidth;
92
- this._currentIndex = index;
93
- }
94
- }
95
- gsap.to(this._slideArea, {
96
- x,
97
- duration: 0.25,
98
- onUpdate: () => {
99
- this._setDepth();
100
- },
101
- });
102
- this.slideCallback(this._currentIndex, this._pageNum);
103
- }
104
- /** @description 开始拖动 */
105
- _onDragStart(event) {
106
- this._isDragging = true;
107
- this._startX = event.global.x;
108
- this._offsetX = this._slideArea.x;
109
- gsap.killTweensOf(this._slideArea);
110
- this._startTime = new Date().getTime();
111
- }
112
- /** @description 拖动中 */
113
- _onDragMove(event) {
114
- if (!this._isDragging)
115
- return;
116
- const moveX = event.pageX - this._startX;
117
- this._slideArea.x = this._offsetX + moveX;
118
- this._setDepth();
119
- }
120
- /** @description 结束拖动 */
121
- _onDragEnd(event) {
122
- if (!this._isDragging)
123
- return;
124
- this._isDragging = false;
125
- const endTime = new Date().getTime() - this._startTime;
126
- const slide = this._startX - event.pageX;
127
- const slideSpeed = Math.abs(slide) / endTime;
128
- //滑动距离阈值,滑动到一半以上必定翻页
129
- const slideThreshold = this._slideWidth / 2;
130
- //滑动速度阈值,滑动速度大于这个值,必定翻页
131
- const speedThreshold = 0.275;
132
- //如果滑动距离大于阈值,或速度大于阈值翻页
133
- if (Math.abs(slide) > slideThreshold || slideSpeed > speedThreshold) {
134
- slide > 0 ? this._currentIndex++ : this._currentIndex--;
135
- }
136
- this._slideTo(this._currentIndex);
137
- }
138
- /** @description 设置滚动景深
139
- * @param containerList 元素列表
140
- * @param y 拖动Y坐标
141
- * @param startY 内部将y - startY进行计算
142
- */
143
- _setDepth() {
144
- if (!this._enableDepth)
145
- return;
146
- const Y = this._slideArea.x;
147
- const idx = Math.floor(Math.abs(Y) / this._slideWidth);
148
- const t = (Math.abs(Y) % this._slideWidth) / this._slideWidth;
149
- const prevIdx = idx - 1;
150
- const nextIdx = idx + 1;
151
- const curItem = this._slideList[idx];
152
- curItem.alpha = LibJsLerp(this._depthAlpha, 1, 1 - t);
153
- curItem.scale.set(LibJsLerp(this._depthScale, 1, 1 - t));
154
- if (nextIdx < this._slideList.length) {
155
- const nextItem = this._slideList[nextIdx];
156
- nextItem.alpha = LibJsLerp(this._depthAlpha, 1, t);
157
- nextItem.scale.set(LibJsLerp(this._depthScale, 1, t));
158
- }
159
- if (prevIdx >= 0) {
160
- const prevItem = this._slideList[prevIdx];
161
- prevItem.alpha = LibJsLerp(this._depthAlpha, 1, 1 - t);
162
- prevItem.scale.set(LibJsLerp(this._depthScale, 1, 1 - t));
163
- }
164
- }
165
- }
@@ -1,40 +0,0 @@
1
- export interface LibPixiSubAddMinMaxParams {
2
- /** 初始下注索引 */
3
- initialBetIndex: number;
4
- /** 下注金额列表 */
5
- betAmountListLength: number;
6
- /** 金额更新回调
7
- * @param index 金额索引
8
- */
9
- onAmountIndex: (index: number) => void;
10
- /** 按钮置灰状态回调
11
- * @param type 被置灰的按钮类型
12
- */
13
- onDisabled: (type?: "min" | "max") => void;
14
- }
15
- /** @description 最小、最大按钮和增减按钮功能及置灰逻辑
16
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiSubAddMinMax-数字控制器
17
- */
18
- export declare class LibPixiSubAddMinMax {
19
- /** 步进器 */
20
- private _baseNumSteper;
21
- /** 金额列表数量 */
22
- private _betAmountListLength;
23
- /** 金额更新回调 */
24
- private _onAmountIndex;
25
- /** 按钮置灰状态回调 */
26
- private _onDisabled;
27
- constructor(params: LibPixiSubAddMinMaxParams);
28
- /** @description 点击最小按钮 */
29
- min(): void;
30
- /** @description 点击最大按钮 */
31
- max(): void;
32
- /** @description 点击减少按钮 */
33
- sub(): void;
34
- /** @description 点击增加按钮 */
35
- add(): void;
36
- /** @description 改变最小最大按钮状态及回调
37
- * @param index 索引
38
- */
39
- minMaxUpdateIndex(index: number): void;
40
- }