Skip to content

Commit 746d584

Browse files
javachefacebook-github-bot
authored andcommittedDec 10, 2024·
Fix animation.stop not being flushed (#48199)
Summary: Pull Request resolved: #48199 `animatedShouldUseSingleOp` relies on a queue always being active, or for a call to `flushQueue` later down the line. If these are missing, a call will be queued up but only executed whenever the next animation flush happens. Changelog: [General][Fixed] Animation.stop() executes when `animatedShouldUseSingleOp` is enabled. Reviewed By: yungsters Differential Revision: D67025831 fbshipit-source-id: 66a7f50d833b7bbaf9f16dd04d24b90c7a699fa0
1 parent 8ab5243 commit 746d584

File tree

1 file changed

+10
-1
lines changed
  • packages/react-native/Libraries/Animated/animations

1 file changed

+10
-1
lines changed
 

‎packages/react-native/Libraries/Animated/animations/Animation.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,16 @@ export default class Animation {
7979

8080
stop(): void {
8181
if (this.#nativeID != null) {
82-
NativeAnimatedHelper.API.stopAnimation(this.#nativeID);
82+
const nativeID = this.#nativeID;
83+
const identifier = `${nativeID}:stopAnimation`;
84+
try {
85+
// This is only required when singleOpBatching is used, as otherwise
86+
// we flush calls immediately when there's no pending queue.
87+
NativeAnimatedHelper.API.setWaitingForIdentifier(identifier);
88+
NativeAnimatedHelper.API.stopAnimation(nativeID);
89+
} finally {
90+
NativeAnimatedHelper.API.unsetWaitingForIdentifier(identifier);
91+
}
8392
}
8493
this.__active = false;
8594
}

0 commit comments

Comments
 (0)
Please sign in to comment.