Added basic control panel
This commit is contained in:
41
frontend/views/control/ts/calibration.ts
Normal file
41
frontend/views/control/ts/calibration.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { Main } from './main';
|
||||
|
||||
export class Calibration {
|
||||
private _Main: Main;
|
||||
|
||||
observer: IntersectionObserver;
|
||||
visible: boolean = false;
|
||||
|
||||
container: HTMLDivElement = document.querySelector('.ntsh-calibration');
|
||||
image: HTMLImageElement = this.container.querySelector('img');
|
||||
|
||||
constructor(Main: Main) {
|
||||
this._Main = Main;
|
||||
|
||||
this.registerListeners();
|
||||
|
||||
this.startClock();
|
||||
}
|
||||
|
||||
private startClock() {
|
||||
setInterval(() => {
|
||||
if (this.visible && this.image)
|
||||
this.image.src = `/calibrationImage?t=${Date.now()}`;
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
private registerListeners() {
|
||||
this.observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach((entry) => {
|
||||
if (entry.isIntersecting) {
|
||||
this.visible = true;
|
||||
console.log('Calibration visible');
|
||||
} else {
|
||||
this.visible = false;
|
||||
console.log('Calibration not visible');
|
||||
}
|
||||
});
|
||||
});
|
||||
this.observer.observe(this.container);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user