Display line count for telemetry console

This commit is contained in:
Shreya 2020-03-13 11:26:45 +05:30
parent d2c315b93f
commit d806746aea
1 changed files with 16 additions and 5 deletions

View File

@ -66,16 +66,15 @@ class MapPageComponent extends AuthComponent {
.then(res => { .then(res => {
if ('telemetries' in res) { if ('telemetries' in res) {
let newTelem = this.state.telemetry.concat(res['telemetries']); let newTelem = this.state.telemetry.concat(res['telemetries']);
let telemConsoleRef = this.telemConsole.current;
this.setState( this.setState(
{ {
telemetry: newTelem, telemetry: newTelem,
telemetryLastTimestamp: res['timestamp'], telemetryLastTimestamp: res['timestamp']
telemetryLines: telemConsoleRef.scrollHeight,
}); });
this.props.onStatusChange(); this.props.onStatusChange();
let telemConsoleRef = this.telemConsole.current;
if (!this.state.isScrolledUp) { if (!this.state.isScrolledUp) {
telemConsoleRef.scrollTop = telemConsoleRef.scrollHeight - telemConsoleRef.clientHeight; telemConsoleRef.scrollTop = telemConsoleRef.scrollHeight - telemConsoleRef.clientHeight;
this.scrollTop = telemConsoleRef.scrollTop; this.scrollTop = telemConsoleRef.scrollTop;
@ -153,10 +152,22 @@ class MapPageComponent extends AuthComponent {
handleScroll(e) { handleScroll(e) {
let element = e.target; let element = e.target;
let telemetryStyle = window.getComputedStyle(element)
let telemetryLineHeight = parseInt((telemetryStyle.lineHeight).replace('px', ''))
if (element.scrollTop < this.scrollTop) { if (element.scrollTop < this.scrollTop) {
this.setState({isScrolledUp: true, telemetryCurrentLine: element.scrollTop}); this.setState({
isScrolledUp: true,
telemetryCurrentLine: parseInt(element.scrollTop/telemetryLineHeight)+1,
telemetryLines: parseInt(element.scrollHeight/telemetryLineHeight),
});
} else { } else {
this.setState({isScrolledUp: false, telemetryCurrentLine: element.scrollTop}); this.setState({
isScrolledUp: false,
telemetryCurrentLine: parseInt(element.scrollTop/telemetryLineHeight)+1,
telemetryLines: parseInt(element.scrollHeight/telemetryLineHeight),
});
} }
} }