@momo-kits/carousel 0.0.65-alpha.10 → 0.0.65-alpha.12

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.js CHANGED
@@ -1,5 +1,7 @@
1
+ //import Carousel from './Carousel';
1
2
  import Carousel from './CarouselV2';
2
3
  import Pagination from './pagination/Pagination';
3
- import NumberPagination from './pagination/NumberPagination';
4
4
 
5
- export {Carousel, Pagination, NumberPagination};
5
+ export {
6
+ Carousel, Pagination
7
+ };
package/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
- "name": "@momo-kits/carousel",
3
- "version": "0.0.65-alpha.10",
4
- "private": false,
5
- "main": "index.js",
6
- "dependencies": {
7
- "prop-types": "^15.7.2",
8
- "react": "16.9.0"
9
- },
10
- "peerDependencies": {
11
- "react": "16.9.0",
12
- "react-native": ">=0.55",
13
- "@momo-kits/core-v2": ">=0.0.4-beta"
14
- },
15
- "devDependencies": {},
16
- "license": "MoMo"
17
- }
2
+ "name": "@momo-kits/carousel",
3
+ "version": "0.0.65-alpha.12",
4
+ "private": false,
5
+ "main": "index.js",
6
+ "dependencies": {
7
+ "prop-types": "^15.7.2",
8
+ "react": "16.9.0"
9
+ },
10
+ "peerDependencies": {
11
+ "react": "16.9.0",
12
+ "react-native": ">=0.55"
13
+ },
14
+ "devDependencies": {},
15
+ "license": "MoMo"
16
+ }
@@ -1,9 +1,10 @@
1
1
  import React, { PureComponent } from 'react';
2
- import { I18nManager, Platform, View } from 'react-native';
2
+ import {
3
+ I18nManager, Platform, View
4
+ } from 'react-native';
3
5
  import PropTypes from 'prop-types';
4
6
  import PaginationDot from './PaginationDot';
5
7
  import styles from './styles';
6
- import { Colors, Radius, Spacing } from '@momo-kits/core-v2';
7
8
 
8
9
  const IS_IOS = Platform.OS === 'ios';
9
10
  const IS_RTL = I18nManager.isRTL;
