diff --git a/Libraries/Components/ScrollResponder.js b/Libraries/Components/ScrollResponder.js index d6e7f6150..088f7b2c9 100644 --- a/Libraries/Components/ScrollResponder.js +++ b/Libraries/Components/ScrollResponder.js @@ -388,12 +388,13 @@ var ScrollResponderMixin = { /** * A helper function to zoom to a specific rect in the scrollview. * @param {object} rect Should have shape {x, y, width, height} + * @param {bool} animated Specify whether zoom is instant or animated */ - scrollResponderZoomTo: function(rect: { x: number; y: number; width: number; height: number; }) { + scrollResponderZoomTo: function(rect: { x: number; y: number; width: number; height: number; }, animated: boolean = true) { if (Platform.OS === 'android') { invariant('zoomToRect is not implemented'); } else { - ScrollViewManager.zoomToRect(React.findNodeHandle(this), rect); + ScrollViewManager.zoomToRect(React.findNodeHandle(this), rect, animated); } }, diff --git a/React/Views/RCTScrollViewManager.m b/React/Views/RCTScrollViewManager.m index 702b75043..7381e4223 100644 --- a/React/Views/RCTScrollViewManager.m +++ b/React/Views/RCTScrollViewManager.m @@ -152,12 +152,12 @@ RCT_EXPORT_METHOD(scrollWithoutAnimationTo:(nonnull NSNumber *)reactTag withOffs }]; } -RCT_EXPORT_METHOD(zoomToRect:(nonnull NSNumber *)reactTag withRect:(CGRect)rect) +RCT_EXPORT_METHOD(zoomToRect:(nonnull NSNumber *)reactTag withRect:(CGRect)rect animated:(BOOL)animated) { [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry){ UIView *view = viewRegistry[reactTag]; if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) { - [(id)view zoomToRect:rect animated:YES]; + [(id)view zoomToRect:rect animated:animated]; } else { RCTLogError(@"tried to zoomToRect: on non-RCTScrollableProtocol view %@ with tag #%@", view, reactTag); }