mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-07 23:22:43 +02:00
bring back console drag resizing. fixes #370
This commit is contained in:
@ -25,6 +25,10 @@ class LogRow extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Console extends PureComponent {
|
export class Console extends PureComponent {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.mouseMoveHandler = this.mouseMoveHandler.bind(this);
|
||||||
|
}
|
||||||
componentDidUpdate(previousProps) {
|
componentDidUpdate(previousProps) {
|
||||||
if (this.props.logs !== previousProps.logs) {
|
if (this.props.logs !== previousProps.logs) {
|
||||||
// Scroll down after new log dom is inserted
|
// Scroll down after new log dom is inserted
|
||||||
@ -33,6 +37,42 @@ export class Console extends PureComponent {
|
|||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.endDragging();
|
||||||
|
}
|
||||||
|
|
||||||
|
endDragging() {
|
||||||
|
if (!this.isDragging) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isDragging = false;
|
||||||
|
window.consoleEl.style.transition = this.savedTransition;
|
||||||
|
window.removeEventListener('mousemove', this.mouseMoveHandler);
|
||||||
|
window.removeEventListener('mouseup', this.mouseUpHandler);
|
||||||
|
}
|
||||||
|
mouseDownHandler(e) {
|
||||||
|
if (!this.props.isConsoleOpen) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
this.isDragging = true;
|
||||||
|
this.startY = e.pageY;
|
||||||
|
this.startHeight = window.consoleEl.getBoundingClientRect().height;
|
||||||
|
this.savedTransition = window.getComputedStyle(window.consoleEl).transition;
|
||||||
|
window.consoleEl.style.transition = 'none';
|
||||||
|
|
||||||
|
window.addEventListener('mousemove', this.mouseMoveHandler);
|
||||||
|
window.addEventListener('mouseup', this.mouseUpHandler);
|
||||||
|
}
|
||||||
|
mouseUpHandler() {
|
||||||
|
this.endDragging();
|
||||||
|
}
|
||||||
|
|
||||||
|
mouseMoveHandler(e) {
|
||||||
|
if (!this.isDragging) return true;
|
||||||
|
const newHeight = this.startHeight + (this.startY - e.pageY);
|
||||||
|
window.consoleEl.style.height = `${newHeight}px`;
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
@ -56,6 +96,8 @@ export class Console extends PureComponent {
|
|||||||
class="js-console__header code-wrap__header"
|
class="js-console__header code-wrap__header"
|
||||||
title={i18n._(t`Double click to toggle console`)}
|
title={i18n._(t`Double click to toggle console`)}
|
||||||
onDblClick={onConsoleHeaderDblClick}
|
onDblClick={onConsoleHeaderDblClick}
|
||||||
|
onMouseDown={this.mouseDownHandler.bind(this)}
|
||||||
|
onMouseUp={this.mouseUpHandler.bind(this)}
|
||||||
>
|
>
|
||||||
<span class="code-wrap__header-label">
|
<span class="code-wrap__header-label">
|
||||||
<Trans>Console</Trans>
|
<Trans>Console</Trans>
|
||||||
|
Reference in New Issue
Block a user