-
Notifications
You must be signed in to change notification settings - Fork 56
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
[Major]: refactor: useRouterService
instead of Ember Router
#270
Conversation
This fixes the following error: ``` Build Error (broccoli-persistent-filter:Babel > [Babel: @ember/test-helpers]) in @ember/test-helpers/dom/-is-focusable.js Cannot find module '@babel/compat-data/corejs3-shipped-proposals' Require stack: - /Users/jan/open-source/ember-router-scroll/node_modules/@babel/preset-env/lib/polyfills/corejs3/usage-plugin.js - /Users/jan/open-source/ember-router-scroll/node_modules/@babel/preset-env/lib/index.js - /Users/jan/open-source/ember-router-scroll/node_modules/@babel/core/lib/config/files/plugins.js - /Users/jan/open-source/ember-router-scroll/node_modules/@babel/core/lib/config/files/index.js - /Users/jan/open-source/ember-router-scroll/node_modules/@babel/core/lib/index.js - /Users/jan/open-source/ember-router-scroll/node_modules/broccoli-babel-transpiler/lib/worker.js ```
@buschtoens 👋 Let me know what you think!! |
@simonihmig as well if you have a moment! |
RouterService
instead of Ember Router
RouterService
instead of Ember Router
Co-authored-by: John Leja <[email protected]>
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.
Looks good. Just had two things to point out.
preserveScrollPosition = get(this, 'preserveScrollPosition') | ||
} | ||
|
||
if (!preserveScrollPosition) { |
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.
Can combine the two if (!preserveScrollPosition)
blocks
addon/services/router-scroll.js
Outdated
// out of the option, this happens on the tightest schedule | ||
scheduleOnce('render', this, CALLBACK, transition); | ||
} else if (scrollWhenAfterRender && !scrollWhenIdle) { | ||
// out of the option, this happens on the tightest schedule | ||
scheduleOnce('afterRender', this, CALLBACK, transition); |
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.
Are the duplicated comments here correct, or is scheduling after render
the option that happens on the tightest schedule?
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.
I wasn't able to verify this addon with a running app yet, but left some comments. Looks 👍 overall
@@ -2,6 +2,9 @@ | |||
|
|||
- Updating to th v3.0 series was due to removing `scrollWhenPainted` as a config option. Also, we fixed some hidden bugs with scheduling when to scroll to your last y position. | |||
|
|||
## 4.0.0 | |||
* [#270](https://github.com/DockYard/ember-router-scroll/pull/270) [Major]: use`RouterService` instead of Ember `Router` |
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.
Would it be helpful to also mention the changes users should make on updating to this version? Or do you expect them to find that in the PR?
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.
Great idea! I updated the README.
addon/services/router-scroll.js
Outdated
|
||
// If `preserveScrollPosition` was not set on the controller, attempt fallback to `preserveScrollPosition` which was set on the router service. | ||
if (!preserveScrollPosition) { | ||
preserveScrollPosition = get(this, 'preserveScrollPosition') |
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.
Mind adding this logic to the initial assignment? Double assignment and the two same if blocks are a bit confusing.
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.
That is a good idea!
addon/services/router-scroll.js
Outdated
if (url && url.indexOf('#') > -1 && hashElement) { | ||
scrollPosition = { x: hashElement.offsetLeft, y: hashElement.offsetTop }; | ||
} else { | ||
scrollPosition = get(this, 'position'); |
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.
What if you use this as the initial value (it gets overwritten in the if block if needed)
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.
Another good find. Thank you Chantal!
addon/services/router-scroll.js
Outdated
|
||
if (!preserveScrollPosition) { | ||
const scrollElement = get(this, 'scrollElement'); | ||
const targetElement = get(this, 'targetElement'); |
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.
Do you need the get
or could you use const { scrollElement, targetElement } = this;
?
addon/services/router-scroll.js
Outdated
// out of the option, this happens on the tightest schedule | ||
scheduleOnce('render', this, CALLBACK, transition); | ||
} else if (scrollWhenAfterRender && !scrollWhenIdle) { | ||
// out of the option, this happens on the tightest schedule |
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.
Should this be the same comment as above?
Co-authored-by: Chantal Broeren <[email protected]>
close #256 close #255
This will be released as a major bump ->
4.0
locations/router-scroll.js
. This has been deprecated and you should rely on Ember's own implementation instead of extending from us. HistoryLocation Subclass Question #193EmberRouterScroll
that you used to import and extend in your application. We handle that for you now and eagerly initialize the service for you. We did this because we can rely onRouterService
events instead of this.