From 33a5b54ba614df96cf1049d9e1d01149b321defe Mon Sep 17 00:00:00 2001 From: Evgeny Sokovikov Date: Mon, 23 Sep 2019 11:19:31 +0400 Subject: [PATCH] prevent automatic log scrolling if user watching logs --- src/view/cli.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/view/cli.js b/src/view/cli.js index 869a43abb..82ea20442 100644 --- a/src/view/cli.js +++ b/src/view/cli.js @@ -74,6 +74,8 @@ class LogOutput extends Component { super(props); this._refresh = true; this._ref = React.createRef(); + this._scrolledToBottom = false; + this.handleScroll = this.handleScroll.bind(this); } shouldComponentUpdate() { @@ -101,12 +103,26 @@ class LogOutput extends Component { tailLogs() { const view = this._ref && this._ref.current; - view && view.scrollToEnd({ animated: false }); + view && !this._scrolledToBottom && view.scrollToEnd({ animated: false }); + } + + handleScroll({ + nativeEvent: { contentOffset, contentSize, layoutMeasurement }, + }) { + const threshold = 10; + this._scrolledToBottom = + layoutMeasurement.height + contentOffset.y + threshold >= + contentSize.height; } render() { return ( - + {this.printLogs} );