mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 05:50:35 +03:00
8c3970c9ba
closes #2906 - add a utility function to add classnames to targets, retrofitted from clientold to accommodate `Ember.run.bind` - create a content-preview view that tracks its scrolling - add a scroll handler to the existing PostsListView - The `posts/post` template now takes its HTML from the post model instead of using the editor's markdown component
36 lines
1018 B
JavaScript
36 lines
1018 B
JavaScript
import setScrollClassName from 'ghost/utils/set-scroll-classname';
|
|
|
|
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.on('scroll', Ember.run.bind(this, this.checkScroll));
|
|
el.on('scroll', Ember.run.bind(el, setScrollClassName, {
|
|
target: el.closest('.content-list'),
|
|
offset: 10
|
|
}));
|
|
},
|
|
|
|
willDestroyElement: function () {
|
|
var el = this.$();
|
|
el.off('scroll');
|
|
}
|
|
});
|
|
|
|
export default PostsListView;
|