From 291d1dc704d7987756af0da1d7507ef3e6ee4d94 Mon Sep 17 00:00:00 2001 From: sawka Date: Thu, 11 Aug 2022 10:41:08 -0700 Subject: [PATCH] allow resize observer to fire conditional scroll to bottom (info panel updates) --- src/main.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main.tsx b/src/main.tsx index 3e9a8247..ed82e991 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -405,6 +405,7 @@ class ScreenWindowView extends React.Component<{sw : ScreenWindow}, {}> { rszObs : any randomId : string; width : mobx.IObservableValue = mobx.observable.box(0); + lastHeight : number = null; scrollToBottom(reason : string) { let elem = document.getElementById(this.getLinesDOMId()); @@ -467,12 +468,24 @@ class ScreenWindowView extends React.Component<{sw : ScreenWindow}, {}> { let entry = entries[0]; let width = entry.target.offsetWidth; this.updateWidth(width); + if (this.lastHeight == null) { + this.lastHeight = entry.target.offsetHeight; + return; + } + if (this.lastHeight != entry.target.offsetHeight) { + this.lastHeight = entry.target.offsetHeight; + this.doConditionalScrollToBottom("resize-height"); + } } handleDomMutation(mutations, mutObs) { + this.doConditionalScrollToBottom("mut"); + } + + doConditionalScrollToBottom(reason : string) { let {sw} = this.props; if (sw && sw.shouldFollow.get()) { - setTimeout(() => this.scrollToBottom("mut"), 0); + setTimeout(() => this.scrollToBottom(reason), 0); } }