mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-14 18:52:05 +03:00
6ed69181ef
Closes #6390 - check if more posts should be loaded whenever one is deleted - delete dead code from posts controller - delete duplicate component gh-infinite-scroll-box - simplify posts-list-item `posts.post` or `editor.edit` link logic by modifying `gh-content-view-container` to yield necessary vars directly and use inline ifs in template - add `gh-tag` component for rendering tags and updating infinite scroll box on `settings/tags` page
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
import Ember from 'ember';
|
|
|
|
const {Mixin, run} = Ember;
|
|
|
|
export default Mixin.create({
|
|
isLoading: false,
|
|
triggerPoint: 100,
|
|
|
|
/**
|
|
* Determines if we are past a scroll point where we need to fetch the next page
|
|
*/
|
|
_checkScroll() {
|
|
let element = this.get('element');
|
|
let triggerPoint = this.get('triggerPoint');
|
|
let isLoading = this.get('isLoading');
|
|
|
|
// If we haven't passed our threshold or we are already fetching content, exit
|
|
if (isLoading || (element.scrollTop + element.clientHeight + triggerPoint <= element.scrollHeight)) {
|
|
return;
|
|
}
|
|
|
|
this.sendAction('fetch');
|
|
},
|
|
|
|
didInsertElement() {
|
|
this._super(...arguments);
|
|
|
|
let el = this.get('element');
|
|
|
|
el.onscroll = run.bind(this, this._checkScroll);
|
|
|
|
// run on load, on the offchance that the initial load
|
|
// did not fill the view.
|
|
this._checkScroll();
|
|
},
|
|
|
|
willDestroyElement() {
|
|
this._super(...arguments);
|
|
|
|
// turn off the scroll handler
|
|
this.get('element').onscroll = null;
|
|
}
|
|
});
|