-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[added] <Route ignoreScrollBehavior /> to opt out of scroll behavior for itself and descendants #388
Conversation
I refuse to accept a "better" picture On Saturday, October 11, 2014, Dan Abramov notifications@github.com wrote:
|
🎨 |
I think the best way to test this would be to stub out the For example, you could setup your routes exactly as you have them here, start at the |
63bea87
to
a333734
Compare
@mjackson I added some tests, are they OK? |
…for itself and descendants
@mjackson this looks good to me, you 👍 ? |
[added] <Route ignoreScrollBehavior /> to opt out of scroll behavior for itself and descendants
Thanks @gaearon ! Looks great. |
Thanks @gaearon ! You're way too fast! I was going to start working on this, and found it is already done! Looks like I have some time now, if anything else needs to be done. |
This PR adds
ignoreScrollBehavior
onRoute
component as discussed in #326.It seems to work on my project but I'd like to hear your opinions on how I should approach testing.
Should I unit-test
Routes
,ScrollContext
, or what?If you specify
ignoreScrollBehavior
on a route, scroll behavior will not be triggered when transitioning within that route. It will, however, be triggered when transitioning outside this route. This allows us to support a variety of scenarios where you might want scroll behavior to be ignored:In the first case, by specifying
ignoreScrollBehavior
onsearch
route we ensure that transitions fromsearch
tosearch
(which is what happens when you type a search query) will not trigger scroll behavior, but transitions fromsearch
tohome
and back will.In the second case, by specifying
ignoreScrollBehavior
onhome
parent route, we say transitions withinhome
(e.g. fromfeed
todiscover
and back) don't trigger scroll behavior. However if you go fromfeed
toabout
, scroll behavior will be respected.(I'll draw a better picture later :-)
By default, scroll behavior is performed on all transitions (red arrows). Routes can create “scrolling realms” for themselves and their descendants by specifying
ignoreScrollBehavior
(purple areas). Transitions that are fully confined to a single scrolling realm, don't have any scroll behavior performed (blue arrows). If transition is not fully confined to a scrolling realm,scrollBehavior
ofRoutes
is respected.