@momo-kits/carousel 0.151.1-test.4 → 0.151.2-beta.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.
- package/index.tsx +16 -9
- package/package.json +1 -1
package/index.tsx
CHANGED
|
@@ -398,18 +398,25 @@ class Carousel extends React.PureComponent<CarouselProps, CarouselState> {
|
|
|
398
398
|
return 0;
|
|
399
399
|
}
|
|
400
400
|
|
|
401
|
-
|
|
401
|
+
if (
|
|
402
|
+
this._positions[lastIndex] &&
|
|
403
|
+
offset >= this._positions[lastIndex].start
|
|
404
|
+
) {
|
|
405
|
+
return lastIndex;
|
|
406
|
+
}
|
|
407
|
+
|
|
402
408
|
for (let i = 0; i < this._positions.length; i++) {
|
|
403
409
|
const { start, end } = this._positions[i];
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
410
|
+
if (
|
|
411
|
+
center + activeSlideOffset >= start &&
|
|
412
|
+
center - activeSlideOffset <= end
|
|
413
|
+
) {
|
|
408
414
|
itemIndex = i;
|
|
415
|
+
break;
|
|
409
416
|
}
|
|
410
417
|
}
|
|
411
418
|
|
|
412
|
-
return itemIndex
|
|
419
|
+
return itemIndex || 0;
|
|
413
420
|
}
|
|
414
421
|
|
|
415
422
|
_initPositionsAndInterpolators(props = this.props) {
|
|
@@ -508,10 +515,10 @@ class Carousel extends React.PureComponent<CarouselProps, CarouselState> {
|
|
|
508
515
|
|
|
509
516
|
if (nextActiveItem !== this._onScrollActiveItem) {
|
|
510
517
|
this._onScrollActiveItem = nextActiveItem;
|
|
511
|
-
|
|
518
|
+
onScrollIndexChanged &&
|
|
519
|
+
onScrollIndexChanged(this._getDataIndex(nextActiveItem));
|
|
512
520
|
|
|
513
|
-
|
|
514
|
-
onSnapToItem && onSnapToItem(dataIndex);
|
|
521
|
+
onSnapToItem && onSnapToItem(this._getDataIndex(nextActiveItem));
|
|
515
522
|
}
|
|
516
523
|
|
|
517
524
|
if (
|