Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Koenig - Fixed incorrect sticky card icon positioning
Browse files Browse the repository at this point in the history
refs TryGhost/Ghost#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
  • Loading branch information
kevinansfield committed May 2, 2018
1 parent 3025968 commit 4ad8800
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions app/components/gh-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4ad8800

Please sign in to comment.