File tree Expand file tree Collapse file tree 2 files changed +5
-28
lines changed Expand file tree Collapse file tree 2 files changed +5
-28
lines changed Original file line number Diff line number Diff line change @@ -388,24 +388,13 @@ var ScrollResponderMixin = {
388
388
/**
389
389
* A helper function to zoom to a specific rect in the scrollview.
390
390
* @param {object } rect Should have shape {x, y, width, height}
391
+ * @param {bool } animated Enable the zoom animation
391
392
*/
392
- scrollResponderZoomTo : function ( rect : { x : number ; y: number ; width: number ; height: number ; } ) {
393
+ scrollResponderZoomTo : function ( rect : { x : number ; y: number ; width: number ; height: number ; } , animated ?: boolean = true ) {
393
394
if ( Platform . OS === 'android' ) {
394
395
invariant ( 'zoomToRect is not implemented' ) ;
395
396
} else {
396
- ScrollViewManager . zoomToRect ( React . findNodeHandle ( this ) , rect ) ;
397
- }
398
- } ,
399
-
400
- /**
401
- * A helper function to zoom to a specific rect in the scrollview without animation.
402
- * @param {object } rect Should have shape {x, y, width, height}
403
- */
404
- scrollResponderZoomWithoutAnimationTo : function ( rect : { x : number ; y: number ; width: number ; height: number ; } ) {
405
- if ( Platform . OS === 'android' ) {
406
- invariant ( 'zoomToRect is not implemented' ) ;
407
- } else {
408
- ScrollViewManager . zoomToRectWithoutAnimation ( React . findNodeHandle ( this ) , rect ) ;
397
+ ScrollViewManager . zoomToRect ( React . findNodeHandle ( this ) , rect , animated ) ;
409
398
}
410
399
} ,
411
400
Original file line number Diff line number Diff line change @@ -152,30 +152,18 @@ - (UIView *)view
152
152
}];
153
153
}
154
154
155
- RCT_EXPORT_METHOD (zoomToRect:(nonnull NSNumber *)reactTag withRect:(CGRect )rect)
155
+ RCT_EXPORT_METHOD (zoomToRect:(nonnull NSNumber *)reactTag withRect:(CGRect )rect withAnimated:( BOOL )animated )
156
156
{
157
157
[self .bridge.uiManager addUIBlock: ^(__unused RCTUIManager *uiManager, NSDictionary <NSNumber *, UIView *> *viewRegistry){
158
158
UIView *view = viewRegistry[reactTag];
159
159
if ([view conformsToProtocol: @protocol (RCTScrollableProtocol)]) {
160
- [(id <RCTScrollableProtocol>)view zoomToRect: rect animated: YES ];
160
+ [(id <RCTScrollableProtocol>)view zoomToRect: rect animated: animated ];
161
161
} else {
162
162
RCTLogError (@" tried to zoomToRect: on non-RCTScrollableProtocol view %@ with tag #%@ " , view, reactTag);
163
163
}
164
164
}];
165
165
}
166
166
167
- RCT_EXPORT_METHOD (zoomToRectWithoutAnimation:(nonnull NSNumber *)reactTag withRect:(CGRect )rect)
168
- {
169
- [self .bridge.uiManager addUIBlock: ^(__unused RCTUIManager *uiManager, NSDictionary <NSNumber *, UIView *> *viewRegistry){
170
- UIView *view = viewRegistry[reactTag];
171
- if ([view conformsToProtocol: @protocol (RCTScrollableProtocol)]) {
172
- [(id <RCTScrollableProtocol>)view zoomToRect: rect animated: NO ];
173
- } else {
174
- RCTLogError (@" tried to zoomToRectWithoutAnimation: on non-RCTScrollableProtocol view %@ with tag #%@ " , view, reactTag);
175
- }
176
- }];
177
- }
178
-
179
167
- (NSArray <NSString *> *)customDirectEventTypes
180
168
{
181
169
return @[
You can’t perform that action at this time.
0 commit comments