Skip to content

Commit

Permalink
WIP infinite scroll
Browse files Browse the repository at this point in the history
We're not scrolling the window (which is the default behavior), manually
specifying a scrollable just loads everything, and rolling our own with
ember-in-viewport doesn't work in Ember 2.9 for now. I'll just leave
this half-baked branch here. Maybe we can add a button to manually load
more until the dust settles? Maybe we should just fully roll our own?

And reminder: "total pages" in ember-infinity seems to actually mean
"total records".

adopted-ember-addons/ember-infinity#97
adopted-ember-addons/ember-infinity#82 (comment)
DockYard/ember-in-viewport#95
  • Loading branch information
sporkexec committed Nov 26, 2016
1 parent 8b979dc commit 740202e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/transaction/index/route.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import Ember from 'ember';
import InfinityRoute from 'ember-infinity/mixins/route';

export default Ember.Route.extend(InfinityRoute, {
perPageParam: 'page[size]',
pageParam: 'page[number]',
totalPagesParam: 'meta.record-count',

export default Ember.Route.extend({
model() {
return this.get('store').query('transaction', {
return this.infinityModel('transaction', {
perPage: 10,
startingPage: 1,
sort: '-date,-id', // Newest first, then newest id for collisions/invalid dates
});
}
Expand Down
2 changes: 2 additions & 0 deletions app/transaction/index/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
{{/link-to}}
{{/each}}

{{infinity-loader infinityModel=model scrollable='.page-content'}}

{{#link-to 'transaction.new' class='x-mdl-button-link new-transaction-button'}}
{{mdl-button isFloating=true icon='add'}}
{{/link-to}}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"ember-exam": "0.5.3",
"ember-export-application-global": "^1.0.5",
"ember-i18n": "4.3.2",
"ember-infinity": "0.2.6",
"ember-load-initializers": "^0.5.1",
"ember-material-lite": "0.2.5",
"ember-moment": "7.0.0-beta.6",
Expand Down

0 comments on commit 740202e

Please sign in to comment.