lyb-pixi-js 1.8.1 → 1.8.3
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.
|
@@ -7,6 +7,14 @@ export interface LibPixiScrollContainerYParams {
|
|
|
7
7
|
height: number;
|
|
8
8
|
/** 滚动内容 */
|
|
9
9
|
scrollContent: Container;
|
|
10
|
+
/** 是否需要滚动条 */
|
|
11
|
+
scrollbar?: boolean;
|
|
12
|
+
/** 滚动靠右坐标 */
|
|
13
|
+
scrollbarRgiht?: number;
|
|
14
|
+
/** 滚动条宽度 */
|
|
15
|
+
scrollbarWidth?: number;
|
|
16
|
+
/** 滚动条颜色 */
|
|
17
|
+
scrollbarColor?: string;
|
|
10
18
|
}
|
|
11
19
|
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
12
20
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y轴滚动容器
|
|
@@ -24,12 +32,20 @@ export declare class LibPixiScrollContainerY extends LibPixiContainer {
|
|
|
24
32
|
private _scrollSpeed;
|
|
25
33
|
/** 是否处于拖动状态 */
|
|
26
34
|
private _isDragging;
|
|
35
|
+
/** 是否处于滚动状态 */
|
|
36
|
+
private _scrollbarDragging;
|
|
37
|
+
/** 滚动条拖动偏移量 */
|
|
38
|
+
private _scrollbarDragOffset;
|
|
27
39
|
/** 滚动容器 */
|
|
28
40
|
_scrollContent: Container;
|
|
29
41
|
/** 遮罩 */
|
|
30
42
|
private _maskGraphics;
|
|
31
43
|
/** 滚动的内容 */
|
|
32
44
|
private _content;
|
|
45
|
+
/** 滚动条 */
|
|
46
|
+
private _scrollbar;
|
|
47
|
+
/** 滚动条颜色 */
|
|
48
|
+
private _scrollbarColor;
|
|
33
49
|
constructor(params: LibPixiScrollContainerYParams);
|
|
34
50
|
/** @description 设置滚动容器可视区宽高
|
|
35
51
|
* @param width 宽度
|
|
@@ -52,4 +68,12 @@ export declare class LibPixiScrollContainerY extends LibPixiContainer {
|
|
|
52
68
|
private _applyInertia;
|
|
53
69
|
/** @description 限制滚动范围 */
|
|
54
70
|
private _limitScrollRange;
|
|
71
|
+
/** @description 更新滚动位置 */
|
|
72
|
+
private _updateScrollbar;
|
|
73
|
+
/** @description 滚动条按下 */
|
|
74
|
+
private _onScrollbarDragStart;
|
|
75
|
+
/** @description 滚动条移动 */
|
|
76
|
+
private _onScrollbarDragMove;
|
|
77
|
+
/** @description 滚动条松开 */
|
|
78
|
+
private _onScrollbarDragEnd;
|
|
55
79
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { Container
|
|
2
|
-
import {
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
import { libPixiEvent } from "../../Utils/LibPixiEvent";
|
|
3
3
|
import { LibPixiContainer } from "../Base/LibPixiContainer";
|
|
4
|
+
import { LibPixiRectangle } from "../Base/LibPixiRectangle";
|
|
5
|
+
import { gsap } from "gsap";
|
|
4
6
|
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
5
7
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y轴滚动容器
|
|
6
8
|
*/
|
|
7
9
|
export class LibPixiScrollContainerY extends LibPixiContainer {
|
|
8
10
|
constructor(params) {
|
|
9
|
-
const { width, height, scrollContent } = params;
|
|
11
|
+
const { width, height, scrollbar = false, scrollContent, scrollbarRgiht, scrollbarWidth = 10, scrollbarColor = "#F8A500", } = params;
|
|
10
12
|
super(width, height);
|
|
11
13
|
/** 开始位置 */
|
|
12
14
|
this._startY = 0;
|
|
@@ -20,26 +22,47 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
|
|
|
20
22
|
this._scrollSpeed = 200;
|
|
21
23
|
/** 是否处于拖动状态 */
|
|
22
24
|
this._isDragging = false;
|
|
25
|
+
/** 是否处于滚动状态 */
|
|
26
|
+
this._scrollbarDragging = false;
|
|
27
|
+
/** 滚动条拖动偏移量 */
|
|
28
|
+
this._scrollbarDragOffset = 0;
|
|
23
29
|
this._scrollContent = scrollContent;
|
|
30
|
+
this._scrollbarColor = scrollbarColor;
|
|
24
31
|
// 创建内容容器
|
|
25
32
|
this._content = new Container();
|
|
26
33
|
this.addChild(this._content);
|
|
27
34
|
this._content.addChild(this._scrollContent);
|
|
28
35
|
// 创建遮罩
|
|
29
|
-
this._maskGraphics = new
|
|
36
|
+
this._maskGraphics = new LibPixiRectangle(width, height, "#000");
|
|
30
37
|
this.addChild(this._maskGraphics);
|
|
31
|
-
this._maskGraphics.clear();
|
|
32
|
-
this._maskGraphics.beginFill(0x000000);
|
|
33
|
-
this._maskGraphics.drawRect(0, 0, width, height);
|
|
34
|
-
this._maskGraphics.endFill();
|
|
35
38
|
this.mask = this._maskGraphics;
|
|
39
|
+
// 创建滚动条
|
|
40
|
+
this._scrollbar = new LibPixiRectangle(scrollbarWidth, height, this._scrollbarColor);
|
|
41
|
+
this._scrollbar.x = width - (scrollbarRgiht || scrollbarWidth);
|
|
42
|
+
this.addChild(this._scrollbar);
|
|
43
|
+
this._scrollbar.visible = scrollbar;
|
|
44
|
+
this._updateScrollbar();
|
|
45
|
+
libPixiEvent(this._scrollbar, "pointerdown", this._onScrollbarDragStart.bind(this));
|
|
36
46
|
// 添加事件监听
|
|
37
47
|
this.eventMode = "static";
|
|
38
48
|
this.on("pointerdown", this._onDragStart, this);
|
|
39
|
-
this
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this
|
|
49
|
+
libPixiEvent(this, "pointerdown", (event) => {
|
|
50
|
+
this._onDragStart(event);
|
|
51
|
+
});
|
|
52
|
+
libPixiEvent(this, "pointermove", (event) => {
|
|
53
|
+
this._onScrollbarDragMove(event);
|
|
54
|
+
this._onDragMove(event);
|
|
55
|
+
});
|
|
56
|
+
libPixiEvent(this, "pointerup", (event) => {
|
|
57
|
+
this._onScrollbarDragEnd(event);
|
|
58
|
+
this._onDragEnd();
|
|
59
|
+
});
|
|
60
|
+
libPixiEvent(this, "wheel", (event) => {
|
|
61
|
+
this._onWheelScroll(event);
|
|
62
|
+
});
|
|
63
|
+
libPixiEvent(this, "pointerupoutside", () => {
|
|
64
|
+
this._onDragEnd();
|
|
65
|
+
});
|
|
43
66
|
}
|
|
44
67
|
/** @description 设置滚动容器可视区宽高
|
|
45
68
|
* @param width 宽度
|
|
@@ -81,10 +104,12 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
|
|
|
81
104
|
const newPosition = position.y - this._startY;
|
|
82
105
|
this._content.y = newPosition;
|
|
83
106
|
}
|
|
107
|
+
this._updateScrollbar();
|
|
84
108
|
}
|
|
85
109
|
/** @description 拖动结束 */
|
|
86
110
|
_onDragEnd() {
|
|
87
111
|
this._isDragging = false;
|
|
112
|
+
this._scrollbarDragging = false;
|
|
88
113
|
const currentTime = Date.now();
|
|
89
114
|
const deltaTime = currentTime - this._startTime; // 计算停留时间
|
|
90
115
|
if (deltaTime < 250) {
|
|
@@ -116,6 +141,9 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
|
|
|
116
141
|
duration: 0.25,
|
|
117
142
|
ease: "power1.out",
|
|
118
143
|
y,
|
|
144
|
+
onUpdate: () => {
|
|
145
|
+
this._updateScrollbar();
|
|
146
|
+
},
|
|
119
147
|
});
|
|
120
148
|
}
|
|
121
149
|
/** @description 惯性动画 */
|
|
@@ -124,7 +152,10 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
|
|
|
124
152
|
y: this._content.y + this._velocity * 250,
|
|
125
153
|
duration: 0.5,
|
|
126
154
|
ease: "power1.out",
|
|
127
|
-
onUpdate:
|
|
155
|
+
onUpdate: () => {
|
|
156
|
+
this._limitScrollRange();
|
|
157
|
+
this._updateScrollbar();
|
|
158
|
+
},
|
|
128
159
|
});
|
|
129
160
|
}
|
|
130
161
|
/** @description 限制滚动范围 */
|
|
@@ -135,6 +166,9 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
|
|
|
135
166
|
duration: 0.75,
|
|
136
167
|
y: 0,
|
|
137
168
|
ease: "elastic.out",
|
|
169
|
+
onUpdate: () => {
|
|
170
|
+
this._updateScrollbar();
|
|
171
|
+
},
|
|
138
172
|
});
|
|
139
173
|
}
|
|
140
174
|
// 如果滚动距离大于内容高度减去遮罩高度
|
|
@@ -147,6 +181,9 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
|
|
|
147
181
|
duration: 0.75,
|
|
148
182
|
y,
|
|
149
183
|
ease: "elastic.out",
|
|
184
|
+
onUpdate: () => {
|
|
185
|
+
this._updateScrollbar();
|
|
186
|
+
},
|
|
150
187
|
});
|
|
151
188
|
}
|
|
152
189
|
// 否则静止不动
|
|
@@ -154,8 +191,59 @@ export class LibPixiScrollContainerY extends LibPixiContainer {
|
|
|
154
191
|
gsap.to(this._content, {
|
|
155
192
|
duration: 0.25,
|
|
156
193
|
y: 0,
|
|
194
|
+
onUpdate: () => {
|
|
195
|
+
this._updateScrollbar();
|
|
196
|
+
},
|
|
157
197
|
});
|
|
158
198
|
}
|
|
159
199
|
}
|
|
160
200
|
}
|
|
201
|
+
/** @description 更新滚动位置 */
|
|
202
|
+
_updateScrollbar() {
|
|
203
|
+
const viewHeight = this._maskGraphics.height;
|
|
204
|
+
const contentHeight = this._content.height;
|
|
205
|
+
if (contentHeight <= viewHeight) {
|
|
206
|
+
this._scrollbar.visible = false;
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
this._scrollbar.visible = true;
|
|
210
|
+
const ratio = viewHeight / contentHeight;
|
|
211
|
+
const barHeight = viewHeight * ratio;
|
|
212
|
+
const maxScrollY = contentHeight - viewHeight;
|
|
213
|
+
const scrollY = Math.min(Math.max(-this._content.y, 0), maxScrollY);
|
|
214
|
+
const barY = (scrollY / maxScrollY) * (viewHeight - barHeight);
|
|
215
|
+
this._scrollbar.clear();
|
|
216
|
+
this._scrollbar.beginFill(this._scrollbarColor);
|
|
217
|
+
this._scrollbar.drawRect(0, 0, 10, barHeight);
|
|
218
|
+
this._scrollbar.endFill();
|
|
219
|
+
this._scrollbar.y = barY;
|
|
220
|
+
}
|
|
221
|
+
/** @description 滚动条按下 */
|
|
222
|
+
_onScrollbarDragStart(event) {
|
|
223
|
+
event.stopPropagation();
|
|
224
|
+
this._scrollbarDragging = true;
|
|
225
|
+
this._scrollbarDragOffset = event.getLocalPosition(this._scrollbar).y;
|
|
226
|
+
gsap.killTweensOf(this._content);
|
|
227
|
+
}
|
|
228
|
+
/** @description 滚动条移动 */
|
|
229
|
+
_onScrollbarDragMove(event) {
|
|
230
|
+
event.stopPropagation();
|
|
231
|
+
if (!this._scrollbarDragging)
|
|
232
|
+
return;
|
|
233
|
+
const localY = event.getLocalPosition(this).y;
|
|
234
|
+
const viewHeight = this._maskGraphics.height;
|
|
235
|
+
const contentHeight = this._content.height;
|
|
236
|
+
const ratio = viewHeight / contentHeight;
|
|
237
|
+
const barHeight = viewHeight * ratio;
|
|
238
|
+
const maxBarY = viewHeight - barHeight;
|
|
239
|
+
const newBarY = Math.min(Math.max(localY - this._scrollbarDragOffset, 0), maxBarY);
|
|
240
|
+
const scrollY = (newBarY / maxBarY) * (contentHeight - viewHeight);
|
|
241
|
+
this._content.y = -scrollY;
|
|
242
|
+
this._updateScrollbar();
|
|
243
|
+
}
|
|
244
|
+
/** @description 滚动条松开 */
|
|
245
|
+
_onScrollbarDragEnd(event) {
|
|
246
|
+
event.stopPropagation();
|
|
247
|
+
this._scrollbarDragging = false;
|
|
248
|
+
}
|
|
161
249
|
}
|
package/lyb-pixi.js
CHANGED
|
@@ -49245,9 +49245,28 @@ void main(void)\r
|
|
|
49245
49245
|
}
|
|
49246
49246
|
}
|
|
49247
49247
|
}
|
|
49248
|
+
class LibPixiRectangle extends Graphics {
|
|
49249
|
+
constructor(width, height, color) {
|
|
49250
|
+
super();
|
|
49251
|
+
this.beginFill(color || 0);
|
|
49252
|
+
this.drawRect(0, 0, width, height);
|
|
49253
|
+
this.endFill();
|
|
49254
|
+
if (!color) {
|
|
49255
|
+
this.alpha = 0;
|
|
49256
|
+
}
|
|
49257
|
+
}
|
|
49258
|
+
}
|
|
49248
49259
|
class LibPixiScrollContainerY extends LibPixiContainer {
|
|
49249
49260
|
constructor(params) {
|
|
49250
|
-
const {
|
|
49261
|
+
const {
|
|
49262
|
+
width,
|
|
49263
|
+
height,
|
|
49264
|
+
scrollbar = false,
|
|
49265
|
+
scrollContent,
|
|
49266
|
+
scrollbarRgiht,
|
|
49267
|
+
scrollbarWidth = 10,
|
|
49268
|
+
scrollbarColor = "#F8A500"
|
|
49269
|
+
} = params;
|
|
49251
49270
|
super(width, height);
|
|
49252
49271
|
this._startY = 0;
|
|
49253
49272
|
this._velocity = 0;
|
|
@@ -49255,23 +49274,49 @@ void main(void)\r
|
|
|
49255
49274
|
this._startPosition = 0;
|
|
49256
49275
|
this._scrollSpeed = 200;
|
|
49257
49276
|
this._isDragging = false;
|
|
49277
|
+
this._scrollbarDragging = false;
|
|
49278
|
+
this._scrollbarDragOffset = 0;
|
|
49258
49279
|
this._scrollContent = scrollContent;
|
|
49280
|
+
this._scrollbarColor = scrollbarColor;
|
|
49259
49281
|
this._content = new Container();
|
|
49260
49282
|
this.addChild(this._content);
|
|
49261
49283
|
this._content.addChild(this._scrollContent);
|
|
49262
|
-
this._maskGraphics = new
|
|
49284
|
+
this._maskGraphics = new LibPixiRectangle(width, height, "#000");
|
|
49263
49285
|
this.addChild(this._maskGraphics);
|
|
49264
|
-
this._maskGraphics.clear();
|
|
49265
|
-
this._maskGraphics.beginFill(0);
|
|
49266
|
-
this._maskGraphics.drawRect(0, 0, width, height);
|
|
49267
|
-
this._maskGraphics.endFill();
|
|
49268
49286
|
this.mask = this._maskGraphics;
|
|
49287
|
+
this._scrollbar = new LibPixiRectangle(
|
|
49288
|
+
scrollbarWidth,
|
|
49289
|
+
height,
|
|
49290
|
+
this._scrollbarColor
|
|
49291
|
+
);
|
|
49292
|
+
this._scrollbar.x = width - (scrollbarRgiht || scrollbarWidth);
|
|
49293
|
+
this.addChild(this._scrollbar);
|
|
49294
|
+
this._scrollbar.visible = scrollbar;
|
|
49295
|
+
this._updateScrollbar();
|
|
49296
|
+
libPixiEvent(
|
|
49297
|
+
this._scrollbar,
|
|
49298
|
+
"pointerdown",
|
|
49299
|
+
this._onScrollbarDragStart.bind(this)
|
|
49300
|
+
);
|
|
49269
49301
|
this.eventMode = "static";
|
|
49270
49302
|
this.on("pointerdown", this._onDragStart, this);
|
|
49271
|
-
this
|
|
49272
|
-
|
|
49273
|
-
|
|
49274
|
-
this
|
|
49303
|
+
libPixiEvent(this, "pointerdown", (event) => {
|
|
49304
|
+
this._onDragStart(event);
|
|
49305
|
+
});
|
|
49306
|
+
libPixiEvent(this, "pointermove", (event) => {
|
|
49307
|
+
this._onScrollbarDragMove(event);
|
|
49308
|
+
this._onDragMove(event);
|
|
49309
|
+
});
|
|
49310
|
+
libPixiEvent(this, "pointerup", (event) => {
|
|
49311
|
+
this._onScrollbarDragEnd(event);
|
|
49312
|
+
this._onDragEnd();
|
|
49313
|
+
});
|
|
49314
|
+
libPixiEvent(this, "wheel", (event) => {
|
|
49315
|
+
this._onWheelScroll(event);
|
|
49316
|
+
});
|
|
49317
|
+
libPixiEvent(this, "pointerupoutside", () => {
|
|
49318
|
+
this._onDragEnd();
|
|
49319
|
+
});
|
|
49275
49320
|
}
|
|
49276
49321
|
/** @description 设置滚动容器可视区宽高
|
|
49277
49322
|
* @param width 宽度
|
|
@@ -49312,10 +49357,12 @@ void main(void)\r
|
|
|
49312
49357
|
const newPosition = position.y - this._startY;
|
|
49313
49358
|
this._content.y = newPosition;
|
|
49314
49359
|
}
|
|
49360
|
+
this._updateScrollbar();
|
|
49315
49361
|
}
|
|
49316
49362
|
/** @description 拖动结束 */
|
|
49317
49363
|
_onDragEnd() {
|
|
49318
49364
|
this._isDragging = false;
|
|
49365
|
+
this._scrollbarDragging = false;
|
|
49319
49366
|
const currentTime = Date.now();
|
|
49320
49367
|
const deltaTime = currentTime - this._startTime;
|
|
49321
49368
|
if (deltaTime < 250) {
|
|
@@ -49339,7 +49386,10 @@ void main(void)\r
|
|
|
49339
49386
|
gsapWithCSS.to(this._content, {
|
|
49340
49387
|
duration: 0.25,
|
|
49341
49388
|
ease: "power1.out",
|
|
49342
|
-
y: y2
|
|
49389
|
+
y: y2,
|
|
49390
|
+
onUpdate: () => {
|
|
49391
|
+
this._updateScrollbar();
|
|
49392
|
+
}
|
|
49343
49393
|
});
|
|
49344
49394
|
}
|
|
49345
49395
|
/** @description 惯性动画 */
|
|
@@ -49348,7 +49398,10 @@ void main(void)\r
|
|
|
49348
49398
|
y: this._content.y + this._velocity * 250,
|
|
49349
49399
|
duration: 0.5,
|
|
49350
49400
|
ease: "power1.out",
|
|
49351
|
-
onUpdate:
|
|
49401
|
+
onUpdate: () => {
|
|
49402
|
+
this._limitScrollRange();
|
|
49403
|
+
this._updateScrollbar();
|
|
49404
|
+
}
|
|
49352
49405
|
});
|
|
49353
49406
|
}
|
|
49354
49407
|
/** @description 限制滚动范围 */
|
|
@@ -49357,7 +49410,10 @@ void main(void)\r
|
|
|
49357
49410
|
gsapWithCSS.to(this._content, {
|
|
49358
49411
|
duration: 0.75,
|
|
49359
49412
|
y: 0,
|
|
49360
|
-
ease: "elastic.out"
|
|
49413
|
+
ease: "elastic.out",
|
|
49414
|
+
onUpdate: () => {
|
|
49415
|
+
this._updateScrollbar();
|
|
49416
|
+
}
|
|
49361
49417
|
});
|
|
49362
49418
|
} else if (Math.abs(this._content.y) >= this._content.height - this._maskGraphics.height) {
|
|
49363
49419
|
if (this._content.height > this._maskGraphics.height) {
|
|
@@ -49365,16 +49421,73 @@ void main(void)\r
|
|
|
49365
49421
|
gsapWithCSS.to(this._content, {
|
|
49366
49422
|
duration: 0.75,
|
|
49367
49423
|
y: y2,
|
|
49368
|
-
ease: "elastic.out"
|
|
49424
|
+
ease: "elastic.out",
|
|
49425
|
+
onUpdate: () => {
|
|
49426
|
+
this._updateScrollbar();
|
|
49427
|
+
}
|
|
49369
49428
|
});
|
|
49370
49429
|
} else {
|
|
49371
49430
|
gsapWithCSS.to(this._content, {
|
|
49372
49431
|
duration: 0.25,
|
|
49373
|
-
y: 0
|
|
49432
|
+
y: 0,
|
|
49433
|
+
onUpdate: () => {
|
|
49434
|
+
this._updateScrollbar();
|
|
49435
|
+
}
|
|
49374
49436
|
});
|
|
49375
49437
|
}
|
|
49376
49438
|
}
|
|
49377
49439
|
}
|
|
49440
|
+
/** @description 更新滚动位置 */
|
|
49441
|
+
_updateScrollbar() {
|
|
49442
|
+
const viewHeight = this._maskGraphics.height;
|
|
49443
|
+
const contentHeight = this._content.height;
|
|
49444
|
+
if (contentHeight <= viewHeight) {
|
|
49445
|
+
this._scrollbar.visible = false;
|
|
49446
|
+
return;
|
|
49447
|
+
}
|
|
49448
|
+
this._scrollbar.visible = true;
|
|
49449
|
+
const ratio = viewHeight / contentHeight;
|
|
49450
|
+
const barHeight = viewHeight * ratio;
|
|
49451
|
+
const maxScrollY = contentHeight - viewHeight;
|
|
49452
|
+
const scrollY = Math.min(Math.max(-this._content.y, 0), maxScrollY);
|
|
49453
|
+
const barY = scrollY / maxScrollY * (viewHeight - barHeight);
|
|
49454
|
+
this._scrollbar.clear();
|
|
49455
|
+
this._scrollbar.beginFill(this._scrollbarColor);
|
|
49456
|
+
this._scrollbar.drawRect(0, 0, 10, barHeight);
|
|
49457
|
+
this._scrollbar.endFill();
|
|
49458
|
+
this._scrollbar.y = barY;
|
|
49459
|
+
}
|
|
49460
|
+
/** @description 滚动条按下 */
|
|
49461
|
+
_onScrollbarDragStart(event) {
|
|
49462
|
+
event.stopPropagation();
|
|
49463
|
+
this._scrollbarDragging = true;
|
|
49464
|
+
this._scrollbarDragOffset = event.getLocalPosition(this._scrollbar).y;
|
|
49465
|
+
gsapWithCSS.killTweensOf(this._content);
|
|
49466
|
+
}
|
|
49467
|
+
/** @description 滚动条移动 */
|
|
49468
|
+
_onScrollbarDragMove(event) {
|
|
49469
|
+
event.stopPropagation();
|
|
49470
|
+
if (!this._scrollbarDragging)
|
|
49471
|
+
return;
|
|
49472
|
+
const localY = event.getLocalPosition(this).y;
|
|
49473
|
+
const viewHeight = this._maskGraphics.height;
|
|
49474
|
+
const contentHeight = this._content.height;
|
|
49475
|
+
const ratio = viewHeight / contentHeight;
|
|
49476
|
+
const barHeight = viewHeight * ratio;
|
|
49477
|
+
const maxBarY = viewHeight - barHeight;
|
|
49478
|
+
const newBarY = Math.min(
|
|
49479
|
+
Math.max(localY - this._scrollbarDragOffset, 0),
|
|
49480
|
+
maxBarY
|
|
49481
|
+
);
|
|
49482
|
+
const scrollY = newBarY / maxBarY * (contentHeight - viewHeight);
|
|
49483
|
+
this._content.y = -scrollY;
|
|
49484
|
+
this._updateScrollbar();
|
|
49485
|
+
}
|
|
49486
|
+
/** @description 滚动条松开 */
|
|
49487
|
+
_onScrollbarDragEnd(event) {
|
|
49488
|
+
event.stopPropagation();
|
|
49489
|
+
this._scrollbarDragging = false;
|
|
49490
|
+
}
|
|
49378
49491
|
}
|
|
49379
49492
|
const LibJsLerp = (start, end, value) => {
|
|
49380
49493
|
const t2 = Math.min(Math.max(value, 0), 1);
|
|
@@ -54876,17 +54989,6 @@ void main(void){
|
|
|
54876
54989
|
}
|
|
54877
54990
|
}
|
|
54878
54991
|
}
|
|
54879
|
-
class LibPixiRectangle extends Graphics {
|
|
54880
|
-
constructor(width, height, color) {
|
|
54881
|
-
super();
|
|
54882
|
-
this.beginFill(color || 0);
|
|
54883
|
-
this.drawRect(0, 0, width, height);
|
|
54884
|
-
this.endFill();
|
|
54885
|
-
if (!color) {
|
|
54886
|
-
this.alpha = 0;
|
|
54887
|
-
}
|
|
54888
|
-
}
|
|
54889
|
-
}
|
|
54890
54992
|
class LibPixiPolygon extends Graphics {
|
|
54891
54993
|
constructor(points, color) {
|
|
54892
54994
|
super();
|