-
Notifications
You must be signed in to change notification settings - Fork 24.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Navigator] Animated replace #1981
[Navigator] Animated replace #1981
Comments
Was thinking about the same. |
What do you think, Eric? |
I think the API looks reasonable, and we have actually experimented with something similar. We're working on some big changes to Navigator to get the route stack logic out, and to upgrade to the new Animated API. This should be pretty easy to add when we make those changes |
Animated replace would've been awesome! I often find it useful to |
I'm doing something like this now to skip a payment screen route that I really don't want in the stack:
It works, but I'd really rather not have this screen have the responsibility to know about the previous routes. |
@miracle2k for this specific use case, take a look at our implementation https://github.com/este/native/blob/master/src/app/app.react.js#L105-L108. We are decorating Navigator with few handy methods and passing it down, this particular one works quite well. |
For now maybe you could do a push and then |
@ericvicenti cool. so |
Inspired by the suggestion from @grabbou, I am now using this workaround:
Note the overwrites of |
@miracle2k Although that allows |
@miracle2k @fender I found this problem too, the view i want to replace was a view which using camera, and using this way the camera page cannot be unmounted and it is keep using the camera, which makes my App deny by App Store because of something like "using camera background". I am now using setTimeout to push new view back after poping current view. Hope next official release can fix this. |
I still find this problem as well, when I have sceneconfig set, it does not work for type replace even though it does for pop |
Any ETA on this, @ericvicenti ? |
Looks like following code works well, could it be used as workaround?
|
@grabbou that is going to remove all prev routes i guess. Few ideas:
Crazy hack:
|
I try another way which execute normally.
hope make sense. regards. |
For now I use this workaround: then in my code I do:
not too elegant, but seems to work :) |
I have tried all of these solutions above but all didn't work. These are my code below. Most of them are copied from Navigator source code. What I did is just combine them in a right way. Um...of course, they still can be optimized. And they too much hard to understand. Trust me, I won't understand after tonight. But it works. It's enough.
After defining that in prototype, you can use it anywhere you want. |
Performace is too slow above provide method, can anyone optimized it |
@waleedarshad-vf I used it in online production and after compiling them by react native and set to production mode. It's quite fluent. Have you tried the production mode? |
@zhaotai thanks for you reply. I tried it again last day and it is working now. i don't know what happened that time. it might be due to low memory of the device. |
@waleedarshad-vf Yeah, especially you develop in the simulator. The application memory will increase along with your code complication increasing and as a result the navigating and animation which is implemented by js code instead of native module will become slow and unsmooth. |
@zhaotai one thing to be mention here that it is not as smooth as the push method of Navigator but thanks for Awesome work |
@zhaotai it needs attention to make it as smooth as push method. the tester here points out this jerk animation issue in a single attempt. |
@waleedarshad-vf I will try, thanks for suggestion. Maybe you can improve it, too. |
Hi there! This issue is being closed because it has been inactive for a while. But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/navigator-animated-replace ProductPains helps the community prioritize the most important issues thanks to its voting feature. Also, if this issue is a bug, please consider sending a pull request with a fix. |
New feature This commit will add replaceWithAnimation function to the Navigator component which will allow the user to replace a route while having the default transition animation of the target scene. fixes facebook/react-native#1981 Implemented based of Stack-Overflow solution - http://stackoverflow.com/questions/40393380/react-native-transition-animation-for-navigator-replace Test plan the following repository [ReactNativeNavigationDemo (branch replaceWithAnimation)](https://github.com/DaniAkash/ReactNativeNavigationDemo/tree/replaceWithAnimation) has a page implemented using the replaceWithAnimation function in SplashPage.js which replaces the splash page with the homepage and it is tested with various use cases and found that the component is working as expected. This Pull request was previously created at facebook/react-native#12881
I often find myself wanting to "replace" a route i.e not adding to the history yet have the route change animate.
In iOS I would do something like this.
Maybe this is related to issue #1953 I think I would prefer an api where we could do
The text was updated successfully, but these errors were encountered: