@@ -71,6 +71,10 @@ class ParallaxSwiper extends Component {
7171 vertical,
7272 animatedValue,
7373 scrollEnabled,
74+ showProgressBar,
75+ progressBarThickness,
76+ progressBarBackgroundColor,
77+ progressBarValueBackgroundColor,
7478 } = this . props ;
7579
7680 return (
@@ -137,6 +141,52 @@ class ParallaxSwiper extends Component {
137141 ) ;
138142 } ) }
139143 </ Animated . ScrollView >
144+ { showProgressBar && (
145+ < View
146+ style = { {
147+ width : vertical ? progressBarThickness : this . state . width ,
148+ height : vertical ? this . state . height : progressBarThickness ,
149+ top : vertical ? - this . state . height : - progressBarThickness ,
150+ backgroundColor : progressBarBackgroundColor ,
151+ } }
152+ >
153+ < Animated . View
154+ style = { [
155+ styles . progressBar ,
156+ {
157+ backgroundColor : progressBarValueBackgroundColor ,
158+ transform : [
159+ {
160+ translateX : vertical
161+ ? 0
162+ : animatedValue . interpolate ( {
163+ inputRange : [
164+ 0 ,
165+ ( this . state . width + dividerWidth ) *
166+ ( children . length - 1 ) ,
167+ ] ,
168+ outputRange : [ - this . state . width , 0 ] ,
169+ extrapolate : 'clamp' ,
170+ } ) ,
171+ } ,
172+ {
173+ translateY : vertical
174+ ? animatedValue . interpolate ( {
175+ inputRange : [
176+ 0 ,
177+ this . state . height * ( children . length - 1 ) ,
178+ ] ,
179+ outputRange : [ - this . state . height , 0 ] ,
180+ extrapolate : 'clamp' ,
181+ } )
182+ : 0 ,
183+ } ,
184+ ] ,
185+ } ,
186+ ] }
187+ />
188+ </ View >
189+ ) }
140190 </ View >
141191 ) ;
142192 }
@@ -146,6 +196,9 @@ const styles = StyleSheet.create({
146196 pageOuterContainer : {
147197 flexDirection : 'row' ,
148198 } ,
199+ progressBar : {
200+ ...StyleSheet . absoluteFillObject ,
201+ } ,
149202} ) ;
150203
151204ParallaxSwiper . propTypes = {
@@ -174,6 +227,10 @@ ParallaxSwiper.propTypes = {
174227 animatedValue : PropTypes . instanceOf ( Animated . Value ) ,
175228 scrollEnabled : PropTypes . bool ,
176229 scrollToIndex : PropTypes . number ,
230+ showProgressBar : PropTypes . bool ,
231+ progressBarThickness : PropTypes . number ,
232+ progressBarBackgroundColor : PropTypes . string ,
233+ progressBarValueBackgroundColor : PropTypes . string ,
177234} ;
178235
179236ParallaxSwiper . defaultProps = {
@@ -188,6 +245,10 @@ ParallaxSwiper.defaultProps = {
188245 onMomentumScrollEnd : ( ) => null ,
189246 scrollToIndex : 0 ,
190247 scrollEnabled : true ,
248+ showProgressBar : false ,
249+ progressBarThickness : 4 ,
250+ progressBarBackgroundColor : 'rgba(255,255,255,0.25)' ,
251+ progressBarValueBackgroundColor : 'white' ,
191252} ;
192253
193254export default ParallaxSwiper ;
0 commit comments