Skip to content

Commit

Permalink
add ScrollResponder#scrollResponderZoomTo animated second argument
Browse files Browse the repository at this point in the history
Summary:
ScrollResponder was missing a non animated version for zoomToRect.

- scrollResponderScrollTo <> scrollResponderScrollWithoutAnimationTo
- ~~scrollResponderZoomTo <> 🆕 **scrollResponderZoomWithoutAnimationTo**~~
- `scrollResponderZoomTo(rect, animated = true)`
Closes #5268

Reviewed By: svcscm

Differential Revision: D2823311

Pulled By: nicklockwood

fb-gh-sync-id: ea409d332963f56e8b58ec2c086db3f6815058f7
  • Loading branch information
gre authored and facebook-github-bot-6 committed Jan 13, 2016
1 parent 51621b1 commit 963f26c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Libraries/Components/ScrollResponder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
},

Expand Down
4 changes: 2 additions & 2 deletions React/Views/RCTScrollViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ - (UIView *)view
}];
}

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<NSNumber *, UIView *> *viewRegistry){
UIView *view = viewRegistry[reactTag];
if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) {
[(id<RCTScrollableProtocol>)view zoomToRect:rect animated:YES];
[(id<RCTScrollableProtocol>)view zoomToRect:rect animated:animated];
} else {
RCTLogError(@"tried to zoomToRect: on non-RCTScrollableProtocol view %@ with tag #%@", view, reactTag);
}
Expand Down

0 comments on commit 963f26c

Please sign in to comment.