From 361db6190ee4a168d5c313fe7292418a253ab106 Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Sat, 18 Feb 2017 00:27:29 -0300 Subject: [PATCH] avoid layout recalculation upon scrollport resize --- lib/hterm.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/hterm.js b/lib/hterm.js index 66480135..442c21dc 100644 --- a/lib/hterm.js +++ b/lib/hterm.js @@ -324,6 +324,25 @@ hterm.Terminal.prototype.onMouseDown_ = function (e) { } }; +// override `ScrollPort.resize` to avoid an expensive calculation +// just to get the size of the scrollbar, which for Hyper is always +// set to overlay (hence with `0`) +hterm.ScrollPort.prototype.resize = function () { + this.currentScrollbarWidthPx = 0; + + this.syncScrollHeight(); + this.syncRowNodesDimensions_(); + + this.publish( + 'resize', + {scrollPort: this}, + () => { + this.scrollRowToBottom(this.rowProvider_.getRowCount()); + this.scheduleRedraw(); + } + ); +}; + // make background transparent to avoid transparency issues hterm.ScrollPort.prototype.setBackgroundColor = function () { this.screen_.style.backgroundColor = 'transparent';