diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index 3735852dc41..c79fc75df5b 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -1092,6 +1092,24 @@ jsi::Value UIManagerBinding::get( }); } + if (methodName == "startViewTransitionReadyFinished") { + return jsi::Function::createFromHostFunction( + runtime, + name, + 0, + [uiManager]( + jsi::Runtime& runtime, + const jsi::Value& /*thisValue*/, + const jsi::Value* /*arguments*/, + size_t /*count*/) -> jsi::Value { + auto* viewTransitionDelegate = uiManager->getViewTransitionDelegate(); + if (viewTransitionDelegate != nullptr) { + viewTransitionDelegate->startViewTransitionReadyFinished(); + } + return jsi::Value::undefined(); + }); + } + if (methodName == "startViewTransition") { auto paramCount = 1; return jsi::Function::createFromHostFunction( diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerViewTransitionDelegate.h b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerViewTransitionDelegate.h index a21cd4e3d00..e8210799212 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerViewTransitionDelegate.h +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerViewTransitionDelegate.h @@ -41,6 +41,8 @@ class UIManagerViewTransitionDelegate { { } + virtual void startViewTransitionReadyFinished() {} + virtual void startViewTransitionEnd() {} struct ViewTransitionInstance { diff --git a/packages/react-native/ReactCommon/react/renderer/viewtransition/ViewTransitionModule.cpp b/packages/react-native/ReactCommon/react/renderer/viewtransition/ViewTransitionModule.cpp index 2aa9e80f083..3cda3cdc4d5 100644 --- a/packages/react-native/ReactCommon/react/renderer/viewtransition/ViewTransitionModule.cpp +++ b/packages/react-native/ReactCommon/react/renderer/viewtransition/ViewTransitionModule.cpp @@ -353,7 +353,7 @@ void ViewTransitionModule::startViewTransition( } applySnapshotsOnPseudoElementShadowNodes(); - + transitionReadyFinished_ = false; if (onReadyCallback) { onReadyCallback(); } @@ -366,6 +366,10 @@ void ViewTransitionModule::startViewTransition( } } +void ViewTransitionModule::startViewTransitionReadyFinished() { + transitionReadyFinished_ = true; +} + void ViewTransitionModule::suspendOnActiveViewTransition() { // Signal that the next transition should be suspended until the current // one finishes. The actual queueing happens in startViewTransition. diff --git a/packages/react-native/ReactCommon/react/renderer/viewtransition/ViewTransitionModule.h b/packages/react-native/ReactCommon/react/renderer/viewtransition/ViewTransitionModule.h index 7e8a332ee24..33331ba3c4f 100644 --- a/packages/react-native/ReactCommon/react/renderer/viewtransition/ViewTransitionModule.h +++ b/packages/react-native/ReactCommon/react/renderer/viewtransition/ViewTransitionModule.h @@ -53,6 +53,8 @@ class ViewTransitionModule : public UIManagerViewTransitionDelegate, std::function onReadyCallback, std::function onCompleteCallback) override; + void startViewTransitionReadyFinished() override; + void startViewTransitionEnd() override; std::optional getViewTransitionInstance(const std::string &name, const std::string &pseudo) @@ -128,6 +130,8 @@ class ViewTransitionModule : public UIManagerViewTransitionDelegate, bool transitionStarted_{false}; + bool transitionReadyFinished_{false}; + // When suspendNextTransition_ is true and a transition is active, the next // startViewTransition calls are queued instead of running immediately. bool suspendNextTransition_{false};