1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/views/content-preview-content-view.js
Robert Rhoades 14402c0a1a Resets the scroll position on controller content change
When scrolling through the preview of a long article, if the
post was changed the scroll position of the preview would
remain the same.
2014-09-02 13:13:32 +01:00

24 lines
647 B
JavaScript

import setScrollClassName from 'ghost/utils/set-scroll-classname';
var PostContentView = Ember.View.extend({
classNames: ['content-preview-content'],
didInsertElement: function () {
var el = this.$();
el.on('scroll', Ember.run.bind(el, setScrollClassName, {
target: el.closest('.content-preview'),
offset: 10
}));
},
contentObserver: function () {
this.$().closest('.content-preview').scrollTop(0);
}.observes('controller.content'),
willDestroyElement: function () {
var el = this.$();
el.off('scroll');
}
});
export default PostContentView;