Add TODO 1

This commit is contained in:
PrajwalM2212 2020-03-12 20:09:29 +05:30 committed by Shreya
parent 67d88e8ab2
commit 8476738925
1 changed files with 22 additions and 4 deletions

View File

@ -18,9 +18,12 @@ class MapPageComponent extends AuthComponent {
killPressed: false, killPressed: false,
showKillDialog: false, showKillDialog: false,
telemetry: [], telemetry: [],
telemetryLastTimestamp: null telemetryLastTimestamp: null,
movedTop: false,
}; };
this.telemConsole = React.createRef(); this.telemConsole = React.createRef();
this.handleScroll = this.handleScroll.bind(this);
this.scrollTop = 0;
} }
events = { events = {
@ -67,9 +70,13 @@ class MapPageComponent extends AuthComponent {
telemetry: newTelem, telemetry: newTelem,
telemetryLastTimestamp: res['timestamp'] telemetryLastTimestamp: res['timestamp']
}); });
var telemConsoleRef = this.telemConsole.current;
telemConsoleRef.scrollTop = telemConsoleRef.scrollHeight - telemConsoleRef.clientHeight
this.props.onStatusChange(); this.props.onStatusChange();
let telemConsoleRef = this.telemConsole.current;
if(!this.state.movedTop){
telemConsoleRef.scrollTop = telemConsoleRef.scrollHeight - telemConsoleRef.clientHeight;
this.scrollTop = telemConsoleRef.scrollTop;
}
} }
}); });
}; };
@ -141,9 +148,20 @@ class MapPageComponent extends AuthComponent {
); );
} }
handleScroll(e){
let element = e.target;
if(element.scrollTop < this.scrollTop){
this.setState({movedTop: true});
}else{
this.setState({movedTop: false});
}
}
renderTelemetryConsole() { renderTelemetryConsole() {
return ( return (
<div className="telemetry-console" ref={this.telemConsole}> <div className="telemetry-console" onScroll={this.handleScroll} ref={this.telemConsole}>
{ {
this.state.telemetry.map(this.renderTelemetryEntry) this.state.telemetry.map(this.renderTelemetryEntry)
} }