File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,13 @@ export class ProgressBar extends React.Component<Props> {
13
13
render ( ) {
14
14
const fractionalPosition =
15
15
this . props . progress . position + this . props . progress . offset ;
16
-
17
16
const size = fractionalPosition / ( this . props . numberOfPages - 1 ) ;
18
- console . log ( size ) ;
17
+ const clampedSize = Math . max ( 0 , Math . min ( 1 , size ) ) ;
19
18
return (
20
19
< View style = { styles . progressBarContainer } >
21
- < View style = { [ styles . progressBar , { width : `${ size * 100 } %` } ] } />
20
+ < View
21
+ style = { [ styles . progressBar , { width : `${ clampedSize * 100 } %` } ] }
22
+ />
22
23
</ View >
23
24
) ;
24
25
}
Original file line number Diff line number Diff line change @@ -392,22 +392,25 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
392
392
393
393
394
394
BOOL isAnimatingBackwards = ([self isLtrLayout ] && offset<0 ) || (![self isLtrLayout ] && offset > 0 .05f );
395
- if (isAnimatingBackwards && position > 0 ){
395
+ if (isAnimatingBackwards){
396
396
position = self.currentIndex - 1 ;
397
397
absoluteOffset = fmax (0 , 1 - absoluteOffset);
398
398
}
399
399
400
400
if (!_overdrag) {
401
401
NSInteger maxIndex = _reactPageIndicatorView.numberOfPages - 1 ;
402
- BOOL isFirstPage = [self isLtrLayout ] ? _currentIndex == 0 : _currentIndex == maxIndex;
403
- BOOL isLastPage = [self isLtrLayout ] ? _currentIndex == maxIndex : _currentIndex == 0 ;
402
+ NSInteger firstPageIndex = [self isLtrLayout ] ? 0 : maxIndex;
403
+ NSInteger lastPageIndex = [self isLtrLayout ] ? maxIndex : 0 ;
404
+ BOOL isFirstPage = _currentIndex == firstPageIndex;
405
+ BOOL isLastPage = _currentIndex == lastPageIndex;
404
406
CGFloat contentOffset =[self isHorizontal ] ? scrollView.contentOffset .x : scrollView.contentOffset .y ;
405
407
CGFloat topBound = [self isHorizontal ] ? scrollView.bounds .size .width : scrollView.bounds .size .height ;
406
408
407
409
if ((isFirstPage && contentOffset <= topBound) || (isLastPage && contentOffset >= topBound)) {
408
410
CGPoint croppedOffset = [self isHorizontal ] ? CGPointMake (topBound, 0 ) : CGPointMake (0 , topBound);
409
411
scrollView.contentOffset = croppedOffset;
410
412
absoluteOffset=0 ;
413
+ position = isLastPage ? lastPageIndex : firstPageIndex;
411
414
}
412
415
}
413
416
You can’t perform that action at this time.
0 commit comments