1
0
mirror of https://github.com/flarum/core.git synced 2025-08-08 09:26:34 +02:00

update: Composer

This commit is contained in:
Alexander Skvortsov
2020-08-08 14:31:44 -04:00
committed by Franz Liedke
parent 070865f825
commit 2a784009fb

View File

@@ -11,13 +11,15 @@ import ComposerState from '../states/ComposerState';
* `show`, `hide`, `close`, `minimize`, `fullScreen`, and `exitFullScreen`. * `show`, `hide`, `close`, `minimize`, `fullScreen`, and `exitFullScreen`.
*/ */
export default class Composer extends Component { export default class Composer extends Component {
init() { oninit(vnode) {
super.oninit(vnode);
/** /**
* The composer's "state". * The composer's "state".
* *
* @type {ComposerState} * @type {ComposerState}
*/ */
this.state = this.props.state; this.state = this.attrs.state;
/** /**
* Whether or not the composer currently has focus. * Whether or not the composer currently has focus.
@@ -54,7 +56,7 @@ export default class Composer extends Component {
); );
} }
config(isInitialized, context) { onupdate() {
if (this.state.position === this.prevPosition) { if (this.state.position === this.prevPosition) {
// Set the height of the Composer element and its contents on each redraw, // Set the height of the Composer element and its contents on each redraw,
// so that they do not lose it if their DOM elements are recreated. // so that they do not lose it if their DOM elements are recreated.
@@ -64,12 +66,10 @@ export default class Composer extends Component {
this.prevPosition = this.state.position; this.prevPosition = this.state.position;
} }
}
if (isInitialized) return; oncreate(vnode) {
super.oncreate(vnode);
// Since this component is a part of the global UI that persists between
// routes, we will flag the DOM to be retained across route changes.
context.retain = true;
this.initializeHeight(); this.initializeHeight();
this.$().hide().css('bottom', -this.state.computedHeight()); this.$().hide().css('bottom', -this.state.computedHeight());
@@ -93,12 +93,12 @@ export default class Composer extends Component {
$(document) $(document)
.on('mousemove', (handlers.onmousemove = this.onmousemove.bind(this))) .on('mousemove', (handlers.onmousemove = this.onmousemove.bind(this)))
.on('mouseup', (handlers.onmouseup = this.onmouseup.bind(this))); .on('mouseup', (handlers.onmouseup = this.onmouseup.bind(this)));
}
context.onunload = () => { onremove() {
$(window).off('resize', handlers.onresize); $(window).off('resize', handlers.onresize);
$(document).off('mousemove', handlers.onmousemove).off('mouseup', handlers.onmouseup); $(document).off('mousemove', handlers.onmousemove).off('mouseup', handlers.onmouseup);
};
} }
/** /**