@momo-kits/carousel 0.0.65-beta.2 → 0.0.65-beta.21

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.
Files changed (2) hide show
  1. package/CarouselV2.js +4 -21
  2. package/package.json +1 -1
package/CarouselV2.js CHANGED
@@ -364,12 +364,6 @@ export default class Carousel extends React.PureComponent {
364
364
  return true;
365
365
  }
366
366
 
367
- _roundNumber(num, decimals = 1) {
368
- // https://stackoverflow.com/a/41716722/
369
- const rounder = Math.pow(10, decimals);
370
- return Math.round((num + Number.EPSILON) * rounder) / rounder;
371
- }
372
-
373
367
  _isMultiple(x, y) {
374
368
  // This prevents Javascript precision issues: https://stackoverflow.com/a/58440614/
375
369
  // Required because Android viewport size can return pretty complicated decimals numbers
@@ -835,7 +829,7 @@ export default class Carousel extends React.PureComponent {
835
829
  }
836
830
 
837
831
  _onScroll(event) {
838
- const {onScroll, onScrollIndexChanged} = this.props;
832
+ const {onScroll, onScrollIndexChanged, onSnapToItem} = this.props;
839
833
  const scrollOffset = event
840
834
  ? this._getScrollOffset(event)
841
835
  : this._currentScrollOffset;
@@ -849,8 +843,11 @@ export default class Carousel extends React.PureComponent {
849
843
  this._onScrollActiveItem = nextActiveItem;
850
844
  onScrollIndexChanged &&
851
845
  onScrollIndexChanged(this._getDataIndex(nextActiveItem));
846
+
847
+ onSnapToItem && onSnapToItem(this._getDataIndex(nextActiveItem));
852
848
  }
853
849
 
850
+ //last item
854
851
  if (
855
852
  (IS_IOS && scrollOffset > lastItemScrollOffset) ||
856
853
  (IS_ANDROID &&
@@ -1012,20 +1009,6 @@ export default class Carousel extends React.PureComponent {
1012
1009
  this.pauseAutoPlay();
1013
1010
  }
1014
1011
 
1015
- snapToItem(index, animated = true, fireCallback = true) {
1016
- if (!index || index < 0) {
1017
- index = 0;
1018
- }
1019
-
1020
- const positionIndex = this._getPositionIndex(index);
1021
-
1022
- if (positionIndex === this._activeItem) {
1023
- return;
1024
- }
1025
-
1026
- this._snapToItem(positionIndex, animated, fireCallback);
1027
- }
1028
-
1029
1012
  snapToNext(animated = true, fireCallback = true) {
1030
1013
  const itemsLength = this._getCustomDataLength();
1031
1014
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/carousel",
3
- "version": "0.0.65-beta.2",
3
+ "version": "0.0.65-beta.21",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "dependencies": {