@@ -71,6 +71,8 @@ class ParallaxSwiper extends Component {
7171 vertical,
7272 animatedValue,
7373 scrollEnabled,
74+ showProgressBar,
75+ progressBarStyle,
7476 } = this . props ;
7577
7678 return (
@@ -137,6 +139,52 @@ class ParallaxSwiper extends Component {
137139 ) ;
138140 } ) }
139141 </ Animated . ScrollView >
142+ { showProgressBar && (
143+ < View
144+ style = { {
145+ width : vertical ? progressBarStyle . height : this . state . width ,
146+ height : vertical ? this . state . height : progressBarStyle . height ,
147+ top : vertical ? - this . state . height : - progressBarStyle . height ,
148+ backgroundColor : progressBarStyle . backgroundColor ,
149+ } }
150+ >
151+ < Animated . View
152+ style = { [
153+ styles . progressBar ,
154+ {
155+ backgroundColor : progressBarStyle . valueBackgroundColor ,
156+ transform : [
157+ {
158+ translateX : vertical
159+ ? 0
160+ : animatedValue . interpolate ( {
161+ inputRange : [
162+ 0 ,
163+ ( this . state . width + dividerWidth ) *
164+ ( children . length - 1 ) ,
165+ ] ,
166+ outputRange : [ - this . state . width , 0 ] ,
167+ extrapolate : 'clamp' ,
168+ } ) ,
169+ } ,
170+ {
171+ translateY : vertical
172+ ? animatedValue . interpolate ( {
173+ inputRange : [
174+ 0 ,
175+ this . state . height * ( children . length - 1 ) ,
176+ ] ,
177+ outputRange : [ - this . state . height , 0 ] ,
178+ extrapolate : 'clamp' ,
179+ } )
180+ : 0 ,
181+ } ,
182+ ] ,
183+ } ,
184+ ] }
185+ />
186+ </ View >
187+ ) }
140188 </ View >
141189 ) ;
142190 }
@@ -146,6 +194,9 @@ const styles = StyleSheet.create({
146194 pageOuterContainer : {
147195 flexDirection : 'row' ,
148196 } ,
197+ progressBar : {
198+ ...StyleSheet . absoluteFillObject ,
199+ } ,
149200} ) ;
150201
151202ParallaxSwiper . propTypes = {
@@ -174,6 +225,12 @@ ParallaxSwiper.propTypes = {
174225 animatedValue : PropTypes . instanceOf ( Animated . Value ) ,
175226 scrollEnabled : PropTypes . bool ,
176227 scrollToIndex : PropTypes . number ,
228+ showProgressBar : PropTypes . bool ,
229+ progressBarStyle : PropTypes . shape ( {
230+ height : PropTypes . number ,
231+ backgroundColor : PropTypes . string ,
232+ valueBackgroundColor : PropTypes . string ,
233+ } ) ,
177234} ;
178235
179236ParallaxSwiper . defaultProps = {
@@ -188,6 +245,12 @@ ParallaxSwiper.defaultProps = {
188245 onMomentumScrollEnd : ( ) => null ,
189246 scrollToIndex : 0 ,
190247 scrollEnabled : true ,
248+ showProgressBar : false ,
249+ progressBarStyle : {
250+ height : 4 ,
251+ backgroundColor : 'rgba(255,255,255,0.25)' ,
252+ valueBackgroundColor : 'white' ,
253+ } ,
191254} ;
192255
193256export default ParallaxSwiper ;
0 commit comments