Ensure viewport is attached before syncing scrollbar

Fixes #1265
This commit is contained in:
Daniel Imms
2018-02-01 10:24:17 -08:00
parent 62d6c242fc
commit 6105975308
+6
View File
@@ -93,6 +93,12 @@ export class Viewport implements IViewport {
* @param ev The scroll event.
*/
private onScroll(ev: Event): void {
// Don't attempt to scroll if the element is not visible, otherwise scrollTop will be corrupt
// which causes the terminal to scroll the buffer to the top
if (!this.viewportElement.offsetParent) {
return;
}
const newRow = Math.round(this.viewportElement.scrollTop / this.currentRowHeight);
const diff = newRow - this.terminal.buffer.ydisp;
this.terminal.scrollLines(diff, true);