ember-infinity
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -1,3 +0,1 @@ | ||
import { alias } from '@ember/object/computed'; | ||
import InfinityPromiseArray from 'ember-infinity/lib/infinity-promise-array'; | ||
import InViewportMixin from 'ember-in-viewport'; | ||
@@ -14,3 +12,3 @@ import { run } from '@ember/runloop'; | ||
classNames: ['infinity-loader'], | ||
classNameBindings: ['infinityModelContent.reachedInfinity', 'viewportEntered:in-viewport'], | ||
classNameBindings: ['isDoneLoading:reached-infinity', 'viewportEntered:in-viewport'], | ||
/** | ||
@@ -40,2 +38,8 @@ * @public | ||
* @public | ||
* @property isDoneLoading | ||
* @default false | ||
*/ | ||
isDoneLoading: false, | ||
/** | ||
* @public | ||
* @property developmentMode | ||
@@ -92,7 +96,5 @@ * @default false | ||
willInsertElement() { | ||
if (get(this, '_isInfinityPromiseArray')) { | ||
defineProperty(this, 'infinityModelContent', alias('infinityModel.promise')); | ||
} else { | ||
defineProperty(this, 'infinityModelContent', alias('infinityModel')); | ||
} | ||
defineProperty(this, 'infinityModelContent', computed('infinityModel', function() { | ||
return resolve(get(this, 'infinityModel')); | ||
})); | ||
}, | ||
@@ -109,10 +111,8 @@ | ||
this._loadStatusDidChange(); | ||
this.addObserver('infinityModelContent.reachedInfinity', this, this._loadStatusDidChange); | ||
get(this, 'infinityModelContent') | ||
.then((infinityModel) => { | ||
infinityModel.on('infinityModelLoaded', this, this._loadStatusDidChange); | ||
set(infinityModel, '_scrollable', get(this, 'scrollable')); | ||
}); | ||
this.addObserver('hideOnInfinity', this, this._loadStatusDidChange); | ||
let scrollableArea = get(this, 'scrollable'); | ||
let infinityModel = get(this, 'infinityModelContent'); | ||
if (infinityModel) { | ||
set(infinityModel, '_scrollable', scrollableArea); | ||
} | ||
}, | ||
@@ -123,10 +123,9 @@ | ||
this._cancelTimers(); | ||
this.removeObserver('infinityModelContent.reachedInfinity', this, this._loadStatusDidChange); | ||
get(this, 'infinityModelContent') | ||
.then((infinityModel) => { | ||
infinityModel.off('infinityModelLoaded', this, this._loadStatusDidChange); | ||
}); | ||
this.removeObserver('hideOnInfinity', this, this._loadStatusDidChange); | ||
}, | ||
_isInfinityPromiseArray: computed('infinityModel', function() { | ||
return (get(this, 'infinityModel') instanceof InfinityPromiseArray); | ||
}), | ||
/** | ||
@@ -166,5 +165,12 @@ * https://github.com/DockYard/ember-in-viewport#didenterviewport-didexitviewport | ||
_loadStatusDidChange() { | ||
if (get(this, 'infinityModelContent.reachedInfinity') && get(this, 'hideOnInfinity')) { | ||
set(this, 'isVisible', false); | ||
} | ||
get(this, 'infinityModelContent') | ||
.then((infinityModel) => { | ||
if (get(infinityModel, 'reachedInfinity')) { | ||
set(this, 'isDoneLoading', true); | ||
if (get(this, 'hideOnInfinity')) { | ||
set(this, 'isVisible', false); | ||
} | ||
} | ||
}); | ||
}, | ||
@@ -182,16 +188,16 @@ | ||
*/ | ||
const infinityModelContent = get(this, 'infinityModelContent'); | ||
function loadPreviousPage() { | ||
function loadPreviousPage(content) { | ||
if (typeof(get(this, 'infinityLoad')) === 'function') { | ||
// closure action | ||
return get(this, 'infinityLoad')(infinityModelContent, -1); | ||
return get(this, 'infinityLoad')(content, -1); | ||
} else { | ||
get(this, 'infinity').infinityLoad(infinityModelContent, -1) | ||
get(this, 'infinity').infinityLoad(content, -1) | ||
} | ||
} | ||
if (get(infinityModelContent, 'firstPage') > 1 && get(infinityModelContent, 'currentPage') > 0) { | ||
this._debounceTimer = run.debounce(this, loadPreviousPage, get(this, 'eventDebounce')); | ||
} | ||
get(this, 'infinityModelContent').then((content) => { | ||
if (get(content, 'firstPage') > 1 && get(content, 'currentPage') > 0) { | ||
this._debounceTimer = run.debounce(this, loadPreviousPage, content, get(this, 'eventDebounce')); | ||
} | ||
}) | ||
}, | ||
@@ -210,5 +216,3 @@ | ||
// type is <InfinityModel|Promise|null> | ||
let infinityModelContent = resolve(get(this, 'infinityModelContent')); | ||
infinityModelContent.then((content) => { | ||
get(this, 'infinityModelContent').then((content) => { | ||
if (typeof(get(this, 'infinityLoad')) === 'function') { | ||
@@ -243,2 +247,5 @@ // closure action (if you need to perform some other logic) | ||
/** | ||
* @method _cancelTimers | ||
*/ | ||
_cancelTimers() { | ||
@@ -245,0 +252,0 @@ run.cancel(this._debounceTimer); |
import ArrayProxy from "@ember/array/proxy" | ||
import Evented from '@ember/object/evented'; | ||
import { oneWay } from '@ember/object/computed'; | ||
@@ -14,5 +15,12 @@ import { computed, get, set, getProperties } from '@ember/object'; | ||
*/ | ||
export default ArrayProxy.extend({ | ||
export default ArrayProxy.extend(Evented, { | ||
/** | ||
@public | ||
@property reachedInfinity | ||
@default null | ||
*/ | ||
reachedInfinity: false, | ||
/** | ||
@public | ||
@property store | ||
@@ -19,0 +27,0 @@ @default null |
@@ -401,4 +401,6 @@ import Service from '@ember/service'; | ||
_notifyInfinityModelLoaded(infinityModel) { | ||
const totalPages = get(this, '_totalPages'); | ||
scheduleOnce('afterRender', infinityModel, 'infinityModelLoaded', { totalPages: totalPages }); | ||
scheduleOnce('afterRender', this, () => { | ||
infinityModel.infinityModelLoaded({ totalPages: get(this, 'totalPages') }); | ||
infinityModel.trigger('infinityModelLoaded'); | ||
}); | ||
}, | ||
@@ -405,0 +407,0 @@ |
{ | ||
"name": "ember-infinity", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Simple, flexible infinite scroll for Ember CLI Apps.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
340459
954