@@ -237,6 +237,7 @@ - (void)setContentOffset:(CGPoint)contentOffset
237
237
if (!NSEqualPoints (contentOffset, self.documentVisibleRect .origin ))
238
238
{
239
239
[self .contentView scrollToPoint: contentOffset];
240
+ [self reflectScrolledClipView: self .contentView];
240
241
}
241
242
#else // ]TODO(macOS ISS#2323203)
242
243
super.contentOffset = CGPointMake (
@@ -245,6 +246,21 @@ - (void)setContentOffset:(CGPoint)contentOffset
245
246
#endif // TODO(macOS ISS#2323203)
246
247
}
247
248
249
+ #if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
250
+ - (void )setContentOffset : (CGPoint)contentOffset
251
+ animated : (BOOL )animated
252
+ {
253
+ if (animated) {
254
+ [NSAnimationContext beginGrouping ];
255
+ [[NSAnimationContext currentContext ] setDuration: 0.3 ];
256
+ [[self .contentView animator ] setBoundsOrigin: contentOffset];
257
+ [NSAnimationContext endGrouping ];
258
+ } else {
259
+ self.contentOffset = contentOffset;
260
+ }
261
+ }
262
+ #endif // TODO(macOS ISS#2323203)
263
+
248
264
- (void )setFrame : (CGRect)frame
249
265
{
250
266
// Preserving and revalidating `contentOffset`.
@@ -321,12 +337,12 @@ - (BOOL)resignFirstResponder
321
337
return YES ;
322
338
}
323
339
324
- - (void )setAccessibilityLabel : (NSString *)accessibilityLabel
340
+ - (void )setAccessibilityLabel : (NSString *)accessibilityLabel
325
341
{
326
342
[super setAccessibilityLabel: accessibilityLabel];
327
343
[[self documentView ] setAccessibilityLabel: accessibilityLabel];
328
344
}
329
- - (void )setDocumentView : (__kindof NSView *)documentView
345
+ - (void )setDocumentView : (__kindof NSView *)documentView
330
346
{
331
347
[super setDocumentView: documentView];
332
348
[documentView setAccessibilityLabel: [self accessibilityLabel ]];
@@ -457,7 +473,7 @@ - (BOOL)resignFirstResponder
457
473
return [_scrollView resignFirstResponder ];
458
474
}
459
475
460
- - (void )setAccessibilityLabel : (NSString *)accessibilityLabel
476
+ - (void )setAccessibilityLabel : (NSString *)accessibilityLabel
461
477
{
462
478
[_scrollView setAccessibilityLabel: accessibilityLabel];
463
479
}
@@ -494,7 +510,7 @@ - (void)insertReactSubview:(RCTUIView *)view atIndex:(NSInteger)atIndex // TODO(
494
510
[super insertReactSubview: view atIndex: atIndex];
495
511
#if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
496
512
RCTAssert (self.contentView == nil , @" RCTScrollView may only contain a single subview" );
497
-
513
+
498
514
_scrollView.documentView = view;
499
515
#else // ]TODO(macOS ISS#2323203)
500
516
#if !TARGET_OS_TV
@@ -714,19 +730,16 @@ - (void)scrollToOffset:(CGPoint)offset animated:(BOOL)animated
714
730
0.01 )); // Make width and height greater than 0
715
731
// Ensure at least one scroll event will fire
716
732
_allowNextScrollNoMatterWhat = YES ;
717
- #if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
718
- (void ) animated;
719
- _scrollView.contentOffset = offset;
720
- #else // ]TODO(macOS ISS#2323203)
733
+
721
734
if (!CGRectContainsPoint (maxRect, offset) && !self.scrollToOverflowEnabled ) {
722
735
CGFloat x = fmax (offset.x , CGRectGetMinX (maxRect));
723
736
x = fmin (x, CGRectGetMaxX (maxRect));
724
737
CGFloat y = fmax (offset.y , CGRectGetMinY (maxRect));
725
738
y = fmin (y, CGRectGetMaxY (maxRect));
726
739
offset = CGPointMake (x, y);
727
740
}
741
+
728
742
[_scrollView setContentOffset: offset animated: animated];
729
- #endif // TODO(macOS ISS#2323203)
730
743
}
731
744
}
732
745
@@ -753,12 +766,7 @@ - (void)scrollToEnd:(BOOL)animated
753
766
if (!CGPointEqualToPoint (_scrollView.contentOffset , offset)) {
754
767
// Ensure at least one scroll event will fire
755
768
_allowNextScrollNoMatterWhat = YES ;
756
- #if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
757
- (void ) animated;
758
- _scrollView.contentOffset = offset;
759
- #else // ]TODO(macOS ISS#2323203)
760
769
[_scrollView setContentOffset: offset animated: animated];
761
- #endif // TODO(macOS ISS#2323203)
762
770
}
763
771
}
764
772
@@ -787,7 +795,7 @@ - (void)flashScrollIndicators
787
795
#endif
788
796
}
789
797
// ]TODO(macOS ISS#2323203)
790
-
798
+
791
799
#pragma mark - ScrollView delegate
792
800
793
801
#if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
@@ -1277,22 +1285,22 @@ - (NSString*)keyCommandFromKeyCode:(NSInteger)keyCode
1277
1285
{
1278
1286
case 36 :
1279
1287
return @" ENTER" ;
1280
-
1288
+
1281
1289
case 116 :
1282
1290
return @" PAGE_UP" ;
1283
1291
1284
1292
case 121 :
1285
1293
return @" PAGE_DOWN" ;
1286
-
1294
+
1287
1295
case 123 :
1288
1296
return @" LEFT_ARROW" ;
1289
-
1297
+
1290
1298
case 124 :
1291
1299
return @" RIGHT_ARROW" ;
1292
-
1300
+
1293
1301
case 125 :
1294
1302
return @" DOWN_ARROW" ;
1295
-
1303
+
1296
1304
case 126 :
1297
1305
return @" UP_ARROW" ;
1298
1306
}
@@ -1308,7 +1316,7 @@ - (void)keyDown:(UIEvent*)theEvent
1308
1316
RCT_SEND_SCROLL_EVENT (onScrollKeyDown, (@{ @" key" : keyCommand}));
1309
1317
} else {
1310
1318
[super keyDown: theEvent];
1311
-
1319
+
1312
1320
// AX: if a tab key was pressed and the first responder is currently clipped by the scroll view,
1313
1321
// automatically scroll to make the view visible to make it navigable via keyboard.
1314
1322
if ([theEvent keyCode ] == 48 ) { // tab key
0 commit comments