react-router-native-stack icon indicating copy to clipboard operation
react-router-native-stack copied to clipboard

Navigate to the previous scroll position when navigating back

Open kfamilonidis opened this issue 7 years ago • 6 comments

I'm using scroll views and when the user scrolls to the end of a scroll, clicks a link, goes to a next screen and navigates back to the first scroll view, the position that he is is not the same as it was before navigating forward. One would expect the position would be the same, and not at the top of the scroll view. I'm trying to fix this by inspecting the position the user is anytime they scroll so when they navigate back I automatically scroll to this position but the effect is not so nice. Any ideas on how can I make this run smoothly ?

kfamilonidis avatar Jan 30 '18 09:01 kfamilonidis

Oh dang that does sound like a problem, it sounds like this is a reason for keeping routes in the stack mounted rather than un-mounting them when a new route pushes in.

I'm not sure of a better fix in the meantime, but I can look into keeping routes in the stack mounted so that they don't lose their state (or scroll position in this case)

Traviskn avatar Feb 02 '18 04:02 Traviskn

I agree, it is better to keep routes mounted so they don't lose their state. Losing scrolling position is a bad for UX, but actual bugs comes because of losing states of unmounted pages and their child components.

rosskhanas avatar Feb 02 '18 04:02 rosskhanas

@Traviskn I agree that keeping routes mounted makes more sense. This is why even native components like UINavigationController on iOS keep their UIViewControllers mounted after a push. Otherwise, you close off the user from being able to properly use callbacks or delegation pattern in their apps. Any ETA on when you'd fix this? Or if you could point me to the code path, I'm happy to make a PR.

egold avatar Mar 31 '18 03:03 egold

Sorry no ETA, I haven't had much time to work on this library recently. Keeping the stack of components in the stack mounted would be a big foundational change to how the StackTransitioner works, so it wouldn't be a quick/easy thing to do. lib/StackTransitioner.js is where I'd recommend looking if you'd like to take a stab at it! I'd be open to PRs implementing this change

Traviskn avatar Aug 18 '18 20:08 Traviskn

Is someone looking into this enhancement?

gmverdon avatar Nov 10 '18 19:11 gmverdon

When can I use it?

jinyang1994 avatar Aug 26 '19 06:08 jinyang1994