0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Koenig - Fixed incorrect sticky card icon positioning

refs https://github.com/TryGhost/Ghost/issues/9505
- sticky positioning was correct on the first post load but leaving the editor then coming back never took the editor header height into account
- store a reference to the header element in `{{gh-editor}}` so that we can more reliably grab the height to pass through
This commit is contained in:
Kevin Ansfield 2018-05-02 12:50:53 +01:00
parent 135d550c8a
commit ac72b89164

View file

@ -100,39 +100,42 @@ export default Component.extend({
},
_setHeaderClass() {
let $editorTitle = this.$('.gh-editor-title, .kg-title-input');
let editorTitle = this.element.querySelector('.gh-editor-title, .kg-title-input');
let smallHeaderClass = 'gh-editor-header-small';
let newHeaderClass = '';
this._editorTitleElement = editorTitle;
if (this.get('isSplitScreen')) {
this.set('headerClass', smallHeaderClass);
return;
}
// grab height of header so that we can pass it as an offset to other
// editor components
run.scheduleOnce('afterRender', this, function () {
if (this.headerClass) {
let headerElement = this.element.querySelector(`.${this.headerClass}`);
if (headerElement) {
let height = headerElement.offsetHeight;
return this.set('headerHeight', height);
}
}
this.set('headerHeight', 0);
});
if ($editorTitle.length > 0) {
let boundingRect = $editorTitle[0].getBoundingClientRect();
if (editorTitle) {
let boundingRect = editorTitle.getBoundingClientRect();
let maxRight = window.innerWidth - this._viewActionsWidth;
if (boundingRect.right >= maxRight) {
this.set('headerClass', smallHeaderClass);
return;
newHeaderClass = smallHeaderClass;
}
}
this.set('headerClass', '');
if (newHeaderClass !== this.headerClass) {
// grab height of header so that we can pass it as an offset to other
// editor components
run.scheduleOnce('afterRender', this, this._setHeaderHeight);
}
this.set('headerClass', newHeaderClass);
},
_setHeaderHeight() {
if (this.headerClass && this._editorTitleElement) {
let height = this._editorTitleElement.offsetHeight;
return this.set('headerHeight', height);
}
this.set('headerHeight', 0);
},
// dragOver is needed so that drop works