@@ -13,37 +14,34 @@ export default class Pagination extends PureComponent {
13
14
  super(props);
14
15
 
15
16
  // Warnings
16
- if (
17
- (props.dotColor && !props.inactiveDotColor) ||
18
- (!props.dotColor && props.inactiveDotColor)
19
- ) {
17
+ if ((props.dotColor && !props.inactiveDotColor) || (!props.dotColor && props.inactiveDotColor)) {
20
18
  console.warn(
21
- 'react-native-snap-carousel | Pagination: ' +
22
- 'You need to specify both `dotColor` and `inactiveDotColor`',
19
+ 'react-native-snap-carousel | Pagination: '
20
+ + 'You need to specify both `dotColor` and `inactiveDotColor`'
23
21
  );
24
22
  }
25
- if (
26
- (props.dotElement && !props.inactiveDotElement) ||
27
- (!props.dotElement && props.inactiveDotElement)
28
- ) {
23
+ if ((props.dotElement && !props.inactiveDotElement) || (!props.dotElement && props.inactiveDotElement)) {
29
24
  console.warn(
30
- 'react-native-snap-carousel | Pagination: ' +
31
- 'You need to specify both `dotElement` and `inactiveDotElement`',
25
+ 'react-native-snap-carousel | Pagination: '
26
+ + 'You need to specify both `dotElement` and `inactiveDotElement`'
32
27
  );
33
28
  }
34
29
  if (props.tappableDots && !props.carouselRef) {
35
30
  console.warn(
36
- 'react-native-snap-carousel | Pagination: ' +
37
- 'You must specify prop `carouselRef` when setting `tappableDots` to `true`',
31
+ 'react-native-snap-carousel | Pagination: '
32
+ + 'You must specify prop `carouselRef` when setting `tappableDots` to `true`'
38
33
  );
39
34
  }
40
35
  }
41
36
 
37
+ _needsRTLAdaptations() {
38
+ const { vertical } = this.props;
39
+ return IS_RTL && !IS_IOS && !vertical;
40
+ }
41
+
42
42
  get _activeDotIndex() {
43
43
  const { activeDotIndex, dotsLength } = this.props;
44
- return this._needsRTLAdaptations()
45
- ? dotsLength - activeDotIndex - 1
46
- : activeDotIndex;
44
+ return this._needsRTLAdaptations() ? dotsLength - activeDotIndex - 1 : activeDotIndex;
47
45
  }
48
46
 
49
47
  get dots() {
@@ -61,8 +59,7 @@ export default class Pagination extends PureComponent {
61
59
  inactiveDotScale,
62
60
  inactiveDotStyle,
63
61
  renderDots,
64
- tappableDots,
65
- type,
62
+ tappableDots
66
63
  } = this.props;
67
64
 
68
65
  if (renderDots) {
@@ -81,7 +78,6 @@ export default class Pagination extends PureComponent {
81
78
  inactiveOpacity={inactiveDotOpacity}
82
79
  inactiveScale={inactiveDotScale}
83
80
  inactiveStyle={inactiveDotStyle}
84
- type={type}
85
81
  />
86
82
  );
87
83
 
@@ -89,33 +85,22 @@ export default class Pagination extends PureComponent {
89
85
 
90
86
  for (let i = 0; i < dotsLength; i += 1) {
91
87
  const isActive = i === this._activeDotIndex;
92
- dots.push(
93
- React.cloneElement(
94
- (isActive ? dotElement : inactiveDotElement) || DefaultDot,
95
- {
96
- key: `pagination-dot-${i}`,
97
- active: i === this._activeDotIndex,
98
- index: i,
99
- },
100
- ),
101
- );
88
+ dots.push(React.cloneElement(
89
+ (isActive ? dotElement : inactiveDotElement) || DefaultDot,
90
+ {
91
+ key: `pagination-dot-${i}`,
92
+ active: i === this._activeDotIndex,
93
+ index: i
94
+ }
95
+ ));
102
96
  }
103
97
 
104
98
  return dots;
105
99
  }
106
100
 
107
- _needsRTLAdaptations() {
108
- const { vertical } = this.props;
109
- return IS_RTL && !IS_IOS && !vertical;
110
- }
111
-
112
101
  render() {
113
102
  const {
114
- dotsLength,
115
- containerStyle,
116
- vertical,
117
- accessibilityLabel,
118
- type,
103
+ dotsLength, containerStyle, vertical, accessibilityLabel
119
104
  } = this.props;
120
105
 
121
106
  if (!dotsLength || dotsLength < 2) {
@@ -127,11 +112,9 @@ export default class Pagination extends PureComponent {
127
112
  {
128
113
  flexDirection: vertical
129
114
  ? 'column'
130
- : this._needsRTLAdaptations()
131
- ? 'row-reverse'
132
- : 'row',
115
+ : (this._needsRTLAdaptations() ? 'row-reverse' : 'row')
133
116
  },
134
- containerStyle || {},
117
+ containerStyle || {}
135
118
  ];
136
119
 
137
120
  return (
@@ -139,20 +122,9 @@ export default class Pagination extends PureComponent {
139
122
  pointerEvents="box-none"
140
123
  style={style}
141
124
  accessible={!!accessibilityLabel}
142
- accessibilityLabel={accessibilityLabel}>
143
- <View
144
- style={[
145
- {
146
- flexDirection: 'row',
147
- padding: Spacing.XS,
148
- borderRadius: Radius.S,
149
- },
150
- type === 'light'
151
- ? {}
152
- : { backgroundColor: Colors.opacity_02_white_20 },
153
- ]}>
154
- {this.dots}
155
- </View>
125
+ accessibilityLabel={accessibilityLabel}
126
+ >
127
+ { this.dots }
156
128
  </View>
157
129
  );
158
130
  }
@@ -175,14 +147,12 @@ Pagination.propTypes = {
175
147
  vertical: PropTypes.bool,
176
148
  accessibilityLabel: PropTypes.string,
177
149
  containerStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
178
- dotContainerStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
179
- type: PropTypes.oneOf(['light', 'dark']),
150
+ dotContainerStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array])
180
151
  };
181
152
 
182
153
  Pagination.defaultProps = {
183
154
  inactiveDotOpacity: 0.5,
184
155
  inactiveDotScale: 0.5,
185
156
  tappableDots: false,
186
- vertical: false,
187
- type: 'light',
157
+ vertical: false
188
158
  };
@@ -1,8 +1,9 @@
1
1
  import React, { PureComponent } from 'react';
2
- import { Animated, Easing, TouchableOpacity } from 'react-native';
2
+ import {
3
+ Animated, Easing, TouchableOpacity
4
+ } from 'react-native';
3
5
  import PropTypes from 'prop-types';
4
6
  import styles from './styles';
5
- import { Colors } from '@momo-kits/core-v2';
6
7
 
7
8
  export default class PaginationDot extends PureComponent {
8
9
  constructor(props) {
@@ -10,15 +11,10 @@ export default class PaginationDot extends PureComponent {
10
11
  this.state = {
11
12
  animColor: new Animated.Value(0),
12
13
  animOpacity: new Animated.Value(0),
13
- animTransform: new Animated.Value(0),
14
+ animTransform: new Animated.Value(0)
14
15
  };
15
16
  }
16
17
 
17
- get _shouldAnimateColor() {
18
- const { color, inactiveColor } = this.props;
19
- return color && inactiveColor;
20
- }
21
-
22
18
  componentDidMount() {
23
19
  const { active } = this.props;
24
20
  if (active) {
@@ -40,33 +36,36 @@ export default class PaginationDot extends PureComponent {
40
36
  toValue,
41
37
  duration: 250,
42
38
  isInteraction: false,
43
- useNativeDriver: false,
39
+ useNativeDriver: false
44
40
  };
45
41
 
46
42
  const animations = [
47
43
  Animated.timing(animOpacity, {
48
44
  easing: Easing.linear,
49
- ...commonProperties,
45
+ ...commonProperties
50
46
  }),
51
47
  Animated.spring(animTransform, {
52
- // friction: 4,
48
+ friction: 4,
53
49
  tension: 50,
54
- ...commonProperties,
55
- }),
50
+ ...commonProperties
51
+ })
56
52
  ];
57
53
 
58
54
  if (this._shouldAnimateColor) {
59
- animations.push(
60
- Animated.timing(animColor, {
61
- easing: Easing.linear,
62
- ...commonProperties,
63
- }),
64
- );
55
+ animations.push(Animated.timing(animColor, {
56
+ easing: Easing.linear,
57
+ ...commonProperties
58
+ }));
65
59
  }
66
60
 
67
61
  Animated.parallel(animations).start();
68
62
  }
69
63
 
64
+ get _shouldAnimateColor() {
65
+ const { color, inactiveColor } = this.props;
66
+ return color && inactiveColor;
67
+ }
68
+
70
69
  render() {
71
70
  const { animColor, animOpacity, animTransform } = this.state;
72
71
  const {
@@ -78,59 +77,53 @@ export default class PaginationDot extends PureComponent {
78
77
  inactiveColor,
79
78
  inactiveStyle,
80
79
  inactiveOpacity,
80
+ inactiveScale,
81
81
  index,
82
82
  style,
83
- tappable,
84
- type,
83
+ tappable
85
84
  } = this.props;
86
85
 
87
86
  const animatedStyle = {
88
87
  opacity: animOpacity.interpolate({
89
88
  inputRange: [0, 1],
90
- outputRange: [inactiveOpacity, 1],
91
- }),
92
- width: animTransform.interpolate({
93
- inputRange: [0, 1],
94
- outputRange: [4, 12],
89
+ outputRange: [inactiveOpacity, 1]
95
90
  }),
91
+ transform: [{
92
+ scale: animTransform.interpolate({
93
+ inputRange: [0, 1],
94
+ outputRange: [inactiveScale, 1]
95
+ })
96
+ }]
96
97
  };
97
- const animatedColor = this._shouldAnimateColor
98
- ? {
99
- backgroundColor: animColor.interpolate({
100
- inputRange: [0, 1],
101
- outputRange: [inactiveColor, color],
102
- }),
103
- }
104
- : {};
98
+ const animatedColor = this._shouldAnimateColor ? {
99
+ backgroundColor: animColor.interpolate({
100
+ inputRange: [0, 1],
101
+ outputRange: [inactiveColor, color]
102
+ })
103
+ } : {};
105
104
 
106
105
  const dotContainerStyle = [
107
106
  styles.sliderPaginationDotContainer,
108
- containerStyle || {},
107
+ containerStyle || {}
109
108
  ];
110
109
 
111
110
  const dotStyle = [
112
111
  styles.sliderPaginationDot,
113
112
  style || {},
114
113
  (!active && inactiveStyle) || {},
115
- !active && { backgroundColor: Colors.black_10 },
116
114
  animatedStyle,
117
- type === 'light'
118
- ? animatedColor
119
- : { backgroundColor: Colors.black_01 },
115
+ animatedColor
120
116
  ];
121
117
 
122
- const onPress = tappable
123
- ? () =>
124
- carouselRef &&
125
- carouselRef._snapToItem(carouselRef._getPositionIndex(index))
126
- : undefined;
118
+ const onPress = tappable ? () => carouselRef && carouselRef._snapToItem(carouselRef._getPositionIndex(index)) : undefined;
127
119
 
128
120
  return (
129
121
  <TouchableOpacity
130
122
  accessible={false}
131
123
  style={dotContainerStyle}
132
124
  activeOpacity={tappable ? activeOpacity : 1}
133
- onPress={onPress}>
125
+ onPress={onPress}
126
+ >
134
127
  <Animated.View style={dotStyle} />
135
128
  </TouchableOpacity>
136
129
  );
@@ -138,6 +131,7 @@ export default class PaginationDot extends PureComponent {
138
131
  }
139
132
  PaginationDot.propTypes = {
140
133
  inactiveOpacity: PropTypes.number.isRequired,
134
+ inactiveScale: PropTypes.number.isRequired,
141
135
  active: PropTypes.bool,
142
136
  activeOpacity: PropTypes.number,
143
137
  carouselRef: PropTypes.object,
@@ -1,24 +1,24 @@
1
1
  import { StyleSheet } from 'react-native';
2
- import { Colors, Spacing } from '@momo-kits/core-v2';
3
2
 
4
- const DEFAULT_DOT_SIZE = 4;
5
- const DEFAULT_DOT_COLOR = Colors.pink_03;
3
+ const DEFAULT_DOT_SIZE = 7;
4
+ const DEFAULT_DOT_COLOR = 'rgba(0, 0, 0, 0.75)';
6
5
 
7
6
  export default StyleSheet.create({
8
7
  sliderPagination: {
9
8
  alignItems: 'center',
10
9
  justifyContent: 'center',
11
10
  paddingHorizontal: 20,
11
+ // paddingVertical: 30
12
12
  },
13
13
  sliderPaginationDotContainer: {
14
14
  alignItems: 'center',
15
15
  justifyContent: 'center',
16
- marginHorizontal: Spacing.XS,
16
+ marginHorizontal: 8
17
17
  },
18
18
  sliderPaginationDot: {
19
19
  width: DEFAULT_DOT_SIZE,
20
20
  height: DEFAULT_DOT_SIZE,
21
21
  borderRadius: DEFAULT_DOT_SIZE / 2,
22
- backgroundColor: DEFAULT_DOT_COLOR,
23
- },
22
+ backgroundColor: DEFAULT_DOT_COLOR
23
+ }
24
24
  });