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

Best way to eliminate scroll to top on route change #989

Closed
Slevinski opened this Issue Mar 17, 2016 · 4 comments

Comments

Projects
None yet
5 participants
@Slevinski
Copy link

Slevinski commented Mar 17, 2016

I have a problem where scrolling to the top of the page on route changes is not desired.

I'm using hash routing. The left side of the page contains a list of items that grows using infinite scroll. The right side of the page is displayed in a fixed position so that it is always visible. Clicking on an item on the left of the page changes the hash, which updates the right side of the page. Unfortunately, the function setScroll scrolls the page to the top, so the user looses their place.

My temporary work around is to redefine the window.scrollTo function to do nothing before adding mithril to the page, and then restoring the scrollTo function after mithril has been created. Definite kludge. Any better ideas?

@tobscure

This comment has been minimized.

Copy link
Contributor

tobscure commented Mar 19, 2016

#567 Is this relevant?

You could save the current scroll position somewhere (e.g. in the click handler, or in the view function?) and then restore it in the config function.

@Slevinski

This comment has been minimized.

Copy link

Slevinski commented Mar 20, 2016

Thanks. That sounds like a much better approach. I'm not sure exactly how the code would look, but I should be able to figure it out. Thanks for the idea.

@lhorie

This comment has been minimized.

Copy link
Member

lhorie commented Aug 10, 2016

this behavior is removed in rewrite

@lhorie lhorie closed this Aug 10, 2016

@volnei

This comment has been minimized.

Copy link

volnei commented Feb 10, 2017

But changing to different pages is terrible to keep the another page scroll position. I think this must be configurable cause the most acceptable behavior is scrolling to top, this is the way any website works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment