Skip to content

Commit

Permalink
Merge pull request #4840 from vishalduggal/timob-15095
Browse files Browse the repository at this point in the history
[TIMOB-15095] Render at end of scroll whenever possible
  • Loading branch information
pec1985 committed Oct 24, 2013
2 parents affad6c + 5dab1b7 commit 9b2cd09
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion iphone/Classes/TiUIScrollableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
int lastPage;
BOOL enforceCacheRecalculation;
int cacheSize;

BOOL pageChanged;
}

-(void)manageRotation;
Expand Down
26 changes: 22 additions & 4 deletions iphone/Classes/TiUIScrollableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -612,15 +612,30 @@ -(void)scrollViewDidScroll:(UIScrollView *)sender
minCacheSize = cacheSize;
}
}
pageChanged = YES;
cacheSize = minCacheSize;
[pageControl setCurrentPage:nextPage];
currentPage = nextPage;
[self.proxy replaceValue:NUMINT(currentPage) forKey:@"currentPage" notification:NO];
[self manageCache:currentPage];
[pageControl setCurrentPage:nextPage];
currentPage = nextPage;
[self.proxy replaceValue:NUMINT(currentPage) forKey:@"currentPage" notification:NO];
cacheSize = curCacheSize;
}
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
if (pageChanged) {
[self manageCache:currentPage];
}
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
//Since we are now managing cache at end of scroll, ensure quick scroll is disabled to avoid blank screens.
if (pageChanged) {
[scrollview setUserInteractionEnabled:!decelerate];
}
}

-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
// called when setContentOffset/scrollRectVisible:animated: finishes. not called if not animating
Expand Down Expand Up @@ -654,6 +669,9 @@ -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
[[self proxy] viewAtIndex:pageNum],@"view",nil]];
}
currentPage=pageNum;
[self manageCache:currentPage];
pageChanged = NO;
[scrollview setUserInteractionEnabled:YES];
[pageControl setCurrentPage:pageNum];
}

Expand Down

0 comments on commit 9b2cd09

Please sign in to comment.