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

scrollTo issues on page refresh. #534

Closed
saniko opened this Issue Apr 6, 2015 · 5 comments

Comments

Projects
None yet
3 participants
@saniko

saniko commented Apr 6, 2015

when i scroll down my spa to bottom and then hit refresh button, the
page renders back exactly where i scrolled.
i need that on page refresh the page will render at top (same as on route change)
i have added a config function with window.scrollTo(0,0). but with no results
any suggestions/

Thanks.

@tobscure

This comment has been minimized.

Contributor

tobscure commented Apr 6, 2015

Maybe do the window.scrollTo after a delay (with setTimeout).

This is just something that browsers do, not a framework issue.

@barneycarroll

This comment has been minimized.

Member

barneycarroll commented Apr 6, 2015

@tobscure's right — this the way browsers are expected to behave. It's especially useful when you're browsing from site to site then hit back and end up where you left.

I vaguely remember wanting to circumvent this behaviour years ago and I found it really difficult to find the right event handler for when to execute scrollTo — I tried DOM ready, onload, and others but I couldn't ensure my scrollTo would happen after the browser's default behaviour kicked in. setTimeout( yourFn, someArbitraryNumber ) kinda worked, but the effect of yanking the user back to 0 after the behaviour had kicked in was unpleasant. Of course you could hide the whole page until that point, but then things are so contrived that you're just giving a different kind of compromised user experience. I gave up and decided to let the page work as the browser dictated.

This is one of the many experiences I had working in a design agency that led me to conclude that unless you have really good reasons, you should probably just let your site behave the way the user expects. :)

@saniko

This comment has been minimized.

saniko commented Apr 6, 2015

LOL.... of course...
How trivial, some times i"m so into solving the "problems" of VD that i forget the trivial stuff.
Thanks.

@saniko saniko closed this Apr 6, 2015

@saniko

This comment has been minimized.

saniko commented Apr 6, 2015

Thanks Barney, you right i will leave this to default behavior.

@barneycarroll

This comment has been minimized.

Member

barneycarroll commented Apr 6, 2015

@saniko I can totally relate to that! One of the reasons I love the Mithril community: rather than offer solutions to whatever problem we find, we can often help each-other find the right problems ;)

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