mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-07 13:05:18 +08:00
Use surface observer for Animated
Summary: Right now we rely on the Paper UIManager to update animated node graphs - this hooks us into `RCTSurfacePresenter` in the same way so we are no longer reliant on Paper. Should also help with complex ordering corner cases with pre vs. post operations and restoring defaults when nodes are removed. More info: https://github.com/facebook/react-native/pull/11819/files Note that we don't have a way to differentiate animation nodes related to fabric views vs. paper views, so if paper and fabric are both rendering updates simultaneously it's possible they could get processed by the wrong callback. That should be very rare, rarely cause problems even if it does happen, and won't be a problem at all in a post-Paper world. Reviewed By: shergin Differential Revision: D14336760 fbshipit-source-id: 1c6a72fa67d5fedbaefb21cd4d7e5d75484f4fae
This commit is contained in:
committed by
Facebook Github Bot
parent
3e40837a85
commit
544d9fb10b
@@ -28,6 +28,7 @@ RCT_EXPORT_MODULE();
|
||||
[_nodesManager stopAnimationLoop];
|
||||
[self.bridge.eventDispatcher removeDispatchObserver:self];
|
||||
[self.bridge.uiManager.observerCoordinator removeObserver:self];
|
||||
[self.bridge.surfacePresenter removeObserver:self];
|
||||
}
|
||||
|
||||
- (dispatch_queue_t)methodQueue
|
||||
@@ -48,7 +49,8 @@ RCT_EXPORT_MODULE();
|
||||
_animIdIsManagedByFabric = [NSMutableDictionary new];
|
||||
|
||||
[bridge.eventDispatcher addDispatchObserver:self];
|
||||
[bridge.uiManager.observerCoordinator addObserver:self]; // TODO: add fabric equivalent?
|
||||
[bridge.uiManager.observerCoordinator addObserver:self];
|
||||
[bridge.surfacePresenter addObserver:self];
|
||||
}
|
||||
|
||||
#pragma mark -- API
|
||||
@@ -225,9 +227,29 @@ RCT_EXPORT_METHOD(removeAnimatedEventFromView:(nonnull NSNumber *)viewTag
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - RCTSurfacePresenterObserver
|
||||
|
||||
- (void)willMountComponentsWithRootTag:(NSInteger)rootTag
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
for (AnimatedOperation operation in _preOperations) {
|
||||
operation(self->_nodesManager);
|
||||
}
|
||||
_preOperations = [NSMutableArray new];
|
||||
}
|
||||
|
||||
- (void)didMountComponentsWithRootTag:(NSInteger)rootTag
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
for (AnimatedOperation operation in _operations) {
|
||||
operation(self->_nodesManager);
|
||||
}
|
||||
_operations = [NSMutableArray new];
|
||||
}
|
||||
|
||||
#pragma mark - RCTUIManagerObserver
|
||||
|
||||
- (void)uiManagerWillPerformMounting:(RCTUIManager *)uiManager // TODO: need fabric equivalent
|
||||
- (void)uiManagerWillPerformMounting:(RCTUIManager *)uiManager
|
||||
{
|
||||
if (_preOperations.count == 0 && _operations.count == 0) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user