Skip to content

Commit

Permalink
Fix refreshing state of RefreshControl
Browse files Browse the repository at this point in the history
When RefreshControl.refreshing change twice in 250ms, it ignores the second changing.
  • Loading branch information
cpunion committed Apr 9, 2016
1 parent 2eafcd4 commit b022d6e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion React/Views/RCTRefreshControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
@implementation RCTRefreshControl {
BOOL _initialRefreshingState;
BOOL _isInitialRender;
BOOL _currentRefreshingState;
}

- (instancetype)init
{
if ((self = [super init])) {
[self addTarget:self action:@selector(refreshControlValueChanged) forControlEvents:UIControlEventValueChanged];
_isInitialRender = true;
_currentRefreshingState = false;
}
return self;
}
Expand Down Expand Up @@ -94,7 +96,9 @@ - (void)setTitle:(NSString *)title

- (void)setRefreshing:(BOOL)refreshing
{
if (self.refreshing != refreshing) {
if (_currentRefreshingState != refreshing) {
_currentRefreshingState = refreshing;

if (refreshing) {
// If it is the initial render, beginRefreshing will get called
// in layoutSubviews.
Expand All @@ -111,6 +115,8 @@ - (void)setRefreshing:(BOOL)refreshing

- (void)refreshControlValueChanged
{
_currentRefreshingState = super.refreshing;

if (_onRefresh) {
_onRefresh(nil);
}
Expand Down

0 comments on commit b022d6e

Please sign in to comment.