From 963f26cea8b921caba1f98d45e91992d00e96664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Wed, 13 Jan 2016 02:54:19 -0800 Subject: [PATCH] add ScrollResponder#scrollResponderZoomTo animated second argument Summary: ScrollResponder was missing a non animated version for zoomToRect. - scrollResponderScrollTo <> scrollResponderScrollWithoutAnimationTo - ~~scrollResponderZoomTo <> :new: **scrollResponderZoomWithoutAnimationTo**~~ - `scrollResponderZoomTo(rect, animated = true)` Closes https://github.com/facebook/react-native/pull/5268 Reviewed By: svcscm Differential Revision: D2823311 Pulled By: nicklockwood fb-gh-sync-id: ea409d332963f56e8b58ec2c086db3f6815058f7 --- Libraries/Components/ScrollResponder.js | 5 +++-- React/Views/RCTScrollViewManager.m | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) 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); }