forked from p15670423/monkey
Add TODO 1
This commit is contained in:
parent
67d88e8ab2
commit
8476738925
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue