@momo-kits/carousel 0.0.43-beta.75 → 0.0.43-beta.76

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/CarouselV2.js CHANGED
@@ -18,6 +18,7 @@ import PropTypes from 'prop-types';
18
18
  // import RN_PACKAGE from '../../../react-native/package.json';
19
19
 
20
20
  const IS_ANDROID = Platform.OS === 'android';
21
+ const IS_IOS = Platform.OS === 'ios';
21
22
 
22
23
  // React Native automatically handles RTL layouts; unfortunately, it's buggy with horizontal ScrollView
23
24
  // See https://github.com/facebook/react-native/issues/11960
@@ -853,6 +854,8 @@ export default class Carousel extends React.PureComponent {
853
854
  ? this._getScrollOffset(event)
854
855
  : this._currentScrollOffset;
855
856
  const nextActiveItem = this._getActiveItem(scrollOffset);
857
+ const dataLength = this._getCustomDataLength();
858
+ const lastItemScrollOffset = this._getItemScrollOffset(dataLength - 1);
856
859
 
857
860
  this._currentScrollOffset = scrollOffset;
858
861
 
@@ -862,6 +865,11 @@ export default class Carousel extends React.PureComponent {
862
865
  onScrollIndexChanged(this._getDataIndex(nextActiveItem));
863
866
  }
864
867
 
868
+ if (IS_IOS && scrollOffset >= lastItemScrollOffset) {
869
+ this._activeItem = nextActiveItem;
870
+ this._repositionScroll(nextActiveItem);
871
+ }
872
+
865
873
  if (typeof onScroll === 'function' && event) {
866
874
  onScroll(event);
867
875
  }
@@ -885,7 +893,9 @@ export default class Carousel extends React.PureComponent {
885
893
  this._activeItem = nextActiveItem;
886
894
  onSnapToItem && onSnapToItem(this._getDataIndex(nextActiveItem));
887
895
 
888
- if (hasSnapped) {
896
+ if (hasSnapped && IS_ANDROID) {
897
+ this._repositionScroll(nextActiveItem);
898
+ } else if (IS_IOS) {
889
899
  this._repositionScroll(nextActiveItem);
890
900
  }
891
901
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/carousel",
3
- "version": "0.0.43-beta.75",
3
+ "version": "0.0.43-beta.76",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "dependencies": {
package/publish.sh CHANGED
@@ -26,4 +26,4 @@ cd ..
26
26
  rm -rf dist
27
27
 
28
28
 
29
- #curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/carousel new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/carousel"}'
29
+ curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/carousel new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/carousel"}'