Skip to content
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

Avoid scroll on first load #169

Merged
merged 5 commits into from
Nov 6, 2018

Conversation

snewcomer
Copy link
Collaborator

@snewcomer snewcomer commented Nov 5, 2018

close #55

@@ -55,6 +55,11 @@ export default Mixin.create({
const url = get(this, 'currentURL');
const hashElement = url ? document.getElementById(url.split('#').pop()) : null

if (get(this, 'service.isFirstLoad')) {
get(this, 'service').unsetFirstLoad();
Copy link
Collaborator Author

@snewcomer snewcomer Nov 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we are currently calling scrollTo on first load here - however has no effect on first load for some reason on fast pages 🤷‍♂️. As detailed in the referenced issue, on first load, we should not try to scroll the page when we first enter the application. On slow requests, this does show up from time to time.

So using a flag isFirstLoad, we can prevent unnecessary work.

https://github.com/dollarshaveclub/ember-router-scroll/blob/master/addon/index.js#L75

@yowainwright
Copy link
Contributor

@snewcomer this looks more readable too. Would you mind adding a patch version bump?

@snewcomer
Copy link
Collaborator Author

@yowainwright Patch for 1.0.1 added! Good call.

@yowainwright yowainwright merged commit 3fbaab1 into DockYard:master Nov 6, 2018
@snewcomer snewcomer deleted the sn/no-scroll-first-load branch September 25, 2019 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

scroll position reset on slow loading fastboot served pages
2 participants