lyb-pixi-js 1.6.1 → 1.6.2
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.
|
@@ -64,10 +64,4 @@ export declare class LibPixiScrollNum extends LibPixiContainer {
|
|
|
64
64
|
private _onDragMove;
|
|
65
65
|
/** @description 结束拖动 */
|
|
66
66
|
private _onDragEnd;
|
|
67
|
-
/** @description 线性插值
|
|
68
|
-
* @param a1 当 t = 0 时,返回 a1
|
|
69
|
-
* @param a2 当 t = 1 时,返回 a2
|
|
70
|
-
* @param t 插值比例,取值范围 0~1
|
|
71
|
-
*/
|
|
72
|
-
private lerp;
|
|
73
67
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Graphics } from "pixi.js";
|
|
2
2
|
import gsap from "gsap";
|
|
3
3
|
import { LibPixiContainer } from "../Base/LibPixiContainer";
|
|
4
|
+
import { LibJsLerp } from "lyb-js/Math/LibJsLerp";
|
|
4
5
|
/** @description 通过鼠标或手指拖动数字列选择数字
|
|
5
6
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollNum-数字滑动
|
|
6
7
|
*/
|
|
@@ -111,20 +112,20 @@ export class LibPixiScrollNum extends LibPixiContainer {
|
|
|
111
112
|
const nextIdx = idx + 1;
|
|
112
113
|
const nextIdx2 = idx + 2;
|
|
113
114
|
const curItem = containerList[idx];
|
|
114
|
-
curItem.alpha =
|
|
115
|
-
curItem.scale.y =
|
|
115
|
+
curItem.alpha = LibJsLerp(0.5, 1, 1 - t);
|
|
116
|
+
curItem.scale.y = LibJsLerp(0.85, 1, 1 - t);
|
|
116
117
|
if (nextIdx < containerList.length) {
|
|
117
118
|
const nextItem = containerList[nextIdx];
|
|
118
|
-
nextItem.alpha =
|
|
119
|
-
nextItem.scale.y =
|
|
119
|
+
nextItem.alpha = LibJsLerp(0.5, 1, t);
|
|
120
|
+
nextItem.scale.y = LibJsLerp(0.85, 1, t);
|
|
120
121
|
}
|
|
121
122
|
if (nextIdx2 < containerList.length) {
|
|
122
123
|
const nextItem = containerList[nextIdx2];
|
|
123
|
-
nextItem.alpha =
|
|
124
|
+
nextItem.alpha = LibJsLerp(0.1, 0.5, t);
|
|
124
125
|
}
|
|
125
126
|
if (prevIdx >= 0) {
|
|
126
127
|
const prevItem = containerList[prevIdx];
|
|
127
|
-
prevItem.alpha =
|
|
128
|
+
prevItem.alpha = LibJsLerp(0.1, 0.5, 1 - t);
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
/** @description 开始拖动 */
|
|
@@ -180,12 +181,4 @@ export class LibPixiScrollNum extends LibPixiContainer {
|
|
|
180
181
|
// 执行滑动到目标页码
|
|
181
182
|
this.slideTo(this._currentIndex);
|
|
182
183
|
}
|
|
183
|
-
/** @description 线性插值
|
|
184
|
-
* @param a1 当 t = 0 时,返回 a1
|
|
185
|
-
* @param a2 当 t = 1 时,返回 a2
|
|
186
|
-
* @param t 插值比例,取值范围 0~1
|
|
187
|
-
*/
|
|
188
|
-
lerp(a1, a2, t) {
|
|
189
|
-
return a1 * (1 - t) + a2 * t;
|
|
190
|
-
}
|
|
191
184
|
}
|
|
@@ -2,6 +2,7 @@ import { Container } from "pixi.js";
|
|
|
2
2
|
import gsap from "gsap";
|
|
3
3
|
import { libPixiOverflowHidden } from "../../Utils/LibPixiOverflowHidden";
|
|
4
4
|
import { LibPixiContainer } from "../Base/LibPixiContainer";
|
|
5
|
+
import { LibJsLerp } from 'lyb-js/Math/LibJsLerp';
|
|
5
6
|
/** @description 类似轮播图,但是不会自动轮播
|
|
6
7
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiSlider-横向滑动图
|
|
7
8
|
*/
|
|
@@ -150,20 +151,17 @@ export class LibPixiSlider extends LibPixiContainer {
|
|
|
150
151
|
const prevIdx = idx - 1;
|
|
151
152
|
const nextIdx = idx + 1;
|
|
152
153
|
const curItem = this._slideList[idx];
|
|
153
|
-
curItem.alpha =
|
|
154
|
-
curItem.scale.set(
|
|
154
|
+
curItem.alpha = LibJsLerp(this._depthAlpha, 1, 1 - t);
|
|
155
|
+
curItem.scale.set(LibJsLerp(this._depthScale, 1, 1 - t));
|
|
155
156
|
if (nextIdx < this._slideList.length) {
|
|
156
157
|
const nextItem = this._slideList[nextIdx];
|
|
157
|
-
nextItem.alpha =
|
|
158
|
-
nextItem.scale.set(
|
|
158
|
+
nextItem.alpha = LibJsLerp(this._depthAlpha, 1, t);
|
|
159
|
+
nextItem.scale.set(LibJsLerp(this._depthScale, 1, t));
|
|
159
160
|
}
|
|
160
161
|
if (prevIdx >= 0) {
|
|
161
162
|
const prevItem = this._slideList[prevIdx];
|
|
162
|
-
prevItem.alpha =
|
|
163
|
-
prevItem.scale.set(
|
|
163
|
+
prevItem.alpha = LibJsLerp(this._depthAlpha, 1, 1 - t);
|
|
164
|
+
prevItem.scale.set(LibJsLerp(this._depthScale, 1, 1 - t));
|
|
164
165
|
}
|
|
165
166
|
}
|
|
166
|
-
lerp(a1, a2, t) {
|
|
167
|
-
return a1 * (1 - t) + a2 * t;
|
|
168
|
-
}
|
|
169
167
|
}
|