Skip to content

Commit

Permalink
Merge pull request #4202 from vishalduggal/timob-12988-31X
Browse files Browse the repository at this point in the history
[TIMOB-12988] (3_1_X) Delay setContentOffset if scrollRectToVisible called
  • Loading branch information
srahim committed Apr 30, 2013
2 parents 70d8fb2 + 9644e6b commit 1ea1219
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions iphone/Classes/TiUIScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
@private
TiUIView * touchHandler;
UIView * touchedContentView;
//TIMOB-12988 Additions
BOOL delay;
BOOL ignore;
BOOL offsetAnimated;
CGPoint offsetPoint;
}
-(void)setTouchHandler:(TiUIView*)handler;
@end
Expand Down
37 changes: 37 additions & 0 deletions iphone/Classes/TiUIScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,43 @@

@implementation TiUIScrollViewImpl

//TIMOB-12988 Additions BEGIN.
/*
* If you log the scrollRectToVisible and setContentOffset calls, you can see
* IOS is passing values we do not want. This is a hack to workaround
* bad contentoffset call. We calculate it correctly in our own code
* and that call follows soon after.
* Happens on IOS 5.1, 5.0 and 4.3. Not on iOS 6. Although values passed in are identical. Timing?
* Delete this block when we drop support for older versions of IOS.
*/
-(void) delayContentOffset
{
if(!ignore){
[self setContentOffset:offsetPoint animated:offsetAnimated];
}
}

- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
{
if (delay && ![TiUtils isIOS6OrGreater]) {
delay = NO;
ignore = NO;
offsetPoint = contentOffset;
offsetAnimated = animated;
[self performSelector:@selector(delayContentOffset) withObject:nil afterDelay:0.2];
return;
}
ignore = YES;
[super setContentOffset:contentOffset animated:animated];
}

- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated
{
delay = YES;
[super scrollRectToVisible:rect animated:animated];
}
//TIMOB-12988 Additions END.

-(void)setTouchHandler:(TiUIView*)handler
{
//Assign only. No retain
Expand Down

0 comments on commit 1ea1219

Please sign in to comment.