mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
3d6856614f
no issue - add ember-suave dependency - upgrade grunt-jscs dependency - add a new .jscsrc for the client's tests directory that extends from client's base .jscsrc - separate client tests in Gruntfile jscs task so they pick up the test's .jscsrc - standardize es6 usage across client
36 lines
874 B
JavaScript
36 lines
874 B
JavaScript
import Ember from 'ember';
|
|
import setScrollClassName from 'ghost/utils/set-scroll-classname';
|
|
|
|
const {Component, run} = Ember;
|
|
|
|
export default Component.extend({
|
|
classNames: ['content-preview-content'],
|
|
|
|
content: null,
|
|
|
|
didInsertElement() {
|
|
let el = this.$();
|
|
|
|
el.on('scroll', run.bind(el, setScrollClassName, {
|
|
target: el.closest('.content-preview'),
|
|
offset: 10
|
|
}));
|
|
},
|
|
|
|
didReceiveAttrs(options) {
|
|
// adjust when didReceiveAttrs gets both newAttrs and oldAttrs
|
|
if (options.newAttrs.content && this.get('content') !== options.newAttrs.content.value) {
|
|
let el = this.$();
|
|
|
|
if (el) {
|
|
el.closest('.content-preview').scrollTop(0);
|
|
}
|
|
}
|
|
},
|
|
|
|
willDestroyElement() {
|
|
let el = this.$();
|
|
|
|
el.off('scroll');
|
|
}
|
|
});
|