mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 06:25:51 +03:00
30 lines
805 B
JavaScript
30 lines
805 B
JavaScript
|
var PostsListView = Ember.View.extend({
|
||
|
classNames: ['content-list-content'],
|
||
|
|
||
|
checkScroll: function (event) {
|
||
|
var element = event.target,
|
||
|
triggerPoint = 100,
|
||
|
controller = this.get('controller'),
|
||
|
isLoading = controller.get('isLoading');
|
||
|
|
||
|
// If we haven't passed our threshold, exit
|
||
|
if (isLoading || (element.scrollTop + element.clientHeight + triggerPoint <= element.scrollHeight)) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
controller.send('loadNextPage');
|
||
|
},
|
||
|
|
||
|
didInsertElement: function () {
|
||
|
var el = this.$();
|
||
|
el.bind('scroll', Ember.run.bind(this, this.checkScroll));
|
||
|
},
|
||
|
|
||
|
willDestroyElement: function () {
|
||
|
var el = this.$();
|
||
|
el.unbind('scroll');
|
||
|
}
|
||
|
});
|
||
|
|
||
|
export default PostsListView;
|