-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[fixed] Window scrolling #249
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
Conversation
The router now remembers the last window scroll position at various paths and automatically scrolls the window to match after transitions complete unless preserveScrollPosition=true is used. This commit also introduces a flux-style architecture to the high-level transitionTo/replaceWith/goBack methods. Fixes #189 Fixes #186
\o/ I was just thinking last night that we needed to finish this feature. |
AND bringing in a dispatcher/actions. this is fantastic |
Interesting implementation. In a server-rendered app you only return to scroll positions if you use the back button, but it appears that if I navigate with links from |
In the few quick tests that I did in Chrome it maintained the scroll position regardless of whether I was using the back/forward buttons or links. Makes for a super simple and predictable implementation. |
Yeah, I think its a novel approach, but you've been pretty adamant about On Fri, Aug 29, 2014 at 8:22 AM, Michael Jackson [email protected]
|
My initial implementation of this feature used a So that was the motivation for including the dispatcher in the first place. |
I just think it makes the most sense as the default since that's what everyone knows already. Mounting a |
I'm still a little unsure about clicking a link and getting the scroll position back. |
Well, let's just see how this feels. I agree there will probably be some fine tuning we still need to do. |
@@ -0,0 +1,18 @@ | |||
var copyProperties = require('react/lib/copyProperties'); | |||
var Dispatcher = require('react-dispatcher'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(require('flux')
now!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:D Awesome!
This also sounds a little odd to me but I'm willing to try it. |
@spicyj I keep wondering what is the difference between clicking a link to The only answer I have is "server-rendered apps won't preserve scroll position." Doesn't seem like a good enough reason to not preserve scroll position. |
Clicking a link and going to the last scroll position of that page doesn't make sense to me. |
yeah, me neither. should be pretty easy to make the change tho. just need to observe the source of the action. if it was a click, don't do the scroll thing. if it was popstate, do it. |
The router now remembers the last window scroll position at various
paths and automatically scrolls the window to match after transitions
complete unless preserveScrollPosition=true is used.
This commit also introduces a flux-style architecture to the high-level
transitionTo/replaceWith/goBack methods.
Fixes #189
Fixes #186