diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index ff0ab9056..fc7fc7223 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -202,6 +202,14 @@ var ScrollView = React.createClass({ ); }, + scrollWithoutAnimationTo: function(destY?: number, destX?: number) { + RCTUIManager.scrollWithoutAnimationTo( + this.getNodeHandle(), + destX || 0, + destY || 0 + ); + }, + render: function() { var contentContainerStyle = [ this.props.horizontal && styles.contentContainerHorizontal, diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index 1daf0652c..82324f281 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -1051,13 +1051,27 @@ static void RCTMeasureLayout(RCTShadowView *view, [self addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry){ UIView *view = viewRegistry[reactTag]; if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) { - [(id)view scrollToOffset:CGPointMake([offsetX floatValue], [offsetY floatValue])]; + [(id)view scrollToOffset:CGPointMake([offsetX floatValue], [offsetY floatValue]) animated:YES]; } else { RCTLogError(@"tried to scrollToOffset: on non-RCTScrollableProtocol view %@ with tag %@", view, reactTag); } }]; } +- (void)scrollWithoutAnimationToOffsetWithView:(NSNumber *)reactTag scrollToOffsetX:(NSNumber *)offsetX offsetY:(NSNumber *)offsetY +{ + RCT_EXPORT(scrollWithoutAnimationTo); + + [self addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry){ + UIView *view = viewRegistry[reactTag]; + if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) { + [(id)view scrollToOffset:CGPointMake([offsetX floatValue], [offsetY floatValue]) animated:NO]; + } else { + RCTLogError(@"tried to scrollToOffset: on non-RCTScrollableProtocol view %@ with tag %@", view, reactTag); + } + }]; +} + - (void)zoomToRectWithView:(NSNumber *)reactTag rect:(NSDictionary *)rectDict { RCT_EXPORT(zoomToRect);