-
Notifications
You must be signed in to change notification settings - Fork 44
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
AnimatedView incorrectly renders focused scene when index !== children.length-1 #61
Comments
I'm working on the fix now. sorry about the inconvenience. |
The root cause of this is that the |
// Move off screen
const translateX = layout.width.interpolate({
inputRange: [0, 1],
outputRange: [0, -1],
}); |
Summary:The initial layout used to render scenes does not contain the actual width and height measured and causes the issue as described at ericvicenti/navigation-rfc#61 The fix is to update the layout and re-render scenes once layout is modified. Also scenes renderer should also consider the case that when the layout is not measured yet. Reviewed By: ericvicenti Differential Revision: D3162143 fb-gh-sync-id: 197574329d3849cad2a21e07e1bd5e800f74c3ea fbshipit-source-id: 197574329d3849cad2a21e07e1bd5e800f74c3ea
@jmurzy : we've added a new property Also, we've fixed the issue that the initial scenes aren't positioned properly. |
@hedgerwang Fixed in ^ that commit. Thanks! 🍻 |
Summary: The initial layout used to render scenes does not contain the actual width and height measured and causes the issue as described at ericvicenti/navigation-rfc#61 The fix is to update the layout and re-render scenes once layout is modified. Also scenes renderer should also consider the case that when the layout is not measured yet. Reviewed By: ericvicenti Differential Revision: D3203245 fb-gh-sync-id: 4de89b9b43bc993d7c970c831458bd31c094073e fbshipit-source-id: 4de89b9b43bc993d7c970c831458bd31c094073e
Summary:The initial layout used to render scenes does not contain the actual width and height measured and causes the issue as described at ericvicenti/navigation-rfc#61 The fix is to update the layout and re-render scenes once layout is modified. Also scenes renderer should also consider the case that when the layout is not measured yet. Reviewed By: ericvicenti Differential Revision: D3162143 fb-gh-sync-id: 197574329d3849cad2a21e07e1bd5e800f74c3ea fbshipit-source-id: 197574329d3849cad2a21e07e1bd5e800f74c3ea
Summary: The initial layout used to render scenes does not contain the actual width and height measured and causes the issue as described at ericvicenti/navigation-rfc#61 The fix is to update the layout and re-render scenes once layout is modified. Also scenes renderer should also consider the case that when the layout is not measured yet. Reviewed By: ericvicenti Differential Revision: D3203245 fb-gh-sync-id: 4de89b9b43bc993d7c970c831458bd31c094073e fbshipit-source-id: 4de89b9b43bc993d7c970c831458bd31c094073e
Summary:The initial layout used to render scenes does not contain the actual width and height measured and causes the issue as described at ericvicenti/navigation-rfc#61 The fix is to update the layout and re-render scenes once layout is modified. Also scenes renderer should also consider the case that when the layout is not measured yet. Reviewed By: ericvicenti Differential Revision: D3162143 fb-gh-sync-id: 197574329d3849cad2a21e07e1bd5e800f74c3ea fbshipit-source-id: 197574329d3849cad2a21e07e1bd5e800f74c3ea
Summary: The initial layout used to render scenes does not contain the actual width and height measured and causes the issue as described at ericvicenti/navigation-rfc#61 The fix is to update the layout and re-render scenes once layout is modified. Also scenes renderer should also consider the case that when the layout is not measured yet. Reviewed By: ericvicenti Differential Revision: D3203245 fb-gh-sync-id: 4de89b9b43bc993d7c970c831458bd31c094073e fbshipit-source-id: 4de89b9b43bc993d7c970c831458bd31c094073e
Summary:The initial layout used to render scenes does not contain the actual width and height measured and causes the issue as described at ericvicenti/navigation-rfc#61 The fix is to update the layout and re-render scenes once layout is modified. Also scenes renderer should also consider the case that when the layout is not measured yet. Reviewed By: ericvicenti Differential Revision: D3162143 fb-gh-sync-id: 197574329d3849cad2a21e07e1bd5e800f74c3ea fbshipit-source-id: 197574329d3849cad2a21e07e1bd5e800f74c3ea
Summary: The initial layout used to render scenes does not contain the actual width and height measured and causes the issue as described at ericvicenti/navigation-rfc#61 The fix is to update the layout and re-render scenes once layout is modified. Also scenes renderer should also consider the case that when the layout is not measured yet. Reviewed By: ericvicenti Differential Revision: D3203245 fb-gh-sync-id: 4de89b9b43bc993d7c970c831458bd31c094073e fbshipit-source-id: 4de89b9b43bc993d7c970c831458bd31c094073e
In the NavigationCompositionExample, tabs are implemented using a
NavigationView
.NavigationView
renders a singleScene
and does so by unmounting any previousScene
s. This is not desirable as component state is lost when switching tabs.I'm trying to implement tabs using
AnimatedView
andStackReducer
to keep the views mounted when navigated to and from usingJumpToIndex
orJumpTo
.AnimatedView
renders eachCard
in the orderScene
s are present inParentState
. It assumes thechildren.length-1
is the focusedCard
. So setting index inParentState
to anything other than the lastScene
has no effect except that the overlay renders correctly since it's passed theScene
at the correct index when render is called:As for the
Scenes
, the focusedCard
renders as the one atchildren.length-1
. So theindex
provided by the reducer is ignored.One way to fix this is to look at how
AnimatedView
delegates transition management toStyleInterpolator
s.Take
forHorizontal
for example:Here the implementation "configures" the focused
Card
to be the last in the stack. Since,StyleInterpolator
is the delegate that coordinates how the actual views transition on the screen, unlikeAnimatedView
, it's possible to change the implementation to render the focused view correctly and make transition animations work as expected.The solution 🚧 I came up with is to push the views to the right of the focused
Card
off screen:Here I'm using
width <= 0
😭 to determine the direction of navigation. A better way would be to include a prevIndex value in theParentState
type so that we can do this:Of course, we'd also have to make some changes to
jumpToIndex
,jumpTo
etc in NavigationStateUtils to implicitly keep track of prevIndex.Alternatively, we could create a custom reducer to achieve pretty much the same thing. But that feels like boilerplate.
For those of you who are looking into implementing tabs using this approach, the transition animations can be "turned off" for tabs by supplying an
applyAnimation
fn toAnimatedView
:So far this solution has been working great. But I strongly think some of this can be moved into
NavigationExperimental
.I'd be happy to turn some of these ideas into a PR. Or perhaps there is another way to achieve this that I'm missing?
Oh and, thanks for all the work you guys have been doing on these. 🚀
🍺
The text was updated successfully, but these errors were encountered: