Skip to content

Commit 90e2f23

Browse files
author
Zach Gibson
committed
Make each progress bar style a prop
1 parent dbfdd77 commit 90e2f23

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/ParallaxSwiper.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ class ParallaxSwiper extends Component {
7272
animatedValue,
7373
scrollEnabled,
7474
showProgressBar,
75-
progressBarStyle,
75+
progressBarThickness,
76+
progressBarBackgroundColor,
77+
progressBarValueBackgroundColor,
7678
} = this.props;
7779

7880
return (
@@ -142,17 +144,17 @@ class ParallaxSwiper extends Component {
142144
{showProgressBar && (
143145
<View
144146
style={{
145-
width: vertical ? progressBarStyle.size : this.state.width,
146-
height: vertical ? this.state.height : progressBarStyle.size,
147-
top: vertical ? -this.state.height : -progressBarStyle.size,
148-
backgroundColor: progressBarStyle.backgroundColor,
147+
width: vertical ? progressBarThickness : this.state.width,
148+
height: vertical ? this.state.height : progressBarThickness,
149+
top: vertical ? -this.state.height : -progressBarThickness,
150+
backgroundColor: progressBarBackgroundColor,
149151
}}
150152
>
151153
<Animated.View
152154
style={[
153155
styles.progressBar,
154156
{
155-
backgroundColor: progressBarStyle.valueBackgroundColor,
157+
backgroundColor: progressBarValueBackgroundColor,
156158
transform: [
157159
{
158160
translateX: vertical
@@ -226,11 +228,9 @@ ParallaxSwiper.propTypes = {
226228
scrollEnabled: PropTypes.bool,
227229
scrollToIndex: PropTypes.number,
228230
showProgressBar: PropTypes.bool,
229-
progressBarStyle: PropTypes.shape({
230-
size: PropTypes.number,
231-
backgroundColor: PropTypes.string,
232-
valueBackgroundColor: PropTypes.string,
233-
}),
231+
progressBarThickness: PropTypes.number,
232+
progressBarBackgroundColor: PropTypes.string,
233+
progressBarValueBackgroundColor: PropTypes.string,
234234
};
235235

236236
ParallaxSwiper.defaultProps = {
@@ -246,11 +246,9 @@ ParallaxSwiper.defaultProps = {
246246
scrollToIndex: 0,
247247
scrollEnabled: true,
248248
showProgressBar: false,
249-
progressBarStyle: {
250-
size: 4,
251-
backgroundColor: 'rgba(255,255,255,0.25)',
252-
valueBackgroundColor: 'white',
253-
},
249+
progressBarThickness: 4,
250+
progressBarBackgroundColor: 'rgba(255,255,255,0.25)',
251+
progressBarValueBackgroundColor: 'white',
254252
};
255253

256254
export default ParallaxSwiper;

0 commit comments

Comments
 (0)