add ScrollResponder#scrollResponderZoomTo animated second argument
Summary: ScrollResponder was missing a non animated version for zoomToRect. - scrollResponderScrollTo <> scrollResponderScrollWithoutAnimationTo - ~~scrollResponderZoomTo <> 🆕 **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
This commit is contained in:
parent
51621b14cb
commit
963f26cea8
|
@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -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<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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue