Skip to content

Commit 2779933

Browse files
authored
fix(iOS): fix animation on onPageScroll event on Fabric (#623)
1 parent 7fefbd5 commit 2779933

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ios/Fabric/RNCPagerViewComponentView.mm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#import "RCTFabricComponentsPlugins.h"
1111
#import "React/RCTConversions.h"
1212

13+
#import <React/RCTBridge+Private.h>
14+
#import "RCTOnPageScrollEvent.h"
15+
1316
using namespace facebook::react;
1417

1518
@interface RNCPagerViewComponentView () <RCTRNCViewPagerViewProtocol, UIPageViewControllerDataSource, UIPageViewControllerDelegate, UIScrollViewDelegate>
@@ -315,6 +318,15 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
315318
const auto strongEventEmitter = *std::dynamic_pointer_cast<const RNCViewPagerEventEmitter>(_eventEmitter);
316319
int eventPosition = (int) position;
317320
strongEventEmitter.onPageScroll(RNCViewPagerEventEmitter::OnPageScroll{.position = static_cast<double>(eventPosition), .offset = absoluteOffset});
321+
322+
//This is temporary workaround to allow animations based on onPageScroll event
323+
//until Fabric implements proper NativeAnimationDriver
324+
RCTBridge *bridge = [RCTBridge currentBridge];
325+
326+
if (bridge) {
327+
[bridge.eventDispatcher sendEvent:[[RCTOnPageScrollEvent alloc] initWithReactTag:[NSNumber numberWithInt:self.tag] position:@(position) offset:@(absoluteOffset)]];
328+
}
329+
318330
}
319331

320332

0 commit comments

Comments
 (0)