lyb-pixi-js 1.7.1 → 1.7.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.
- package/Components/Custom/LibPixiScrollContainerX.d.ts +57 -0
- package/Components/Custom/LibPixiScrollContainerX.js +165 -0
- package/Components/Custom/{LibPixiScrollContainer.d.ts → LibPixiScrollContainerY.d.ts} +5 -5
- package/Components/Custom/{LibPixiScrollContainer.js → LibPixiScrollContainerY.js} +3 -3
- package/README.md +38 -24
- package/libPixiJs.d.ts +8 -3
- package/libPixiJs.js +8 -3
- package/lyb-pixi.js +252 -88
- package/package.json +1 -1
- package/Utils/LibPixiEventControlled.d.ts +0 -8
- package/Utils/LibPixiEventControlled.js +0 -21
- package/Utils/LibPixiWatchProperty.d.ts +0 -9
- package/Utils/LibPixiWatchProperty.js +0 -46
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
import { LibPixiContainer } from '../Base/LibPixiContainer';
|
|
3
|
+
export interface LibPixiScrollContainerXParams {
|
|
4
|
+
/** 宽度 */
|
|
5
|
+
width: number;
|
|
6
|
+
/** 高度 */
|
|
7
|
+
height: number;
|
|
8
|
+
/** 滚动内容 */
|
|
9
|
+
scrollContent: Container;
|
|
10
|
+
/** 底部内边距 */
|
|
11
|
+
bottomMargin?: number;
|
|
12
|
+
}
|
|
13
|
+
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
14
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerX-X轴滚动容器
|
|
15
|
+
*/
|
|
16
|
+
export declare class LibPixiScrollContainerX extends LibPixiContainer {
|
|
17
|
+
/** 开始位置 */
|
|
18
|
+
private _startX;
|
|
19
|
+
/** 惯性速度 */
|
|
20
|
+
private _velocity;
|
|
21
|
+
/** 上一次滚动时间 */
|
|
22
|
+
private _startTime;
|
|
23
|
+
/** 开始位置 */
|
|
24
|
+
private _startPosition;
|
|
25
|
+
/** 滚动速度 */
|
|
26
|
+
private _scrollSpeed;
|
|
27
|
+
/** 是否处于拖动状态 */
|
|
28
|
+
private _isDragging;
|
|
29
|
+
/** 滚动容器 */
|
|
30
|
+
_scrollContent: Container;
|
|
31
|
+
/** 遮罩 */
|
|
32
|
+
private _maskGraphics;
|
|
33
|
+
/** 滚动的内容 */
|
|
34
|
+
private _content;
|
|
35
|
+
constructor(params: LibPixiScrollContainerXParams);
|
|
36
|
+
/** @description 设置滚动容器可视区宽高
|
|
37
|
+
* @param width 宽度
|
|
38
|
+
* @param height 高度
|
|
39
|
+
*/
|
|
40
|
+
setDimensions(width: number, height: number): void;
|
|
41
|
+
/** @description 返回顶部 */
|
|
42
|
+
scrollToTop(): void;
|
|
43
|
+
/** @description 往滚动内容添加元素 */
|
|
44
|
+
addContent(container: Container): void;
|
|
45
|
+
/** @description 按下 */
|
|
46
|
+
private _onDragStart;
|
|
47
|
+
/** @description 拖动 */
|
|
48
|
+
private _onDragMove;
|
|
49
|
+
/** @description 拖动结束 */
|
|
50
|
+
private _onDragEnd;
|
|
51
|
+
/** @description 滚轮滚动 */
|
|
52
|
+
private _onWheelScroll;
|
|
53
|
+
/** @description 惯性动画 */
|
|
54
|
+
private _applyInertia;
|
|
55
|
+
/** @description 限制滚动范围 */
|
|
56
|
+
private _limitScrollRange;
|
|
57
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { Container, Graphics, Sprite, } from "pixi.js";
|
|
2
|
+
import { gsap } from "gsap";
|
|
3
|
+
import { LibPixiContainer } from '../Base/LibPixiContainer';
|
|
4
|
+
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
5
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerX-X轴滚动容器
|
|
6
|
+
*/
|
|
7
|
+
export class LibPixiScrollContainerX extends LibPixiContainer {
|
|
8
|
+
constructor(params) {
|
|
9
|
+
const { width, height, scrollContent, bottomMargin = 50 } = params;
|
|
10
|
+
super(width, height);
|
|
11
|
+
/** 开始位置 */
|
|
12
|
+
this._startX = 0;
|
|
13
|
+
/** 惯性速度 */
|
|
14
|
+
this._velocity = 0;
|
|
15
|
+
/** 上一次滚动时间 */
|
|
16
|
+
this._startTime = 0;
|
|
17
|
+
/** 开始位置 */
|
|
18
|
+
this._startPosition = 0;
|
|
19
|
+
/** 滚动速度 */
|
|
20
|
+
this._scrollSpeed = 200;
|
|
21
|
+
/** 是否处于拖动状态 */
|
|
22
|
+
this._isDragging = false;
|
|
23
|
+
this._scrollContent = scrollContent;
|
|
24
|
+
// 创建内容容器
|
|
25
|
+
this._content = new Container();
|
|
26
|
+
this.addChild(this._content);
|
|
27
|
+
this._content.addChild(this._scrollContent);
|
|
28
|
+
// 创建底部占位
|
|
29
|
+
if (bottomMargin > 0) {
|
|
30
|
+
const bottom_box = new Sprite();
|
|
31
|
+
this._content.addChild(bottom_box);
|
|
32
|
+
bottom_box.x = this._content.width + bottomMargin;
|
|
33
|
+
}
|
|
34
|
+
// 创建遮罩
|
|
35
|
+
this._maskGraphics = new Graphics();
|
|
36
|
+
this.addChild(this._maskGraphics);
|
|
37
|
+
this._maskGraphics.clear();
|
|
38
|
+
this._maskGraphics.beginFill(0x000000);
|
|
39
|
+
this._maskGraphics.drawRect(0, 0, width, height);
|
|
40
|
+
this._maskGraphics.endFill();
|
|
41
|
+
this.mask = this._maskGraphics;
|
|
42
|
+
// 添加事件监听
|
|
43
|
+
this.eventMode = "static";
|
|
44
|
+
this.on("pointerdown", this._onDragStart, this);
|
|
45
|
+
this.on("pointermove", this._onDragMove, this);
|
|
46
|
+
this.on("pointerup", this._onDragEnd, this);
|
|
47
|
+
this.on("pointerupoutside", this._onDragEnd, this);
|
|
48
|
+
this.on("wheel", this._onWheelScroll, this);
|
|
49
|
+
}
|
|
50
|
+
/** @description 设置滚动容器可视区宽高
|
|
51
|
+
* @param width 宽度
|
|
52
|
+
* @param height 高度
|
|
53
|
+
*/
|
|
54
|
+
setDimensions(width, height) {
|
|
55
|
+
// 更新遮罩尺寸
|
|
56
|
+
this._maskGraphics.clear();
|
|
57
|
+
this._maskGraphics.beginFill(0x000000);
|
|
58
|
+
this._maskGraphics.drawRect(0, 0, width, height);
|
|
59
|
+
this._maskGraphics.endFill();
|
|
60
|
+
this.setSize(width, height);
|
|
61
|
+
}
|
|
62
|
+
/** @description 返回顶部 */
|
|
63
|
+
scrollToTop() {
|
|
64
|
+
gsap.killTweensOf(this._content);
|
|
65
|
+
this._content.x = 0;
|
|
66
|
+
}
|
|
67
|
+
/** @description 往滚动内容添加元素 */
|
|
68
|
+
addContent(container) {
|
|
69
|
+
this._scrollContent.addChild(container);
|
|
70
|
+
}
|
|
71
|
+
/** @description 按下 */
|
|
72
|
+
_onDragStart(event) {
|
|
73
|
+
if (this._content.width <= this._maskGraphics.width)
|
|
74
|
+
return;
|
|
75
|
+
const position = event.getLocalPosition(this);
|
|
76
|
+
this._startX = position.x - this._content.x;
|
|
77
|
+
this._isDragging = true;
|
|
78
|
+
this._velocity = 0;
|
|
79
|
+
this._startTime = Date.now();
|
|
80
|
+
this._startPosition = this._content.x;
|
|
81
|
+
gsap.killTweensOf(this._content);
|
|
82
|
+
}
|
|
83
|
+
/** @description 拖动 */
|
|
84
|
+
_onDragMove(event) {
|
|
85
|
+
if (this._isDragging) {
|
|
86
|
+
const position = event.getLocalPosition(this);
|
|
87
|
+
const newPosition = position.x - this._startX;
|
|
88
|
+
this._content.x = newPosition;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** @description 拖动结束 */
|
|
92
|
+
_onDragEnd() {
|
|
93
|
+
this._isDragging = false;
|
|
94
|
+
const currentTime = Date.now();
|
|
95
|
+
const deltaTime = currentTime - this._startTime; // 计算停留时间
|
|
96
|
+
if (deltaTime < 250) {
|
|
97
|
+
// 如果停留时间在阈值内,计算惯性速度
|
|
98
|
+
this._velocity = (this._content.x - this._startPosition) / deltaTime;
|
|
99
|
+
this._applyInertia();
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
// 停留时间超出阈值,取消惯性
|
|
103
|
+
this._velocity = 0;
|
|
104
|
+
}
|
|
105
|
+
this._limitScrollRange();
|
|
106
|
+
}
|
|
107
|
+
/** @description 滚轮滚动 */
|
|
108
|
+
_onWheelScroll(event) {
|
|
109
|
+
// 如果内容高度小于遮罩高度,则不滚动
|
|
110
|
+
if (this._content.width <= this._maskGraphics.width)
|
|
111
|
+
return;
|
|
112
|
+
let x = this._content.x - event.deltaY * (this._scrollSpeed / 100);
|
|
113
|
+
if (x > 0) {
|
|
114
|
+
x = 0;
|
|
115
|
+
}
|
|
116
|
+
else if (Math.abs(x) >= this._content.width - this._maskGraphics.width) {
|
|
117
|
+
x = -(this._content.width - this._maskGraphics.width);
|
|
118
|
+
}
|
|
119
|
+
gsap.to(this._content, {
|
|
120
|
+
duration: 0.25,
|
|
121
|
+
ease: "power1.out",
|
|
122
|
+
x,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/** @description 惯性动画 */
|
|
126
|
+
_applyInertia() {
|
|
127
|
+
gsap.to(this._content, {
|
|
128
|
+
x: this._content.x + this._velocity * 250,
|
|
129
|
+
duration: 0.5,
|
|
130
|
+
ease: "power1.out",
|
|
131
|
+
onUpdate: this._limitScrollRange.bind(this),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/** @description 限制滚动范围 */
|
|
135
|
+
_limitScrollRange() {
|
|
136
|
+
//如果内容顶部离开了滚动容器顶部,则归位
|
|
137
|
+
if (this._content.x > 0) {
|
|
138
|
+
gsap.to(this._content, {
|
|
139
|
+
duration: 0.75,
|
|
140
|
+
x: 0,
|
|
141
|
+
ease: "elastic.out",
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
// 如果滚动距离大于内容高度减去遮罩高度
|
|
145
|
+
else if (Math.abs(this._content.x) >=
|
|
146
|
+
this._content.width - this._maskGraphics.width) {
|
|
147
|
+
// 如果内容高度大于遮罩高度,则滚动到底部
|
|
148
|
+
if (this._content.width > this._maskGraphics.width) {
|
|
149
|
+
const x = -(this._content.width - this._maskGraphics.width);
|
|
150
|
+
gsap.to(this._content, {
|
|
151
|
+
duration: 0.75,
|
|
152
|
+
x,
|
|
153
|
+
ease: "elastic.out",
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
// 否则静止不动
|
|
157
|
+
else {
|
|
158
|
+
gsap.to(this._content, {
|
|
159
|
+
duration: 0.25,
|
|
160
|
+
x: 0,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Container } from "pixi.js";
|
|
2
|
-
import { LibPixiContainer } from
|
|
3
|
-
export interface
|
|
2
|
+
import { LibPixiContainer } from '../Base/LibPixiContainer';
|
|
3
|
+
export interface LibPixiScrollContainerYParams {
|
|
4
4
|
/** 宽度 */
|
|
5
5
|
width: number;
|
|
6
6
|
/** 高度 */
|
|
@@ -11,9 +11,9 @@ export interface LibPixiScrollContainerParams {
|
|
|
11
11
|
bottomMargin?: number;
|
|
12
12
|
}
|
|
13
13
|
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
14
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#
|
|
14
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y轴滚动容器
|
|
15
15
|
*/
|
|
16
|
-
export declare class
|
|
16
|
+
export declare class LibPixiScrollContainerY extends LibPixiContainer {
|
|
17
17
|
/** 开始位置 */
|
|
18
18
|
private _startY;
|
|
19
19
|
/** 惯性速度 */
|
|
@@ -32,7 +32,7 @@ export declare class LibPixiScrollContainer extends LibPixiContainer {
|
|
|
32
32
|
private _maskGraphics;
|
|
33
33
|
/** 滚动的内容 */
|
|
34
34
|
private _content;
|
|
35
|
-
constructor(params:
|
|
35
|
+
constructor(params: LibPixiScrollContainerYParams);
|
|
36
36
|
/** @description 设置滚动容器可视区宽高
|
|
37
37
|
* @param width 宽度
|
|
38
38
|
* @param height 高度
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Container, Graphics, Sprite, } from "pixi.js";
|
|
2
2
|
import { gsap } from "gsap";
|
|
3
|
-
import { LibPixiContainer } from
|
|
3
|
+
import { LibPixiContainer } from '../Base/LibPixiContainer';
|
|
4
4
|
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
5
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#
|
|
5
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y轴滚动容器
|
|
6
6
|
*/
|
|
7
|
-
export class
|
|
7
|
+
export class LibPixiScrollContainerY extends LibPixiContainer {
|
|
8
8
|
constructor(params) {
|
|
9
9
|
const { width, height, scrollContent, bottomMargin = 50 } = params;
|
|
10
10
|
super(width, height);
|
package/README.md
CHANGED
|
@@ -104,7 +104,9 @@ app.stage.addChild(box);
|
|
|
104
104
|
|
|
105
105
|
\- [LibPixiProgress-进度条](#LibPixiProgress-进度条)
|
|
106
106
|
|
|
107
|
-
\- [
|
|
107
|
+
\- [LibPixiScrollContainerX-X轴滚动容器](#LibPixiScrollContainerX-X轴滚动容器)
|
|
108
|
+
|
|
109
|
+
\- [LibPixiScrollContainerY-Y轴滚动容器](#LibPixiScrollContainerY-Y轴滚动容器)
|
|
108
110
|
|
|
109
111
|
\- [LibPixiScrollNum-数字滑动](#LibPixiScrollNum-数字滑动)
|
|
110
112
|
|
|
@@ -146,8 +148,6 @@ app.stage.addChild(box);
|
|
|
146
148
|
|
|
147
149
|
\- [LibPixiPolygonDrawTool-多边形绘制](#LibPixiPolygonDrawTool-多边形绘制)
|
|
148
150
|
|
|
149
|
-
\- [LibPixiWatchProperty-对象属性监听](#LibPixiWatchProperty-对象属性监听)
|
|
150
|
-
|
|
151
151
|
## Base-基础
|
|
152
152
|
|
|
153
153
|
### LibPixiText-文本
|
|
@@ -579,13 +579,13 @@ progress.setProgress(0.5); //50% 完成
|
|
|
579
579
|
app.stage.addChild(progress);
|
|
580
580
|
```
|
|
581
581
|
|
|
582
|
-
###
|
|
582
|
+
### LibPixiScrollContainerX-X轴滚动容器
|
|
583
583
|
|
|
584
584
|
> 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
585
585
|
|
|
586
586
|
```ts
|
|
587
587
|
import { Container } from "pixi.js";
|
|
588
|
-
import {
|
|
588
|
+
import { LibPixiScrollContainerX } from "./path/to/LibPixiScrollContainerX";
|
|
589
589
|
|
|
590
590
|
//创建滚动内容容器
|
|
591
591
|
const scrollContent = new Container();
|
|
@@ -593,7 +593,38 @@ const scrollContent = new Container();
|
|
|
593
593
|
//scrollContent.addChild(someOtherPixiElement);
|
|
594
594
|
|
|
595
595
|
//创建滚动容器实例
|
|
596
|
-
const scrollContainer = new
|
|
596
|
+
const scrollContainer = new LibPixiScrollContainerX({
|
|
597
|
+
width: 800,
|
|
598
|
+
height: 600,
|
|
599
|
+
scrollContent: scrollContent,
|
|
600
|
+
bottomMargin: 50, //可选:底部内边距
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
//添加到Pixi.js场景
|
|
604
|
+
app.stage.addChild(scrollContainer);
|
|
605
|
+
|
|
606
|
+
//设置容器大小
|
|
607
|
+
scrollContainer.setDimensions(800, 600);
|
|
608
|
+
|
|
609
|
+
//将内容添加到滚动容器
|
|
610
|
+
scrollContainer.addContent(new Sprite(Texture.from("new-content.png")));
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
### LibPixiScrollContainerY-Y轴滚动容器
|
|
614
|
+
|
|
615
|
+
> 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
616
|
+
|
|
617
|
+
```ts
|
|
618
|
+
import { Container } from "pixi.js";
|
|
619
|
+
import { LibPixiScrollContainerY } from "./path/to/LibPixiScrollContainerY";
|
|
620
|
+
|
|
621
|
+
//创建滚动内容容器
|
|
622
|
+
const scrollContent = new Container();
|
|
623
|
+
//在这里添加滚动内容,例如图片、文本等
|
|
624
|
+
//scrollContent.addChild(someOtherPixiElement);
|
|
625
|
+
|
|
626
|
+
//创建滚动容器实例
|
|
627
|
+
const scrollContainer = new LibPixiScrollContainerY({
|
|
597
628
|
width: 800,
|
|
598
629
|
height: 600,
|
|
599
630
|
scrollContent: scrollContent,
|
|
@@ -1019,21 +1050,4 @@ $bus.on("play", () => {
|
|
|
1019
1050
|
|
|
1020
1051
|
```ts
|
|
1021
1052
|
new LibPixiPolygonDrawTool(app);
|
|
1022
|
-
```
|
|
1023
|
-
|
|
1024
|
-
### LibPixiWatchProperty-对象属性监听
|
|
1025
|
-
|
|
1026
|
-
> 内部通过 Ticker 每秒调用10次循环判断被监听的属性是否发生改变,当元素被销毁时自动销毁 Ticker,取决于是否传递了元素
|
|
1027
|
-
|
|
1028
|
-
```ts
|
|
1029
|
-
LibPixiWatchProperty(
|
|
1030
|
-
gameStore,
|
|
1031
|
-
["a", "b"],
|
|
1032
|
-
() => {
|
|
1033
|
-
warningContainer.visible = a;
|
|
1034
|
-
useBtn.eventMode = a || b ? "none" : "static";
|
|
1035
|
-
},
|
|
1036
|
-
this
|
|
1037
|
-
);
|
|
1038
|
-
```
|
|
1039
|
-
|
|
1053
|
+
```
|
package/libPixiJs.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ import { LibPixiCloseBtn } from "./Components/Custom/LibPixiCloseBtn";
|
|
|
9
9
|
import { LibPixiDrawer } from "./Components/Custom/LibPixiDrawer";
|
|
10
10
|
import { LibPixiPerforMon } from "./Components/Custom/LibPixiPerforMon";
|
|
11
11
|
import { LibPixiProgress } from "./Components/Custom/LibPixiProgress";
|
|
12
|
-
import {
|
|
12
|
+
import { LibPixiScrollContainerX } from "./Components/Custom/LibPixiScrollContainerX";
|
|
13
|
+
import { LibPixiScrollContainerY } from "./Components/Custom/LibPixiScrollContainerY";
|
|
13
14
|
import { LibPixiScrollNum } from "./Components/Custom/LibPixiScrollNum";
|
|
14
15
|
import { LibPixiSlider } from "./Components/Custom/LibPixiSlider";
|
|
15
16
|
import { LibPixiSubAddMinMax } from "./Components/Custom/LibPixiSubAddMinMax";
|
|
@@ -68,9 +69,13 @@ export declare const Components: {
|
|
|
68
69
|
*/
|
|
69
70
|
LibPixiProgress: typeof LibPixiProgress;
|
|
70
71
|
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
71
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#
|
|
72
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerX-X轴滚动容器
|
|
72
73
|
*/
|
|
73
|
-
|
|
74
|
+
LibPixiScrollContainerX: typeof LibPixiScrollContainerX;
|
|
75
|
+
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
76
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y轴滚动容器
|
|
77
|
+
*/
|
|
78
|
+
LibPixiScrollContainerY: typeof LibPixiScrollContainerY;
|
|
74
79
|
/** @description 通过鼠标或手指拖动数字列选择数字
|
|
75
80
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollNum-数字滑动
|
|
76
81
|
*/
|
package/libPixiJs.js
CHANGED
|
@@ -9,7 +9,8 @@ import { LibPixiCloseBtn } from "./Components/Custom/LibPixiCloseBtn";
|
|
|
9
9
|
import { LibPixiDrawer } from "./Components/Custom/LibPixiDrawer";
|
|
10
10
|
import { LibPixiPerforMon } from "./Components/Custom/LibPixiPerforMon";
|
|
11
11
|
import { LibPixiProgress } from "./Components/Custom/LibPixiProgress";
|
|
12
|
-
import {
|
|
12
|
+
import { LibPixiScrollContainerX } from "./Components/Custom/LibPixiScrollContainerX";
|
|
13
|
+
import { LibPixiScrollContainerY } from "./Components/Custom/LibPixiScrollContainerY";
|
|
13
14
|
import { LibPixiScrollNum } from "./Components/Custom/LibPixiScrollNum";
|
|
14
15
|
import { LibPixiSlider } from "./Components/Custom/LibPixiSlider";
|
|
15
16
|
import { LibPixiSubAddMinMax } from "./Components/Custom/LibPixiSubAddMinMax";
|
|
@@ -78,9 +79,13 @@ export const Components = {
|
|
|
78
79
|
*/
|
|
79
80
|
LibPixiProgress,
|
|
80
81
|
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
81
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#
|
|
82
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerX-X轴滚动容器
|
|
82
83
|
*/
|
|
83
|
-
|
|
84
|
+
LibPixiScrollContainerX,
|
|
85
|
+
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
86
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y轴滚动容器
|
|
87
|
+
*/
|
|
88
|
+
LibPixiScrollContainerY,
|
|
84
89
|
/** @description 通过鼠标或手指拖动数字列选择数字
|
|
85
90
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollNum-数字滑动
|
|
86
91
|
*/
|
package/lyb-pixi.js
CHANGED
|
@@ -1315,7 +1315,7 @@
|
|
|
1315
1315
|
var ys = arrObjKeys(obj, inspect2);
|
|
1316
1316
|
var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
|
|
1317
1317
|
var protoTag = obj instanceof Object ? "" : "null prototype";
|
|
1318
|
-
var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr
|
|
1318
|
+
var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
|
|
1319
1319
|
var constructorTag = isPlainObject || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
|
|
1320
1320
|
var tag = constructorTag + (stringTag || protoTag ? "[" + $join.call($concat$1.call([], stringTag || [], protoTag || []), ": ") + "] " : "");
|
|
1321
1321
|
if (ys.length === 0) {
|
|
@@ -1337,25 +1337,25 @@
|
|
|
1337
1337
|
return $replace$1.call(String(s2), /"/g, """);
|
|
1338
1338
|
}
|
|
1339
1339
|
function isArray$3(obj) {
|
|
1340
|
-
return toStr
|
|
1340
|
+
return toStr(obj) === "[object Array]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1341
1341
|
}
|
|
1342
1342
|
function isDate(obj) {
|
|
1343
|
-
return toStr
|
|
1343
|
+
return toStr(obj) === "[object Date]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1344
1344
|
}
|
|
1345
1345
|
function isRegExp$1(obj) {
|
|
1346
|
-
return toStr
|
|
1346
|
+
return toStr(obj) === "[object RegExp]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1347
1347
|
}
|
|
1348
1348
|
function isError(obj) {
|
|
1349
|
-
return toStr
|
|
1349
|
+
return toStr(obj) === "[object Error]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1350
1350
|
}
|
|
1351
1351
|
function isString(obj) {
|
|
1352
|
-
return toStr
|
|
1352
|
+
return toStr(obj) === "[object String]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1353
1353
|
}
|
|
1354
1354
|
function isNumber(obj) {
|
|
1355
|
-
return toStr
|
|
1355
|
+
return toStr(obj) === "[object Number]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1356
1356
|
}
|
|
1357
1357
|
function isBoolean(obj) {
|
|
1358
|
-
return toStr
|
|
1358
|
+
return toStr(obj) === "[object Boolean]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1359
1359
|
}
|
|
1360
1360
|
function isSymbol(obj) {
|
|
1361
1361
|
if (hasShammedSymbols) {
|
|
@@ -1391,7 +1391,7 @@
|
|
|
1391
1391
|
function has$3(obj, key) {
|
|
1392
1392
|
return hasOwn$1.call(obj, key);
|
|
1393
1393
|
}
|
|
1394
|
-
function toStr
|
|
1394
|
+
function toStr(obj) {
|
|
1395
1395
|
return objectToString.call(obj);
|
|
1396
1396
|
}
|
|
1397
1397
|
function nameOf(f2) {
|
|
@@ -1700,7 +1700,7 @@
|
|
|
1700
1700
|
var uri = URIError;
|
|
1701
1701
|
var abs$1 = Math.abs;
|
|
1702
1702
|
var floor$1 = Math.floor;
|
|
1703
|
-
var max$
|
|
1703
|
+
var max$1 = Math.max;
|
|
1704
1704
|
var min$1 = Math.min;
|
|
1705
1705
|
var pow$1 = Math.pow;
|
|
1706
1706
|
var round$2 = Math.round;
|
|
@@ -1833,78 +1833,102 @@
|
|
|
1833
1833
|
Object_getPrototypeOf = $Object2.getPrototypeOf || null;
|
|
1834
1834
|
return Object_getPrototypeOf;
|
|
1835
1835
|
}
|
|
1836
|
-
var
|
|
1837
|
-
var
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
var slicy = function slicy2(arrLike, offset) {
|
|
1851
|
-
var arr = [];
|
|
1852
|
-
for (var i2 = offset || 0, j2 = 0; i2 < arrLike.length; i2 += 1, j2 += 1) {
|
|
1853
|
-
arr[j2] = arrLike[i2];
|
|
1854
|
-
}
|
|
1855
|
-
return arr;
|
|
1856
|
-
};
|
|
1857
|
-
var joiny = function(arr, joiner) {
|
|
1858
|
-
var str = "";
|
|
1859
|
-
for (var i2 = 0; i2 < arr.length; i2 += 1) {
|
|
1860
|
-
str += arr[i2];
|
|
1861
|
-
if (i2 + 1 < arr.length) {
|
|
1862
|
-
str += joiner;
|
|
1836
|
+
var implementation;
|
|
1837
|
+
var hasRequiredImplementation;
|
|
1838
|
+
function requireImplementation() {
|
|
1839
|
+
if (hasRequiredImplementation)
|
|
1840
|
+
return implementation;
|
|
1841
|
+
hasRequiredImplementation = 1;
|
|
1842
|
+
var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
|
|
1843
|
+
var toStr2 = Object.prototype.toString;
|
|
1844
|
+
var max2 = Math.max;
|
|
1845
|
+
var funcType = "[object Function]";
|
|
1846
|
+
var concatty = function concatty2(a2, b2) {
|
|
1847
|
+
var arr = [];
|
|
1848
|
+
for (var i2 = 0; i2 < a2.length; i2 += 1) {
|
|
1849
|
+
arr[i2] = a2[i2];
|
|
1863
1850
|
}
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
if (
|
|
1881
|
-
|
|
1851
|
+
for (var j2 = 0; j2 < b2.length; j2 += 1) {
|
|
1852
|
+
arr[j2 + a2.length] = b2[j2];
|
|
1853
|
+
}
|
|
1854
|
+
return arr;
|
|
1855
|
+
};
|
|
1856
|
+
var slicy = function slicy2(arrLike, offset) {
|
|
1857
|
+
var arr = [];
|
|
1858
|
+
for (var i2 = offset || 0, j2 = 0; i2 < arrLike.length; i2 += 1, j2 += 1) {
|
|
1859
|
+
arr[j2] = arrLike[i2];
|
|
1860
|
+
}
|
|
1861
|
+
return arr;
|
|
1862
|
+
};
|
|
1863
|
+
var joiny = function(arr, joiner) {
|
|
1864
|
+
var str = "";
|
|
1865
|
+
for (var i2 = 0; i2 < arr.length; i2 += 1) {
|
|
1866
|
+
str += arr[i2];
|
|
1867
|
+
if (i2 + 1 < arr.length) {
|
|
1868
|
+
str += joiner;
|
|
1882
1869
|
}
|
|
1883
|
-
return this;
|
|
1884
1870
|
}
|
|
1885
|
-
return
|
|
1886
|
-
that,
|
|
1887
|
-
concatty(args, arguments)
|
|
1888
|
-
);
|
|
1871
|
+
return str;
|
|
1889
1872
|
};
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
var
|
|
1873
|
+
implementation = function bind2(that) {
|
|
1874
|
+
var target = this;
|
|
1875
|
+
if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
|
|
1876
|
+
throw new TypeError(ERROR_MESSAGE + target);
|
|
1877
|
+
}
|
|
1878
|
+
var args = slicy(arguments, 1);
|
|
1879
|
+
var bound;
|
|
1880
|
+
var binder = function() {
|
|
1881
|
+
if (this instanceof bound) {
|
|
1882
|
+
var result = target.apply(
|
|
1883
|
+
this,
|
|
1884
|
+
concatty(args, arguments)
|
|
1885
|
+
);
|
|
1886
|
+
if (Object(result) === result) {
|
|
1887
|
+
return result;
|
|
1888
|
+
}
|
|
1889
|
+
return this;
|
|
1890
|
+
}
|
|
1891
|
+
return target.apply(
|
|
1892
|
+
that,
|
|
1893
|
+
concatty(args, arguments)
|
|
1894
|
+
);
|
|
1898
1895
|
};
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1896
|
+
var boundLength = max2(0, target.length - args.length);
|
|
1897
|
+
var boundArgs = [];
|
|
1898
|
+
for (var i2 = 0; i2 < boundLength; i2++) {
|
|
1899
|
+
boundArgs[i2] = "$" + i2;
|
|
1900
|
+
}
|
|
1901
|
+
bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
|
|
1902
|
+
if (target.prototype) {
|
|
1903
|
+
var Empty = function Empty2() {
|
|
1904
|
+
};
|
|
1905
|
+
Empty.prototype = target.prototype;
|
|
1906
|
+
bound.prototype = new Empty();
|
|
1907
|
+
Empty.prototype = null;
|
|
1908
|
+
}
|
|
1909
|
+
return bound;
|
|
1910
|
+
};
|
|
1911
|
+
return implementation;
|
|
1912
|
+
}
|
|
1913
|
+
var functionBind;
|
|
1914
|
+
var hasRequiredFunctionBind;
|
|
1915
|
+
function requireFunctionBind() {
|
|
1916
|
+
if (hasRequiredFunctionBind)
|
|
1917
|
+
return functionBind;
|
|
1918
|
+
hasRequiredFunctionBind = 1;
|
|
1919
|
+
var implementation2 = requireImplementation();
|
|
1920
|
+
functionBind = Function.prototype.bind || implementation2;
|
|
1921
|
+
return functionBind;
|
|
1922
|
+
}
|
|
1923
|
+
var functionCall;
|
|
1924
|
+
var hasRequiredFunctionCall;
|
|
1925
|
+
function requireFunctionCall() {
|
|
1926
|
+
if (hasRequiredFunctionCall)
|
|
1927
|
+
return functionCall;
|
|
1928
|
+
hasRequiredFunctionCall = 1;
|
|
1929
|
+
functionCall = Function.prototype.call;
|
|
1930
|
+
return functionCall;
|
|
1931
|
+
}
|
|
1908
1932
|
var functionApply;
|
|
1909
1933
|
var hasRequiredFunctionApply;
|
|
1910
1934
|
function requireFunctionApply() {
|
|
@@ -1915,14 +1939,14 @@
|
|
|
1915
1939
|
return functionApply;
|
|
1916
1940
|
}
|
|
1917
1941
|
var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
|
|
1918
|
-
var bind$2 =
|
|
1942
|
+
var bind$2 = requireFunctionBind();
|
|
1919
1943
|
var $apply$1 = requireFunctionApply();
|
|
1920
|
-
var $call$2 =
|
|
1944
|
+
var $call$2 = requireFunctionCall();
|
|
1921
1945
|
var $reflectApply = reflectApply;
|
|
1922
1946
|
var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
|
|
1923
|
-
var bind$1 =
|
|
1947
|
+
var bind$1 = requireFunctionBind();
|
|
1924
1948
|
var $TypeError$4 = type;
|
|
1925
|
-
var $call$1 =
|
|
1949
|
+
var $call$1 = requireFunctionCall();
|
|
1926
1950
|
var $actualApply = actualApply;
|
|
1927
1951
|
var callBindApplyHelpers = function callBindBasic2(args) {
|
|
1928
1952
|
if (args.length < 1 || typeof args[0] !== "function") {
|
|
@@ -1991,7 +2015,7 @@
|
|
|
1991
2015
|
hasRequiredHasown = 1;
|
|
1992
2016
|
var call = Function.prototype.call;
|
|
1993
2017
|
var $hasOwn = Object.prototype.hasOwnProperty;
|
|
1994
|
-
var bind2 =
|
|
2018
|
+
var bind2 = requireFunctionBind();
|
|
1995
2019
|
hasown = bind2.call(call, $hasOwn);
|
|
1996
2020
|
return hasown;
|
|
1997
2021
|
}
|
|
@@ -2006,7 +2030,7 @@
|
|
|
2006
2030
|
var $URIError = uri;
|
|
2007
2031
|
var abs = abs$1;
|
|
2008
2032
|
var floor = floor$1;
|
|
2009
|
-
var max = max$
|
|
2033
|
+
var max = max$1;
|
|
2010
2034
|
var min = min$1;
|
|
2011
2035
|
var pow = pow$1;
|
|
2012
2036
|
var round$1 = round$2;
|
|
@@ -2040,7 +2064,7 @@
|
|
|
2040
2064
|
var $ObjectGPO = requireObject_getPrototypeOf();
|
|
2041
2065
|
var $ReflectGPO = requireReflect_getPrototypeOf();
|
|
2042
2066
|
var $apply = requireFunctionApply();
|
|
2043
|
-
var $call =
|
|
2067
|
+
var $call = requireFunctionCall();
|
|
2044
2068
|
var needsEval = {};
|
|
2045
2069
|
var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
|
|
2046
2070
|
var INTRINSICS = {
|
|
@@ -2210,7 +2234,7 @@
|
|
|
2210
2234
|
"%WeakMapPrototype%": ["WeakMap", "prototype"],
|
|
2211
2235
|
"%WeakSetPrototype%": ["WeakSet", "prototype"]
|
|
2212
2236
|
};
|
|
2213
|
-
var bind =
|
|
2237
|
+
var bind = requireFunctionBind();
|
|
2214
2238
|
var hasOwn = requireHasown();
|
|
2215
2239
|
var $concat = bind.call($call, Array.prototype.concat);
|
|
2216
2240
|
var $spliceApply = bind.call($apply, Array.prototype.splice);
|
|
@@ -49090,7 +49114,143 @@ void main(void)\r
|
|
|
49090
49114
|
this._maskGraphics.endFill();
|
|
49091
49115
|
}
|
|
49092
49116
|
}
|
|
49093
|
-
class
|
|
49117
|
+
class LibPixiScrollContainerX extends LibPixiContainer {
|
|
49118
|
+
constructor(params) {
|
|
49119
|
+
const { width, height, scrollContent, bottomMargin = 50 } = params;
|
|
49120
|
+
super(width, height);
|
|
49121
|
+
this._startX = 0;
|
|
49122
|
+
this._velocity = 0;
|
|
49123
|
+
this._startTime = 0;
|
|
49124
|
+
this._startPosition = 0;
|
|
49125
|
+
this._scrollSpeed = 200;
|
|
49126
|
+
this._isDragging = false;
|
|
49127
|
+
this._scrollContent = scrollContent;
|
|
49128
|
+
this._content = new Container();
|
|
49129
|
+
this.addChild(this._content);
|
|
49130
|
+
this._content.addChild(this._scrollContent);
|
|
49131
|
+
if (bottomMargin > 0) {
|
|
49132
|
+
const bottom_box = new Sprite();
|
|
49133
|
+
this._content.addChild(bottom_box);
|
|
49134
|
+
bottom_box.x = this._content.width + bottomMargin;
|
|
49135
|
+
}
|
|
49136
|
+
this._maskGraphics = new Graphics();
|
|
49137
|
+
this.addChild(this._maskGraphics);
|
|
49138
|
+
this._maskGraphics.clear();
|
|
49139
|
+
this._maskGraphics.beginFill(0);
|
|
49140
|
+
this._maskGraphics.drawRect(0, 0, width, height);
|
|
49141
|
+
this._maskGraphics.endFill();
|
|
49142
|
+
this.mask = this._maskGraphics;
|
|
49143
|
+
this.eventMode = "static";
|
|
49144
|
+
this.on("pointerdown", this._onDragStart, this);
|
|
49145
|
+
this.on("pointermove", this._onDragMove, this);
|
|
49146
|
+
this.on("pointerup", this._onDragEnd, this);
|
|
49147
|
+
this.on("pointerupoutside", this._onDragEnd, this);
|
|
49148
|
+
this.on("wheel", this._onWheelScroll, this);
|
|
49149
|
+
}
|
|
49150
|
+
/** @description 设置滚动容器可视区宽高
|
|
49151
|
+
* @param width 宽度
|
|
49152
|
+
* @param height 高度
|
|
49153
|
+
*/
|
|
49154
|
+
setDimensions(width, height) {
|
|
49155
|
+
this._maskGraphics.clear();
|
|
49156
|
+
this._maskGraphics.beginFill(0);
|
|
49157
|
+
this._maskGraphics.drawRect(0, 0, width, height);
|
|
49158
|
+
this._maskGraphics.endFill();
|
|
49159
|
+
this.setSize(width, height);
|
|
49160
|
+
}
|
|
49161
|
+
/** @description 返回顶部 */
|
|
49162
|
+
scrollToTop() {
|
|
49163
|
+
gsapWithCSS.killTweensOf(this._content);
|
|
49164
|
+
this._content.x = 0;
|
|
49165
|
+
}
|
|
49166
|
+
/** @description 往滚动内容添加元素 */
|
|
49167
|
+
addContent(container) {
|
|
49168
|
+
this._scrollContent.addChild(container);
|
|
49169
|
+
}
|
|
49170
|
+
/** @description 按下 */
|
|
49171
|
+
_onDragStart(event) {
|
|
49172
|
+
if (this._content.width <= this._maskGraphics.width)
|
|
49173
|
+
return;
|
|
49174
|
+
const position = event.getLocalPosition(this);
|
|
49175
|
+
this._startX = position.x - this._content.x;
|
|
49176
|
+
this._isDragging = true;
|
|
49177
|
+
this._velocity = 0;
|
|
49178
|
+
this._startTime = Date.now();
|
|
49179
|
+
this._startPosition = this._content.x;
|
|
49180
|
+
gsapWithCSS.killTweensOf(this._content);
|
|
49181
|
+
}
|
|
49182
|
+
/** @description 拖动 */
|
|
49183
|
+
_onDragMove(event) {
|
|
49184
|
+
if (this._isDragging) {
|
|
49185
|
+
const position = event.getLocalPosition(this);
|
|
49186
|
+
const newPosition = position.x - this._startX;
|
|
49187
|
+
this._content.x = newPosition;
|
|
49188
|
+
}
|
|
49189
|
+
}
|
|
49190
|
+
/** @description 拖动结束 */
|
|
49191
|
+
_onDragEnd() {
|
|
49192
|
+
this._isDragging = false;
|
|
49193
|
+
const currentTime = Date.now();
|
|
49194
|
+
const deltaTime = currentTime - this._startTime;
|
|
49195
|
+
if (deltaTime < 250) {
|
|
49196
|
+
this._velocity = (this._content.x - this._startPosition) / deltaTime;
|
|
49197
|
+
this._applyInertia();
|
|
49198
|
+
} else {
|
|
49199
|
+
this._velocity = 0;
|
|
49200
|
+
}
|
|
49201
|
+
this._limitScrollRange();
|
|
49202
|
+
}
|
|
49203
|
+
/** @description 滚轮滚动 */
|
|
49204
|
+
_onWheelScroll(event) {
|
|
49205
|
+
if (this._content.width <= this._maskGraphics.width)
|
|
49206
|
+
return;
|
|
49207
|
+
let x2 = this._content.x - event.deltaY * (this._scrollSpeed / 100);
|
|
49208
|
+
if (x2 > 0) {
|
|
49209
|
+
x2 = 0;
|
|
49210
|
+
} else if (Math.abs(x2) >= this._content.width - this._maskGraphics.width) {
|
|
49211
|
+
x2 = -(this._content.width - this._maskGraphics.width);
|
|
49212
|
+
}
|
|
49213
|
+
gsapWithCSS.to(this._content, {
|
|
49214
|
+
duration: 0.25,
|
|
49215
|
+
ease: "power1.out",
|
|
49216
|
+
x: x2
|
|
49217
|
+
});
|
|
49218
|
+
}
|
|
49219
|
+
/** @description 惯性动画 */
|
|
49220
|
+
_applyInertia() {
|
|
49221
|
+
gsapWithCSS.to(this._content, {
|
|
49222
|
+
x: this._content.x + this._velocity * 250,
|
|
49223
|
+
duration: 0.5,
|
|
49224
|
+
ease: "power1.out",
|
|
49225
|
+
onUpdate: this._limitScrollRange.bind(this)
|
|
49226
|
+
});
|
|
49227
|
+
}
|
|
49228
|
+
/** @description 限制滚动范围 */
|
|
49229
|
+
_limitScrollRange() {
|
|
49230
|
+
if (this._content.x > 0) {
|
|
49231
|
+
gsapWithCSS.to(this._content, {
|
|
49232
|
+
duration: 0.75,
|
|
49233
|
+
x: 0,
|
|
49234
|
+
ease: "elastic.out"
|
|
49235
|
+
});
|
|
49236
|
+
} else if (Math.abs(this._content.x) >= this._content.width - this._maskGraphics.width) {
|
|
49237
|
+
if (this._content.width > this._maskGraphics.width) {
|
|
49238
|
+
const x2 = -(this._content.width - this._maskGraphics.width);
|
|
49239
|
+
gsapWithCSS.to(this._content, {
|
|
49240
|
+
duration: 0.75,
|
|
49241
|
+
x: x2,
|
|
49242
|
+
ease: "elastic.out"
|
|
49243
|
+
});
|
|
49244
|
+
} else {
|
|
49245
|
+
gsapWithCSS.to(this._content, {
|
|
49246
|
+
duration: 0.25,
|
|
49247
|
+
x: 0
|
|
49248
|
+
});
|
|
49249
|
+
}
|
|
49250
|
+
}
|
|
49251
|
+
}
|
|
49252
|
+
}
|
|
49253
|
+
class LibPixiScrollContainerY extends LibPixiContainer {
|
|
49094
49254
|
constructor(params) {
|
|
49095
49255
|
const { width, height, scrollContent, bottomMargin = 50 } = params;
|
|
49096
49256
|
super(width, height);
|
|
@@ -54735,9 +54895,13 @@ void main(void){
|
|
|
54735
54895
|
*/
|
|
54736
54896
|
LibPixiProgress,
|
|
54737
54897
|
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
54738
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#
|
|
54898
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerX-X轴滚动容器
|
|
54899
|
+
*/
|
|
54900
|
+
LibPixiScrollContainerX,
|
|
54901
|
+
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
54902
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y轴滚动容器
|
|
54739
54903
|
*/
|
|
54740
|
-
|
|
54904
|
+
LibPixiScrollContainerY,
|
|
54741
54905
|
/** @description 通过鼠标或手指拖动数字列选择数字
|
|
54742
54906
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollNum-数字滑动
|
|
54743
54907
|
*/
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Container, DisplayObjectEvents, FederatedPointerEvent } from "pixi.js";
|
|
2
|
-
/** @description 设置可关闭的事件监听,调用自身后不再触发
|
|
3
|
-
* @param container 事件容器
|
|
4
|
-
* @param eventName 事件名称
|
|
5
|
-
* @param callback 事件回调
|
|
6
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiEventControlled-可关闭的事件
|
|
7
|
-
*/
|
|
8
|
-
export declare const libPixiEventControlled: (container: Container, eventName: keyof DisplayObjectEvents, callback: (e: FederatedPointerEvent) => void) => () => void;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/** @description 设置可关闭的事件监听,调用自身后不再触发
|
|
2
|
-
* @param container 事件容器
|
|
3
|
-
* @param eventName 事件名称
|
|
4
|
-
* @param callback 事件回调
|
|
5
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiEventControlled-可关闭的事件
|
|
6
|
-
*/
|
|
7
|
-
export const libPixiEventControlled = (container, eventName, callback) => {
|
|
8
|
-
let isDestroy = false;
|
|
9
|
-
container.cursor = "pointer";
|
|
10
|
-
container.eventMode = "static";
|
|
11
|
-
container.on(eventName, (e) => {
|
|
12
|
-
if (isDestroy)
|
|
13
|
-
return;
|
|
14
|
-
if (e.button === 2)
|
|
15
|
-
return;
|
|
16
|
-
callback(e);
|
|
17
|
-
});
|
|
18
|
-
return () => {
|
|
19
|
-
isDestroy = true;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type Container } from "pixi.js";
|
|
2
|
-
/** @description 对象属性监听
|
|
3
|
-
* @param obj 对象
|
|
4
|
-
* @param keys 监听的对象属性
|
|
5
|
-
* @param callback 监听的对象属性发生变化时触发回调
|
|
6
|
-
* @param container 容器对象,用于判断元素是否被销毁
|
|
7
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiWatchProperty-对象属性监听
|
|
8
|
-
*/
|
|
9
|
-
export declare const LibPixiWatchProperty: <T extends object, K extends keyof T>(obj: T, keys: K[], callback: () => void, container?: Container) => void;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Ticker } from "pixi.js";
|
|
2
|
-
/** @description 对象属性监听
|
|
3
|
-
* @param obj 对象
|
|
4
|
-
* @param keys 监听的对象属性
|
|
5
|
-
* @param callback 监听的对象属性发生变化时触发回调
|
|
6
|
-
* @param container 容器对象,用于判断元素是否被销毁
|
|
7
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiWatchProperty-对象属性监听
|
|
8
|
-
*/
|
|
9
|
-
export const LibPixiWatchProperty = (obj, keys, callback, container) => {
|
|
10
|
-
const ticker = new Ticker();
|
|
11
|
-
const lastValues = new Map();
|
|
12
|
-
ticker.maxFPS = 10;
|
|
13
|
-
callback();
|
|
14
|
-
//存储上一次的值
|
|
15
|
-
for (let i = 0; i < keys.length; i++) {
|
|
16
|
-
const key = keys[i];
|
|
17
|
-
lastValues.set(key, obj[key]);
|
|
18
|
-
}
|
|
19
|
-
const flag = (key) => {
|
|
20
|
-
if (lastValues.get(key) !== obj[key]) {
|
|
21
|
-
lastValues.set(key, obj[key]);
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
return false;
|
|
25
|
-
};
|
|
26
|
-
ticker.add(() => {
|
|
27
|
-
//如果元素被销毁
|
|
28
|
-
if (container === null || container === void 0 ? void 0 : container.destroyed) {
|
|
29
|
-
ticker.destroy();
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
let changed = false;
|
|
33
|
-
if (keys.length === 1) {
|
|
34
|
-
changed = flag(keys[0]);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
for (let i = 0; i < keys.length; i++) {
|
|
38
|
-
const key = keys[i];
|
|
39
|
-
changed = flag(key);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (changed)
|
|
43
|
-
callback();
|
|
44
|
-
});
|
|
45
|
-
ticker.start();
|
|
46
|
-
};
|