@momo-kits/carousel 0.89.4 → 0.89.6-rc.1

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 (4) hide show
  1. package/index.tsx +17 -17
  2. package/package.json +2 -2
  3. package/publish.sh +21 -23
  4. package/types.ts +15 -7
package/index.tsx CHANGED
@@ -10,18 +10,15 @@ import {
10
10
  View,
11
11
  ViewStyle,
12
12
  } from 'react-native';
13
- import {defaultScrollInterpolator} from './animation';
13
+ import {defaultAnimatedStyles, defaultScrollInterpolator} from './animation';
14
14
  import {CarouselProps, CarouselRef, CarouselState, Position} from './types';
15
- import {scaleSize, Spacing} from '@momo-kits/foundation';
15
+ import {Spacing} from '@momo-kits/foundation';
16
16
 
17
17
  const IS_ANDROID = Platform.OS === 'android';
18
18
  const IS_IOS = Platform.OS === 'ios';
19
19
  const screenWidth = Dimensions.get('window').width;
20
20
 
21
- class Carousel extends React.PureComponent<
22
- CarouselProps,
23
- CarouselState
24
- > {
21
+ class Carousel extends React.PureComponent<CarouselProps, CarouselState> {
25
22
  static defaultProps = {
26
23
  activeSlideAlignment: 'start',
27
24
  activeSlideOffset: 20,
@@ -69,6 +66,7 @@ class Carousel extends React.PureComponent<
69
66
  _autoplayInterval?: NodeJS.Timeout;
70
67
  _carouselRef: any;
71
68
  _onLayoutInitDone?: boolean;
69
+
72
70
  constructor(props: CarouselProps) {
73
71
  super(props);
74
72
 
@@ -441,7 +439,7 @@ class Carousel extends React.PureComponent<
441
439
  } else {
442
440
  let interpolator = defaultScrollInterpolator(
443
441
  _index,
444
- this.state.itemWidth,
442
+ this.state.itemWidth
445
443
  );
446
444
 
447
445
  animatedValue = this._scrollPos.interpolate({
@@ -576,9 +574,7 @@ class Carousel extends React.PureComponent<
576
574
  this.props.visibleItem === 1
577
575
  ? screenWidth - Spacing.M * 2
578
576
  : Math.ceil(
579
- scaleSize(
580
- (containerWidth * 0.9 - visibleItem * Spacing.S) / visibleItem,
581
- ),
577
+ (containerWidth * 0.9 - visibleItem * Spacing.S) / visibleItem
582
578
  );
583
579
  if (this.props.itemWidth) {
584
580
  itemWidth = this.props.itemWidth;
@@ -601,7 +597,7 @@ class Carousel extends React.PureComponent<
601
597
  index: number,
602
598
  animated = true,
603
599
  fireCallback = true,
604
- forceScrollTo = false,
600
+ forceScrollTo = false
605
601
  ) {
606
602
  const {onSnapToItem} = this.props;
607
603
  const itemsLength = this._getCustomDataLength();
@@ -670,15 +666,15 @@ class Carousel extends React.PureComponent<
670
666
  if (full) {
671
667
  spacingStyle = {};
672
668
  }
673
-
669
+ const animatedStyle = defaultAnimatedStyles(animatedValue, this.props);
674
670
  return (
675
671
  <Component
676
672
  style={[
677
673
  mainDimension,
678
- slideStyle,
679
- // animatedStyle,
674
+ animatedStyle,
680
675
  {overflow: 'hidden'},
681
676
  spacingStyle,
677
+ slideStyle,
682
678
  ]}
683
679
  pointerEvents="box-none">
684
680
  {this.props.renderItem({
@@ -764,8 +760,9 @@ class Carousel extends React.PureComponent<
764
760
  style,
765
761
  disableIntervalMomentum,
766
762
  enableSnap,
763
+ contentContainerStyle,
767
764
  } = this.props;
768
- const {hideCarousel, containerWidth} = this.state;
765
+ const {hideCarousel} = this.state;
769
766
 
770
767
  const initialNumPerSide = this._enableLoop() ? loopClonesPerSide : 2;
771
768
  const initialNumToRender =
@@ -792,7 +789,9 @@ class Carousel extends React.PureComponent<
792
789
  {...specificProps}
793
790
  ref={c => (this._carouselRef = c)}
794
791
  overScrollMode={'never'}
795
- snapToInterval={snapToInterval}
792
+ snapToInterval={
793
+ this.props.snapToInterval ? this.props.snapToInterval : snapToInterval
794
+ }
796
795
  disableIntervalMomentum={disableIntervalMomentum}
797
796
  pointerEvents={hideCarousel ? 'none' : 'auto'}
798
797
  decelerationRate={'fast'}
@@ -804,6 +803,7 @@ class Carousel extends React.PureComponent<
804
803
  ]}
805
804
  automaticallyAdjustContentInsets={false}
806
805
  directionalLockEnabled
806
+ contentContainerStyle={contentContainerStyle}
807
807
  disableScrollViewPanResponder={false}
808
808
  pinchGestureEnabled={false}
809
809
  scrollsToTop={false}
@@ -826,5 +826,5 @@ class Carousel extends React.PureComponent<
826
826
  }
827
827
  }
828
828
 
829
- export {Carousel}
829
+ export {Carousel};
830
830
  export type {CarouselProps, CarouselRef};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/carousel",
3
- "version": "0.89.4",
3
+ "version": "0.89.6-rc.1",
4
4
  "private": false,
5
5
  "main": "index.tsx",
6
6
  "peerDependencies": {
@@ -16,4 +16,4 @@
16
16
  "dependencies": {
17
17
  "moment": "^2.24.0"
18
18
  }
19
- }
19
+ }
package/publish.sh CHANGED
@@ -1,29 +1,27 @@
1
1
  #!/bin/bash
2
+
3
+ # Prepare dist files
2
4
  rm -rf dist
3
5
  mkdir dist
4
-
5
- cp . ./dist
6
-
7
- # GET VERSION from mck_package.json
8
- VERSIONSTRING=( v$(jq .version package.json) )
9
- VERSION=(${VERSIONSTRING//[\"]/})
10
- echo VERSION: $VERSION
11
-
12
- rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type.js' --exclude 'prop-types.js' ./* dist
13
-
14
- # #babel component to dist
15
- #babel ./dist -d dist --copy-files
16
-
17
- #copy option
18
- #cp -r ./src/ dist
19
-
20
-
21
- #npm login
22
- #publish dist to npm
6
+ rsync -r --exclude=/dist ./* dist
23
7
  cd dist
24
- npm publish --tag beta --access=public
8
+
9
+ if [ "$1" == "stable" ]; then
10
+ npm version $(npm view @momo-kits/foundation@stable version)
11
+ npm version patch
12
+ npm publish --tag stable --access=public
13
+ elif [ "$1" == "latest" ]; then
14
+ npm version $(npm view @momo-kits/foundation@latest version)
15
+ npm publish --tag latest --access=public
16
+ else
17
+ npm version $(npm view @momo-kits/carousel@beta version)
18
+ npm version prerelease --preid=beta
19
+ npm publish --tag beta --access=public
20
+ fi
21
+
22
+ PACKAGE_NAME=$(npm pkg get name)
23
+ NEW_PACKAGE_VERSION=$(npm pkg get version)
24
+
25
+ # Clean up
25
26
  cd ..
26
27
  rm -rf dist
27
-
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/calendar new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/calendar"}'
package/types.ts CHANGED
@@ -1,4 +1,10 @@
1
- import {NativeScrollEvent, NativeSyntheticEvent, ViewStyle} from 'react-native';
1
+ import {
2
+ Animated,
3
+ NativeScrollEvent,
4
+ NativeSyntheticEvent,
5
+ StyleProp,
6
+ ViewStyle,
7
+ } from 'react-native';
2
8
 
3
9
  export type CarouselProps = {
4
10
  activeSlideOffset?: number;
@@ -13,35 +19,37 @@ export type CarouselProps = {
13
19
  loop?: boolean;
14
20
  loopClonesPerSide?: number;
15
21
  scrollEnabled?: boolean;
16
- slideStyle?: object;
22
+ slideStyle?: StyleProp<ViewStyle>;
17
23
  disableIntervalMomentum?: boolean;
18
24
  itemWidth?: number;
19
25
  data: any[];
20
- renderItem: (info: {item: any; index: number}) => React.ReactNode;
26
+ renderItem: (info: { item: any; index: number }) => React.ReactNode;
21
27
  onScroll?: any;
22
28
  onScrollIndexChanged?: (index: number) => void;
23
29
  onSnapToItem?: (index: number) => void;
24
30
  onTouchStart?: (event: any) => void;
25
31
  onTouchEnd?: (event: any) => void;
26
32
  onMomentumScrollEnd?: (
27
- event: NativeSyntheticEvent<NativeScrollEvent>,
33
+ event: NativeSyntheticEvent<NativeScrollEvent>
28
34
  ) => void;
29
35
  onLayout?: (event: any) => void;
30
36
  keyExtractor?: (item: any, index: number) => string;
31
37
  getItemLayout?: (
32
38
  data: any,
33
- index: number,
34
- ) => {length: number; offset: number; index: number};
39
+ index: number
40
+ ) => { length: number; offset: number; index: number };
35
41
  style?: ViewStyle;
36
42
  visibleItem?: number;
43
+ contentContainerStyle?: StyleProp<ViewStyle>;
37
44
  full?: boolean;
45
+ snapToInterval?: number | Animated.Value | Animated.AnimatedInterpolation | undefined
38
46
  };
39
47
 
40
48
  export type CarouselRef = {
41
49
  snapToItem: (
42
50
  index: number,
43
51
  animated?: boolean,
44
- fireCallback?: boolean,
52
+ fireCallback?: boolean
45
53
  ) => void;
46
54
  snapToNext: (animated?: boolean, fireCallback?: boolean) => void;
47
55
  snapToPrev: (animated?: boolean, fireCallback?: boolean) => void;