@@ -15,6 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
15
15
- (void )flashScrollIndicators ;
16
16
- (void )scrollTo : (double )x y : (double )y animated : (BOOL )animated ;
17
17
- (void )scrollToEnd : (BOOL )animated ;
18
+ - (void )zoomToRect : (CGRect )rect animated : (BOOL )animated ;
18
19
@end
19
20
20
21
RCT_EXTERN inline void
@@ -90,6 +91,43 @@ RCTScrollViewHandleCommand(id<RCTScrollViewProtocol> componentView, NSString con
90
91
[componentView scrollToEnd: animated];
91
92
return ;
92
93
}
94
+
95
+ if ([commandName isEqualToString: @" zoomToRect" ]) {
96
+ #if RCT_DEBUG
97
+ if ([args count ] != 2 ) {
98
+ RCTLogError (
99
+ @" %@ command %@ received %d arguments, expected %d ." , @" ScrollView" , commandName, (int )[args count ], 2 );
100
+ return ;
101
+ }
102
+ #endif
103
+
104
+ NSObject *arg0 = args[0 ];
105
+
106
+ #if RCT_DEBUG
107
+ if (!RCTValidateTypeOfViewCommandArgument (
108
+ arg0, [NSDictionary class ], @" dictionary" , @" ScrollView" , commandName, @" 1st" )) {
109
+ return ;
110
+ }
111
+ #endif
112
+
113
+ NSDictionary *rectDict = (NSDictionary *)arg0;
114
+ NSNumber *x = rectDict[@" x" ];
115
+ NSNumber *y = rectDict[@" y" ];
116
+ NSNumber *width = rectDict[@" width" ];
117
+ NSNumber *height = rectDict[@" height" ];
118
+ CGRect rect = CGRectMake (x.doubleValue , y.doubleValue , width.doubleValue , height.doubleValue );
119
+
120
+ NSObject *arg1 = args[1 ];
121
+ #if RCT_DEBUG
122
+ if (!RCTValidateTypeOfViewCommandArgument (arg1, [NSNumber class ], @" boolean" , @" ScrollView" , commandName, @" 2nd" )) {
123
+ return ;
124
+ }
125
+ #endif
126
+
127
+ BOOL animated = [(NSNumber *)arg1 boolValue ];
128
+ [componentView zoomToRect: rect animated: animated];
129
+ return ;
130
+ }
93
131
}
94
132
95
133
NS_ASSUME_NONNULL_END
0 commit comments