Skip to content

Commit

Permalink
<MainContent>
Browse files Browse the repository at this point in the history
`</>, this, @, etc.`
  • Loading branch information
nummi committed Oct 1, 2019
1 parent 53a5881 commit df45d75
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
31 changes: 20 additions & 11 deletions app/components/main-content.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from '@ember/component';
import { schedule } from '@ember/runloop';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { task, timeout } from 'ember-concurrency';

Expand All @@ -14,15 +14,29 @@ export default Component.extend({
*/
layoutService: service('layout'),

didInsertElement() {
/**
* Reference to drag-handle on mousedown
*
* @property el
* @type {DOMNode|null}
* @default null
*/
el: null,

setupListeners: action(function(element) {
this.el = element;

this._performUpdateHeight = () => {
this.updateHeightDebounce.perform();
};

window.addEventListener('resize', this._performUpdateHeight);
schedule('afterRender', this, this.updateHeight);
return this._super(...arguments);
},
this.updateHeight();
}),

destroyListeners: action(function() {
window.removeEventListener('resize', this._performUpdateHeight);
}),

/**
* Restartable Ember Concurrency task that triggers
Expand All @@ -48,11 +62,6 @@ export default Component.extend({
* @method updateHeight
*/
updateHeight() {
this.layoutService.updateContentHeight(this.element.clientHeight);
this.layoutService.updateContentHeight(this.el.clientHeight);
},

willDestroyElement() {
window.removeEventListener('resize', this._performUpdateHeight);
return this._super(...arguments);
}
});
4 changes: 2 additions & 2 deletions app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
</button>
</div>

{{#main-content class="split__panel__bd"}}
<MainContent class="split__panel__bd">
{{outlet}}
{{/main-content}}
</MainContent>
</div>
</div>

Expand Down
7 changes: 7 additions & 0 deletions app/templates/components/main-content.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div
{{did-insert this.setupListeners}}
{{will-destroy this.destroyListeners}}
...attributes
>
{{yield}}
</div>
2 changes: 1 addition & 1 deletion lib/ui/addon/components/resizable-column.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from '@ember/component';
import { action, computed } from '@ember/object';
import { computed } from '@ember/object';
import { htmlSafe } from '@ember/string';
import layout from '../templates/components/resizable-column';

Expand Down

0 comments on commit df45d75

Please sign in to comment.