@momo-kits/carousel 0.0.62-alpha.33 → 0.0.62-alpha.34

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 +41 -29
  2. package/package.json +2 -2
package/CarouselV2.js CHANGED
@@ -68,6 +68,29 @@ export default class Carousel extends React.PureComponent {
68
68
  this._displayWarnings(props);
69
69
  }
70
70
 
71
+ get realIndex() {
72
+ return this._activeItem;
73
+ }
74
+
75
+ // shouldComponentUpdate (
76
+ // nextProps,
77
+ // nextState
78
+ // ) {
79
+ // if (this.props.shouldOptimizeUpdates === false) {
80
+ // return true;
81
+ // } else {
82
+ // return shallowCompare(this, nextProps, nextState);
83
+ // }
84
+ // }
85
+
86
+ get currentIndex() {
87
+ return this._getDataIndex(this._activeItem);
88
+ }
89
+
90
+ get currentScrollPosition() {
91
+ return this._currentScrollOffset;
92
+ }
93
+
71
94
  componentDidMount() {
72
95
  const { apparitionDelay, autoplay, firstItem } = this.props;
73
96
 
@@ -106,17 +129,6 @@ export default class Carousel extends React.PureComponent {
106
129
  }, 1);
107
130
  }
108
131
 
109
- // shouldComponentUpdate (
110
- // nextProps,
111
- // nextState
112
- // ) {
113
- // if (this.props.shouldOptimizeUpdates === false) {
114
- // return true;
115
- // } else {
116
- // return shallowCompare(this, nextProps, nextState);
117
- // }
118
- // }
119
-
120
132
  componentDidUpdate(prevProps) {
121
133
  const { interpolators } = this.state;
122
134
  const { firstItem, scrollEnabled } = this.props;
@@ -202,18 +214,6 @@ export default class Carousel extends React.PureComponent {
202
214
  clearTimeout(this._androidRepositioningTimeout);
203
215
  }
204
216
 
205
- get realIndex() {
206
- return this._activeItem;
207
- }
208
-
209
- get currentIndex() {
210
- return this._getDataIndex(this._activeItem);
211
- }
212
-
213
- get currentScrollPosition() {
214
- return this._currentScrollOffset;
215
- }
216
-
217
217
  _setScrollHandler(props) {
218
218
  // Native driver for scroll events
219
219
  const scrollEventConfig = {
@@ -752,12 +752,18 @@ export default class Carousel extends React.PureComponent {
752
752
  const multiplier = this._currentScrollOffset === 0 ? 1 : -1;
753
753
  const scrollDelta = scrollValue * multiplier;
754
754
 
755
- this._scrollTo({ offset: offset + scrollDelta, animated: false });
755
+ this._scrollTo({
756
+ offset: offset + scrollDelta,
757
+ animated: false,
758
+ });
756
759
 
757
760
  // @ts-expect-error setTimeout / clearTiemout is buggy :/
758
761
  clearTimeout(this._hackSlideAnimationTimeout);
759
762
  this._hackSlideAnimationTimeout = setTimeout(() => {
760
- this._scrollTo({ offset, animated: false });
763
+ this._scrollTo({
764
+ offset,
765
+ animated: false,
766
+ });
761
767
  }, 1); // works randomly when set to '0'
762
768
  }
763
769
 
@@ -867,9 +873,9 @@ export default class Carousel extends React.PureComponent {
867
873
  }
868
874
 
869
875
  if (
870
- (IS_IOS && scrollOffset >= lastItemScrollOffset) ||
876
+ (IS_IOS && scrollOffset > lastItemScrollOffset) ||
871
877
  (IS_ANDROID &&
872
- Math.floor(scrollOffset) >= Math.floor(lastItemScrollOffset))
878
+ Math.floor(scrollOffset) > Math.floor(lastItemScrollOffset))
873
879
  ) {
874
880
  this._activeItem = nextActiveItem;
875
881
  this._repositionScroll(nextActiveItem);
@@ -961,7 +967,10 @@ export default class Carousel extends React.PureComponent {
961
967
  return;
962
968
  }
963
969
 
964
- this._scrollTo({ offset, animated });
970
+ this._scrollTo({
971
+ offset,
972
+ animated,
973
+ });
965
974
 
966
975
  // On both platforms, `onMomentumScrollEnd` won't be triggered if the scroll isn't animated
967
976
  // so we need to trigger the callback manually
@@ -1196,7 +1205,10 @@ export default class Carousel extends React.PureComponent {
1196
1205
  containerCustomStyle || style || {},
1197
1206
  hideCarousel ? { opacity: 0 } : {},
1198
1207
  this.props.vertical
1199
- ? { height: this.props.sliderHeight, flexDirection: 'column' } // LTR hack; see https://github.com/facebook/react-native/issues/11960
1208
+ ? {
1209
+ height: this.props.sliderHeight,
1210
+ flexDirection: 'column',
1211
+ } // LTR hack; see https://github.com/facebook/react-native/issues/11960
1200
1212
  : // and https://github.com/facebook/react-native/issues/13100#issuecomment-328986423
1201
1213
  {
1202
1214
  width: this.props.sliderWidth,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/carousel",
3
- "version": "0.0.62-alpha.33",
3
+ "version": "0.0.62-alpha.34",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "dependencies": {
@@ -14,4 +14,4 @@
14
14
  },
15
15
  "devDependencies": {},
16
16
  "license": "MoMo"
17
- }
17
+ }