Fixed broken resizing (#2273)

* simplify and fix resizing

* don't lint built bundles

* bump eslint
This commit is contained in:
Guillermo Rauch 2017-09-24 12:01:55 +02:00 committed by Leo Lamprecht
parent 0502bbfc79
commit de69aab095
4 changed files with 135 additions and 195 deletions

View file

@ -90,7 +90,7 @@ export default class Term extends PureComponent {
// xterm.js might be doing this asynchronously, so
// we force it instead
this.term.charMeasure.measure();
this.measureResize();
this.fitResize();
});
}
@ -99,19 +99,8 @@ export default class Term extends PureComponent {
console.error('unimplemented');
}
// measures the container and makes the decision
// whether to resize the term to fit the container
measureResize() {
const termRect = this.termWrapperRef.getBoundingClientRect();
if (!this.termRect || termRect.width !== this.termRect.width || termRect.height !== this.termRect.height) {
this.termRect = termRect;
this.fitResize();
}
}
onWindowResize() {
this.measureResize();
this.fitResize();
}
write(data) {
@ -135,12 +124,10 @@ export default class Term extends PureComponent {
}
fitResize() {
const cols = Math.floor(this.termRect.width / this.term.charMeasure.width);
const rows = Math.floor(this.termRect.height / this.term.charMeasure.height);
if (cols !== this.props.cols || rows !== this.props.rows) {
this.resize(cols, rows);
}
const termRect = this.termWrapperRef.getBoundingClientRect();
const cols = Math.floor(termRect.width / this.term.charMeasure.width);
const rows = Math.floor(termRect.height / this.term.charMeasure.height);
this.resize(cols, rows);
}
keyboardHandler(e) {
@ -159,6 +146,13 @@ export default class Term extends PureComponent {
this.clear();
}
if (!this.props.isTermActive && nextProps.isTermActive) {
requestAnimationFrame(() => {
this.term.charMeasure.measure();
this.fitResize();
});
}
if (this.props.fontSize !== nextProps.fontSize || this.props.fontFamily !== nextProps.fontFamily) {
// invalidate xterm cache about how wide each
// character is