Open kuznetsov-from-wonderland opened 4 years ago
Is it possible to animate navigation.goBack()
?
i had this same problem a few minutes ago. occurs because the default navigation replace method is push.
solution: in your navigator's screenOption add animationTypeForReplace:"pop"
i had this same problem a few minutes ago. occurs because the default navigation replace method is push.
solution: in your navigator's screenOption add
animationTypeForReplace:"pop"
Thanks! But have no effect 🤷♂️
I can confirm this happening in my app, on Android only. It doesn't happen when using the hardware back button; see my related comment in #71.
I tried uncommenting all the Log.d
calls (currently commented out) in RNSharedElementTransition.java
, ran my app, and inspected adb logcat
. Here are the resulting annotated logs:
# navigating from screen A to screen B
07-23 21:00:50.644 6366 6366 D RNSharedElementTransition: updateLayout: 0.0
07-23 21:00:50.647 6366 6366 D RNSharedElementTransition: updateLayout: 0.0
07-23 21:00:50.648 6366 6366 D RNSharedElementTransition: setNodePosition 0.33446404, mInitialLayoutPassCompleted: true
07-23 21:00:50.649 6366 6366 D RNSharedElementTransition: updateLayout: 0.33446404
07-23 21:00:50.649 6366 6366 D RNSharedElementTransition: setNodePosition 0.33446404, mInitialLayoutPassCompleted: true
07-23 21:00:50.649 6366 6366 D RNSharedElementTransition: updateLayout: 0.33446404
07-23 21:00:50.649 6366 6366 D RNSharedElementTransition: dispatchDraw, mRequiresClipping: true, width: 1080, height: 1157
07-23 21:00:50.650 6366 6366 D RNSharedElementTransition: dispatchDraw, mRequiresClipping: false, width: 790, height: 229
07-23 21:00:50.660 6366 6366 D RNSharedElementTransition: setNodePosition 0.48871756, mInitialLayoutPassCompleted: true
07-23 21:00:50.660 6366 6366 D RNSharedElementTransition: updateLayout: 0.48871756
07-23 21:00:50.661 6366 6366 D RNSharedElementTransition: setNodePosition 0.48871756, mInitialLayoutPassCompleted: true
07-23 21:00:50.661 6366 6366 D RNSharedElementTransition: updateLayout: 0.48871756
07-23 21:00:50.677 6366 6366 D RNSharedElementTransition: setNodePosition 0.6264305, mInitialLayoutPassCompleted: true
07-23 21:00:50.677 6366 6366 D RNSharedElementTransition: updateLayout: 0.6264305
07-23 21:00:50.678 6366 6366 D RNSharedElementTransition: setNodePosition 0.6264305, mInitialLayoutPassCompleted: true
07-23 21:00:50.678 6366 6366 D RNSharedElementTransition: updateLayout: 0.6264305
07-23 21:00:50.690 6366 6366 D RNSharedElementTransition: setNodePosition 0.718984, mInitialLayoutPassCompleted: true
07-23 21:00:50.691 6366 6366 D RNSharedElementTransition: updateLayout: 0.718984
07-23 21:00:50.691 6366 6366 D RNSharedElementTransition: setNodePosition 0.718984, mInitialLayoutPassCompleted: true
07-23 21:00:50.691 6366 6366 D RNSharedElementTransition: updateLayout: 0.718984
07-23 21:00:50.707 6366 6366 D RNSharedElementTransition: setNodePosition 0.78188026, mInitialLayoutPassCompleted: true
07-23 21:00:50.708 6366 6366 D RNSharedElementTransition: updateLayout: 0.78188026
07-23 21:00:50.708 6366 6366 D RNSharedElementTransition: setNodePosition 0.78188026, mInitialLayoutPassCompleted: true
07-23 21:00:50.708 6366 6366 D RNSharedElementTransition: updateLayout: 0.78188026
07-23 21:00:50.724 6366 6366 D RNSharedElementTransition: setNodePosition 0.8274976, mInitialLayoutPassCompleted: true
07-23 21:00:50.724 6366 6366 D RNSharedElementTransition: updateLayout: 0.8274976
07-23 21:00:50.724 6366 6366 D RNSharedElementTransition: setNodePosition 0.8274976, mInitialLayoutPassCompleted: true
07-23 21:00:50.724 6366 6366 D RNSharedElementTransition: updateLayout: 0.8274976
07-23 21:00:50.740 6366 6366 D RNSharedElementTransition: setNodePosition 0.86223525, mInitialLayoutPassCompleted: true
07-23 21:00:50.740 6366 6366 D RNSharedElementTransition: updateLayout: 0.86223525
07-23 21:00:50.740 6366 6366 D RNSharedElementTransition: setNodePosition 0.86223525, mInitialLayoutPassCompleted: true
07-23 21:00:50.740 6366 6366 D RNSharedElementTransition: updateLayout: 0.86223525
07-23 21:00:50.758 6366 6366 D RNSharedElementTransition: setNodePosition 0.88956416, mInitialLayoutPassCompleted: true
07-23 21:00:50.758 6366 6366 D RNSharedElementTransition: updateLayout: 0.88956416
07-23 21:00:50.758 6366 6366 D RNSharedElementTransition: setNodePosition 0.88956416, mInitialLayoutPassCompleted: true
07-23 21:00:50.758 6366 6366 D RNSharedElementTransition: updateLayout: 0.88956416
07-23 21:00:50.774 6366 6366 D RNSharedElementTransition: setNodePosition 0.9115343, mInitialLayoutPassCompleted: true
07-23 21:00:50.774 6366 6366 D RNSharedElementTransition: updateLayout: 0.9115343
07-23 21:00:50.774 6366 6366 D RNSharedElementTransition: setNodePosition 0.9115343, mInitialLayoutPassCompleted: true
07-23 21:00:50.774 6366 6366 D RNSharedElementTransition: updateLayout: 0.9115343
07-23 21:00:50.790 6366 6366 D RNSharedElementTransition: setNodePosition 0.92944765, mInitialLayoutPassCompleted: true
07-23 21:00:50.790 6366 6366 D RNSharedElementTransition: updateLayout: 0.92944765
07-23 21:00:50.791 6366 6366 D RNSharedElementTransition: setNodePosition 0.92944765, mInitialLayoutPassCompleted: true
07-23 21:00:50.791 6366 6366 D RNSharedElementTransition: updateLayout: 0.92944765
07-23 21:00:50.807 6366 6366 D RNSharedElementTransition: setNodePosition 0.9441806, mInitialLayoutPassCompleted: true
07-23 21:00:50.807 6366 6366 D RNSharedElementTransition: updateLayout: 0.9441806
07-23 21:00:50.807 6366 6366 D RNSharedElementTransition: setNodePosition 0.9441806, mInitialLayoutPassCompleted: true
07-23 21:00:50.807 6366 6366 D RNSharedElementTransition: updateLayout: 0.9441806
07-23 21:00:50.824 6366 6366 D RNSharedElementTransition: setNodePosition 0.95635056, mInitialLayoutPassCompleted: true
07-23 21:00:50.824 6366 6366 D RNSharedElementTransition: updateLayout: 0.95635056
07-23 21:00:50.824 6366 6366 D RNSharedElementTransition: setNodePosition 0.95635056, mInitialLayoutPassCompleted: true
07-23 21:00:50.824 6366 6366 D RNSharedElementTransition: updateLayout: 0.95635056
07-23 21:00:50.840 6366 6366 D RNSharedElementTransition: setNodePosition 0.96640885, mInitialLayoutPassCompleted: true
07-23 21:00:50.841 6366 6366 D RNSharedElementTransition: updateLayout: 0.96640885
07-23 21:00:50.841 6366 6366 D RNSharedElementTransition: setNodePosition 0.96640885, mInitialLayoutPassCompleted: true
07-23 21:00:50.841 6366 6366 D RNSharedElementTransition: updateLayout: 0.96640885
07-23 21:00:50.856 6366 6366 D RNSharedElementTransition: setNodePosition 0.9746955, mInitialLayoutPassCompleted: true
07-23 21:00:50.857 6366 6366 D RNSharedElementTransition: updateLayout: 0.9746955
07-23 21:00:50.859 6366 6366 D RNSharedElementTransition: setNodePosition 0.9746955, mInitialLayoutPassCompleted: true
07-23 21:00:50.859 6366 6366 D RNSharedElementTransition: updateLayout: 0.9746955
07-23 21:00:50.879 6366 6366 D RNSharedElementTransition: setNodePosition 0.98147327, mInitialLayoutPassCompleted: true
07-23 21:00:50.879 6366 6366 D RNSharedElementTransition: updateLayout: 0.98147327
07-23 21:00:50.879 6366 6366 D RNSharedElementTransition: setNodePosition 0.98147327, mInitialLayoutPassCompleted: true
07-23 21:00:50.879 6366 6366 D RNSharedElementTransition: updateLayout: 0.98147327
07-23 21:00:50.894 6366 6366 D RNSharedElementTransition: setNodePosition 0.98694944, mInitialLayoutPassCompleted: true
07-23 21:00:50.894 6366 6366 D RNSharedElementTransition: updateLayout: 0.98694944
07-23 21:00:50.894 6366 6366 D RNSharedElementTransition: setNodePosition 0.98694944, mInitialLayoutPassCompleted: true
07-23 21:00:50.894 6366 6366 D RNSharedElementTransition: updateLayout: 0.98694944
07-23 21:00:50.911 6366 6366 D RNSharedElementTransition: setNodePosition 0.9912905, mInitialLayoutPassCompleted: true
07-23 21:00:50.911 6366 6366 D RNSharedElementTransition: updateLayout: 0.9912905
07-23 21:00:50.912 6366 6366 D RNSharedElementTransition: setNodePosition 0.9912905, mInitialLayoutPassCompleted: true
07-23 21:00:50.912 6366 6366 D RNSharedElementTransition: updateLayout: 0.9912905
07-23 21:00:50.922 6366 6366 D RNSharedElementTransition: setNodePosition 0.99463224, mInitialLayoutPassCompleted: true
07-23 21:00:50.923 6366 6366 D RNSharedElementTransition: updateLayout: 0.99463224
07-23 21:00:50.923 6366 6366 D RNSharedElementTransition: setNodePosition 0.99463224, mInitialLayoutPassCompleted: true
07-23 21:00:50.923 6366 6366 D RNSharedElementTransition: updateLayout: 0.99463224
07-23 21:00:50.940 6366 6366 D RNSharedElementTransition: setNodePosition 0.9970871, mInitialLayoutPassCompleted: true
07-23 21:00:50.940 6366 6366 D RNSharedElementTransition: updateLayout: 0.9970871
07-23 21:00:50.941 6366 6366 D RNSharedElementTransition: setNodePosition 0.9970871, mInitialLayoutPassCompleted: true
07-23 21:00:50.942 6366 6366 D RNSharedElementTransition: updateLayout: 0.9970871
07-23 21:00:50.955 6366 6366 D RNSharedElementTransition: setNodePosition 0.99874896, mInitialLayoutPassCompleted: true
07-23 21:00:50.955 6366 6366 D RNSharedElementTransition: updateLayout: 0.99874896
07-23 21:00:50.955 6366 6366 D RNSharedElementTransition: setNodePosition 0.99874896, mInitialLayoutPassCompleted: true
07-23 21:00:50.955 6366 6366 D RNSharedElementTransition: updateLayout: 0.99874896
07-23 21:00:50.973 6366 6366 D RNSharedElementTransition: setNodePosition 0.9996973, mInitialLayoutPassCompleted: true
07-23 21:00:50.973 6366 6366 D RNSharedElementTransition: updateLayout: 0.9996973
07-23 21:00:50.973 6366 6366 D RNSharedElementTransition: setNodePosition 0.9996973, mInitialLayoutPassCompleted: true
07-23 21:00:50.973 6366 6366 D RNSharedElementTransition: updateLayout: 0.9996973
07-23 21:00:50.992 6366 6366 D RNSharedElementTransition: setNodePosition 1.0, mInitialLayoutPassCompleted: true
07-23 21:00:50.992 6366 6366 D RNSharedElementTransition: updateLayout: 1.0
07-23 21:00:50.993 6366 6366 D RNSharedElementTransition: setNodePosition 1.0, mInitialLayoutPassCompleted: true
07-23 21:00:50.993 6366 6366 D RNSharedElementTransition: updateLayout: 1.0
# waiting for a few seconds and then going back...
07-23 21:01:10.161 6366 6366 D RNSharedElementTransition: updateLayout: 0.0
07-23 21:01:10.164 6366 6366 D RNSharedElementTransition: updateLayout: 0.0
07-23 21:01:10.166 6366 6366 D RNSharedElementTransition: setNodePosition 1.0, mInitialLayoutPassCompleted: true
07-23 21:01:10.166 6366 6366 D RNSharedElementTransition: updateLayout: 1.0
07-23 21:01:10.168 6366 6366 D RNSharedElementTransition: setNodePosition 1.0, mInitialLayoutPassCompleted: true
07-23 21:01:10.168 6366 6366 D RNSharedElementTransition: updateLayout: 1.0
07-23 21:01:10.169 6366 6366 D RNSharedElementTransition: dispatchDraw, mRequiresClipping: true, width: 1080, height: 1157
07-23 21:01:10.169 6366 6366 D RNSharedElementTransition: dispatchDraw, mRequiresClipping: false, width: 790, height: 229
I further noticed that afterwards, when scrolling through the RecyclerListViews that I have on the source screen, further events related to the transition are logged – even though it's supposed to have finished long ago!
# I did no further transitions, just scrolled around – and then...
07-23 21:07:50.258 6366 6366 D RNSharedElementTransition: setNodePosition 0.0, mInitialLayoutPassCompleted: true
07-23 21:07:50.258 6366 6366 D RNSharedElementTransition: updateLayout: 0.0
07-23 21:07:50.258 6366 6366 D RNSharedElementTransition: setNodePosition 0.0, mInitialLayoutPassCompleted: true
07-23 21:07:50.259 6366 6366 D RNSharedElementTransition: updateLayout: 0.0
07-23 21:07:50.264 6366 6366 D RNSharedElementTransition: setNodePosition 1.0, mInitialLayoutPassCompleted: true
07-23 21:07:50.267 6366 6366 D RNSharedElementTransition: updateLayout: 1.0
07-23 21:07:50.267 6366 6366 D RNSharedElementTransition: setNodePosition 1.0, mInitialLayoutPassCompleted: true
07-23 21:07:50.267 6366 6366 D RNSharedElementTransition: updateLayout: 1.0
07-23 21:07:50.269 6366 6366 D RNSharedElementTransition: dispatchDraw, mRequiresClipping: true, width: 1080, height: 1157
07-23 21:07:50.269 6366 6366 D RNSharedElementTransition: dispatchDraw, mRequiresClipping: false, width: 790, height: 229
07-23 21:07:50.371 6366 6366 D RNSharedElementTransition: setNodePosition 0.0, mInitialLayoutPassCompleted: true
07-23 21:07:50.371 6366 6366 D RNSharedElementTransition: updateLayout: 0.0
07-23 21:07:50.372 6366 6366 D RNSharedElementTransition: setNodePosition 0.0, mInitialLayoutPassCompleted: true
07-23 21:07:50.372 6366 6366 D RNSharedElementTransition: updateLayout: 0.0
07-23 21:07:50.375 6366 6366 D RNSharedElementTransition: setNodePosition 1.0, mInitialLayoutPassCompleted: true
07-23 21:07:50.376 6366 6366 D RNSharedElementTransition: updateLayout: 1.0
07-23 21:07:50.376 6366 6366 D RNSharedElementTransition: setNodePosition 1.0, mInitialLayoutPassCompleted: true
07-23 21:07:50.376 6366 6366 D RNSharedElementTransition: updateLayout: 1.0
07-23 21:07:50.379 6366 6366 D RNSharedElementTransition: dispatchDraw, mRequiresClipping: true, width: 1080, height: 1157
07-23 21:07:50.379 6366 6366 D RNSharedElementTransition: dispatchDraw, mRequiresClipping: false, width: 790, height: 229
Any updates on this? @kromsik @IjzerenHein
Thanks
Any updates on this @kromsik @IjzerenHein ? Thanks
Having the same problem.
Had a similar issue, appeared due to a nested Tab Navigator, workaround provided in https://github.com/IjzerenHein/react-navigation-shared-element/issues/77
The solution in #77 did not work for me.
I found a workaround that did work in my case.
When using the back button from the stack navigator header, the animation appeared. However, when calling navigation.goBack() the animation did not appear. I want to hide the header so using it is not an option for me.
It seems like the goBack function of react-navigation-shared-element isn't implemented the same way as the goBack function from @react-navigation/stack.
The workaround I have come up with is to create my own goBack function (called "goBack_WORKAROUND") and using that instead.
import React from 'react';
import {StackActions} from '@react-navigation/native';
import debounce from '@react-navigation/stack/src/utils/debounce';
/************
* Start of component
************/
const DetailsScreen = ({navigation, route}) => {
const goBack_WORKAROUND = React.useCallback(
debounce(() => {
if (navigation.isFocused() && navigation.canGoBack()) {
navigation.dispatch({
...StackActions.pop(),
source: route.key,
});
}
}, 50),
[navigation, route.key]
);
return (
<>
<MyBeautifulBackButton onPress={()=>goBack_WORKAROUND()}/>
</>
)
})
export default DetailsScreen;
I guess you could put this into its own file for better reusability.
Hope this helps everyone!
Same issue here! Not triggered transition in navigation.goBack() call but transition is working when I press back button (device back button in android).
Having the same issue, and when I try @KDKHD's solution, I run into https://github.com/IjzerenHein/react-navigation-shared-element/issues/109
Any update?