pixuireactcomponents 1.5.3 → 1.5.4
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/package.json
CHANGED
|
@@ -68,8 +68,10 @@ export function Carousel(props) {
|
|
|
68
68
|
: 0.3 : _p;
|
|
69
69
|
// console.log('children', children.length);
|
|
70
70
|
var safeNext = function () {
|
|
71
|
-
|
|
71
|
+
// console.log('safeNext1', canClickSwitch.current, isMoving.current);
|
|
72
|
+
if (!canClickSwitch.current || isMoving.current)
|
|
72
73
|
return;
|
|
74
|
+
// console.log('safeNext2');
|
|
73
75
|
canClickSwitch.current = false;
|
|
74
76
|
if (safeNextHandle.current)
|
|
75
77
|
clearTimeout(safeNextHandle.current);
|
|
@@ -79,8 +81,10 @@ export function Carousel(props) {
|
|
|
79
81
|
handleNext();
|
|
80
82
|
};
|
|
81
83
|
var safePrev = function () {
|
|
82
|
-
|
|
84
|
+
// console.log('safePrev1', canClickSwitch.current, isMoving.current);
|
|
85
|
+
if (!canClickSwitch.current || isMoving.current)
|
|
83
86
|
return;
|
|
87
|
+
// console.log('safePrev2');
|
|
84
88
|
canClickSwitch.current = false;
|
|
85
89
|
if (safePrevHandle.current)
|
|
86
90
|
clearTimeout(safePrevHandle.current);
|
|
@@ -102,6 +106,8 @@ export function Carousel(props) {
|
|
|
102
106
|
var isMouseDown = useRef(false);
|
|
103
107
|
var mouseDownX = useRef(0);
|
|
104
108
|
var mouseDownY = useRef(0);
|
|
109
|
+
var lastAniFinishTime = useRef(0);
|
|
110
|
+
var isSideAniPlaying = useRef(false);
|
|
105
111
|
//pixui在 onTransitionEnd 之后马上触发 transform 会丢onTransitionEnd
|
|
106
112
|
var canClickSwitch = useRef(true);
|
|
107
113
|
var handleNextRef = useRef(function () { });
|
|
@@ -167,7 +173,7 @@ export function Carousel(props) {
|
|
|
167
173
|
};
|
|
168
174
|
}, []);
|
|
169
175
|
var handlePrev = function () {
|
|
170
|
-
if (isMoving.current)
|
|
176
|
+
if (isMoving.current || isMouseDown.current)
|
|
171
177
|
return;
|
|
172
178
|
isMoving.current = true;
|
|
173
179
|
if (showIndex === 0) {
|
|
@@ -180,18 +186,38 @@ export function Carousel(props) {
|
|
|
180
186
|
var handleNext = function () {
|
|
181
187
|
if (!loop && showIndex == carouselItems.length - 2)
|
|
182
188
|
return;
|
|
183
|
-
if (isMoving.current)
|
|
189
|
+
if (isMoving.current || isMouseDown.current)
|
|
184
190
|
return;
|
|
185
191
|
isMoving.current = true;
|
|
186
192
|
setShowIndex(showIndex + 1);
|
|
187
193
|
};
|
|
188
194
|
var handleTransitionEnd = function () {
|
|
195
|
+
var now = Date.now();
|
|
196
|
+
// console.log(
|
|
197
|
+
// 'handleTransitionEnd ? isSideAniPlaying',
|
|
198
|
+
// isSideAniPlaying.current,
|
|
199
|
+
// 'time',
|
|
200
|
+
// now - lastAniFinishTime.current,
|
|
201
|
+
// 'showTransition',
|
|
202
|
+
// showTransition
|
|
203
|
+
// );
|
|
204
|
+
if (!isSideAniPlaying.current && Math.abs(now - lastAniFinishTime.current) < 800) {
|
|
205
|
+
//pixui bug 重复触发handleTransitionEnd
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
lastAniFinishTime.current = now;
|
|
189
209
|
//判断前后补位元素准备跳转
|
|
190
210
|
//在动画结束以后关掉,否则用鼠标拖动的时候不能补充剩下的offset
|
|
191
211
|
if (isLastCarouseItem() || isFirstCarouseLastItem()) {
|
|
192
212
|
setShowTransition(false);
|
|
213
|
+
isSideAniPlaying.current = true;
|
|
214
|
+
// console.log('handleTransitionEnd 1');
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
// console.log('handleTransitionEnd 3');
|
|
218
|
+
isMoving.current = false;
|
|
219
|
+
isSideAniPlaying.current = false;
|
|
193
220
|
}
|
|
194
|
-
isMoving.current = false;
|
|
195
221
|
//触发onSlideChange
|
|
196
222
|
if (!isLastCarouseItem() && !isFirstCarouseLastItem() && onSlideChange && showTransition)
|
|
197
223
|
onSlideChange(showIndex - 1);
|