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

Update to 3.12 #202

Merged
merged 10 commits into from
Nov 23, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2017,
ecmaVersion: 2018,
sourceType: 'module'
},
plugins: [
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# misc
/.env*
/.pnp*
/.sass-cache
/connect.lock
/coverage/
Expand Down
25 changes: 6 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
ember-router-scroll
==============================================================================

[![Build Status](https://travis-ci.org/dollarshaveclub/ember-router-scroll.svg?branch=master)](https://travis-ci.org/dollarshaveclub/ember-router-scroll)
[![Greenkeeper badge](https://badges.greenkeeper.io/dollarshaveclub/ember-router-scroll.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/DockYard/ember-router-scroll.svg?branch=master)](https://travis-ci.org/DockYard/ember-router-scroll)

> Scroll to page top on transition, like a non-SPA website. An alternative scroll behavior for Ember applications.

Expand All @@ -24,10 +23,10 @@ Compatibility
* Ember CLI v2.13 or above


Installation
Installation
------------------------------------------------------------------------------

```
```sh
ember install ember-router-scroll
```

Expand All @@ -54,7 +53,7 @@ const Router = EmberRouter.extend(PageTrackerMixin, RouterScroll, {

Edit `config/environment.js` and change `locationType`.
Also add `historySupportMiddleware: true,` to get live-reload working in nested routes.
(See [Issue #21](https://github.com/dollarshaveclub/ember-router-scroll/issues/21))
(See [Issue #21](https://github.com/DockYard/ember-router-scroll/issues/21))

```javascript
locationType: 'router-scroll',
Expand Down Expand Up @@ -240,7 +239,7 @@ Note: if `preserveScrollPosition` is set to true on the service, it will overrid

**1.** Manage preserveScrollPosition via service

When you need to modify `preserveScrollPosition` on the service for a specific transition, you should always reset the value after the transition occurs, otherwise all future transitions will use the same `preserveScrollPosition` value.
When you need to modify `preserveScrollPosition` on the service for a specific transition, you should always reset the value after the transition occurs, otherwise all future transitions will use the same `preserveScrollPosition` value.

Example:

Expand Down Expand Up @@ -273,19 +272,7 @@ export default Component.extend({

* `npm test` (Runs `ember try:testall` to test your addon against multiple Ember versions)
* `ember test`
* `ember test --server`

## Automatic Updates

This repository uses [Greenkeeper](https://greenkeeper.io/) to manage dependencies.
Before doing manual updates to dependencies, please check if a Greenkeeper pull request for the update already exists.

Greenkeeper updates are updated and merged following the steps listed below.

* `git checkout <greenkeeper-pull-request>`
* `nvm i`
* `yarn`
* `yarn update`
* `ember test --serve

License
------------------------------------------------------------------------------
Expand Down
22 changes: 10 additions & 12 deletions addon/services/router-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ const RouterScroll = Service.extend({
}
},

get position() {
const scrollMap = get(this, 'scrollMap');
const stateUuid = get(window, 'history.state.uuid');

set(this, 'key', stateUuid);
const key = getWithDefault(this, 'key', '-1');

return getWithDefault(scrollMap, key, scrollMap.default);

Choose a reason for hiding this comment

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

Maybe don't use getWithDefault? It only defaults if the value of the key is undefined, but if it's null then the default value won't be used.
https://github.com/emberjs/ember.js/blob/master/packages/%40ember/-internals/metal/lib/property_get.ts#L192

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah right. Great point. Just saw an RFC to deprecate as well. It is confusing!

},

_loadConfig() {
const config = getOwner(this).resolveRegistration('config:environment');

Expand All @@ -92,16 +102,4 @@ const RouterScroll = Service.extend({
}
});

Object.defineProperty(RouterScroll.prototype, 'position', {
get() {
const scrollMap = get(this, 'scrollMap');
const stateUuid = get(window, 'history.state.uuid');

set(this, 'key', stateUuid);
const key = getWithDefault(this, 'key', '-1');

return getWithDefault(scrollMap, key, scrollMap.default);
}
});

export default RouterScroll;
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"devDependencies": {
"@ember/optional-features": "^0.6.3",
"broccoli-asset-rev": "^3.0.0",
"ember-cli": "~3.7.1",
"ember-cli": "~3.10.1",
"ember-cli-dependency-checker": "^3.0.0",
"ember-cli-eslint": "^5.0.0",
"ember-cli-github-pages": "^0.2.0",
Expand All @@ -90,7 +90,7 @@
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^3.4.1",
"ember-resolver": "^5.0.1",
"ember-source": "~3.7.0",
"ember-source": "~3.10.0",
"ember-source-channel-url": "^1.1.0",
"ember-try": "^1.0.0",
"eslint-plugin-ember": "^6.1.0",
Expand All @@ -99,7 +99,7 @@
"qunit-dom": "^0.8.0"
},
"engines": {
"node": "6.* || 8.* || >= 10.*"
"node": "8.* || >= 10.*"
},
"ember-addon": {
"configPath": "tests/dummy/config",
Expand Down
Loading