|
8 | 8 | #import "RCTScrollViewComponentView.h" |
9 | 9 |
|
10 | 10 | #import <React/RCTAssert.h> |
| 11 | +#import <React/RCTBridge+Private.h> |
| 12 | +#import <React/RCTScrollEvent.h> |
11 | 13 |
|
12 | 14 | #import <react/components/scrollview/ScrollViewComponentDescriptor.h> |
13 | 15 | #import <react/components/scrollview/ScrollViewEventEmitter.h> |
|
20 | 22 |
|
21 | 23 | using namespace facebook::react; |
22 | 24 |
|
| 25 | +static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteger tag) |
| 26 | +{ |
| 27 | + static uint16_t coalescingKey = 0; |
| 28 | + RCTScrollEvent *scrollEvent = [[RCTScrollEvent alloc] initWithEventName:@"onScroll" |
| 29 | + reactTag:[NSNumber numberWithInt:tag] |
| 30 | + scrollViewContentOffset:scrollView.contentOffset |
| 31 | + scrollViewContentInset:scrollView.contentInset |
| 32 | + scrollViewContentSize:scrollView.contentSize |
| 33 | + scrollViewFrame:scrollView.frame |
| 34 | + scrollViewZoomScale:scrollView.zoomScale |
| 35 | + userData:nil |
| 36 | + coalescingKey:coalescingKey]; |
| 37 | + [[RCTBridge currentBridge].eventDispatcher sendEvent:scrollEvent]; |
| 38 | +} |
| 39 | + |
23 | 40 | @interface RCTScrollViewComponentView () <UIScrollViewDelegate> |
24 | 41 |
|
25 | 42 | @end |
@@ -211,6 +228,9 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView |
211 | 228 | if ((_lastScrollEventDispatchTime == 0) || (now - _lastScrollEventDispatchTime > _scrollEventThrottle)) { |
212 | 229 | _lastScrollEventDispatchTime = now; |
213 | 230 | std::static_pointer_cast<ScrollViewEventEmitter const>(_eventEmitter)->onScroll([self _scrollViewMetrics]); |
| 231 | + // Once Fabric implements proper NativeAnimationDriver, this should be removed. |
| 232 | + // This is just a workaround to allow animations based on onScroll event. |
| 233 | + RCTSendPaperScrollEvent_DEPRECATED(scrollView, self.tag); |
214 | 234 | } |
215 | 235 | } |
216 | 236 |
|
|
0 commit comments