Skip to content

Commit

Permalink
Re-land of modern animated
Browse files Browse the repository at this point in the history
Summary:
changelog:
[general][Added] - Concurrent rendering safe implementation of Animated

This is a re land of D40681265 (5e863fc). Previously, Modern Animated did not work correctly for animations that were driven by ScrollView's contentOffset. This was fixed in D41122065 (1b1b26a).

Reviewed By: javache, huntie

Differential Revision: D41264757

fbshipit-source-id: 3a9213997710e483d6c2c09b51359d17a6f9567e
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Nov 14, 2022
1 parent a7ae988 commit 5cdf3cf
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 453 deletions.
11 changes: 7 additions & 4 deletions Libraries/Animated/NativeAnimatedHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ const API = {
}
},
flushQueue: function (): void {
invariant(NativeAnimatedModule, 'Native animated module is not available');
// TODO: (T136971132)
// invariant(NativeAnimatedModule, 'Native animated module is not available');
flushQueueTimeout = null;

// Early returns before calling any APIs
Expand All @@ -165,16 +166,18 @@ const API = {
// use RCTDeviceEventEmitter. This reduces overhead of sending lots of
// JSI functions across to native code; but also, TM infrastructure currently
// does not support packing a function into native arrays.
NativeAnimatedModule.queueAndExecuteBatchedOperations?.(singleOpQueue);
NativeAnimatedModule?.queueAndExecuteBatchedOperations?.(singleOpQueue);
singleOpQueue.length = 0;
} else {
Platform.OS === 'android' && NativeAnimatedModule.startOperationBatch?.();
Platform.OS === 'android' &&
NativeAnimatedModule?.startOperationBatch?.();

for (let q = 0, l = queue.length; q < l; q++) {
queue[q]();
}
queue.length = 0;
Platform.OS === 'android' &&
NativeAnimatedModule.finishOperationBatch?.();
NativeAnimatedModule?.finishOperationBatch?.();
}
},
queueOperation: <Args: $ReadOnlyArray<mixed>, Fn: (...Args) => void>(
Expand Down
12 changes: 7 additions & 5 deletions Libraries/Animated/__tests__/Animated-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,13 @@ describe('Animated tests', () => {

expect(testRenderer.toJSON().props.style.opacity).toEqual(0);

Animated.timing(opacity, {
toValue: 1,
duration: 0,
useNativeDriver: false,
}).start();
TestRenderer.act(() => {
Animated.timing(opacity, {
toValue: 1,
duration: 0,
useNativeDriver: false,
}).start();
});

expect(testRenderer.toJSON().props.style.opacity).toEqual(1);
});
Expand Down

This file was deleted.

Loading

0 comments on commit 5cdf3cf

Please sign in to comment.