diff options
Diffstat (limited to 'javascript/app/components/infinite-list.js')
-rw-r--r-- | javascript/app/components/infinite-list.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/javascript/app/components/infinite-list.js b/javascript/app/components/infinite-list.js index b73b6d4..02e1943 100644 --- a/javascript/app/components/infinite-list.js +++ b/javascript/app/components/infinite-list.js @@ -10,34 +10,34 @@ function initialize(component) { pageNumber = 1; } -export default Component.extend({ +export default Component.extend({ renderedElements : [], init() { this._super(...arguments); initialize(this); }, - elementsObserver : observer('elements',function() { + elementsObserver : observer('elements',function() { initialize(this); const containerElement = document.getElementById(this.get('containerElementId')); - if(containerElement) { + if(containerElement) { containerElement.scrollTop = 0; } }), didInsertElement() { const containerElement = document.getElementById(this.get('containerElementId')); if(containerElement) { - const component = this; + const component = this; containerElement.onscroll = function() { const perPage = component.get('perPage'); const elements = component.get('elements'); - + if(!updating && (pageNumber * perPage < elements.length) && (containerElement.scrollTop + containerElement.offsetHeight > component.element.offsetHeight - 100)) { - + updating = true; - run.next(component,() => { + run.next(component,() => { const newElements = elements.slice(pageNumber * perPage,(pageNumber + 1) * perPage); component.get('renderedElements').pushObjects(newElements); pageNumber ++; |