Merge pull request #1266 from Tyriar/1265_sync_when_attached
Ensure viewport is attached before syncing scrollbar
This commit is contained in:
@@ -93,6 +93,12 @@ export class Viewport implements IViewport {
|
|||||||
* @param ev The scroll event.
|
* @param ev The scroll event.
|
||||||
*/
|
*/
|
||||||
private onScroll(ev: Event): void {
|
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 newRow = Math.round(this.viewportElement.scrollTop / this.currentRowHeight);
|
||||||
const diff = newRow - this.terminal.buffer.ydisp;
|
const diff = newRow - this.terminal.buffer.ydisp;
|
||||||
this.terminal.scrollLines(diff, true);
|
this.terminal.scrollLines(diff, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user