Refactor & improve

This commit is contained in:
Andras Schmelczer 2023-05-01 12:14:36 +01:00
commit b3d9229af5
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
22 changed files with 713 additions and 334 deletions

View file

@ -1,7 +1,7 @@
export class DeltaTimeCalculator {
private previousTime: DOMHighResTimeStamp | null = null;
constructor() {
constructor(private readonly maxDeltaTimeInSeconds: number = 1 / 30) {
document.addEventListener('visibilitychange', this.handleVisibilityChange.bind(this));
}
@ -14,7 +14,7 @@ export class DeltaTimeCalculator {
const delta = currentTime - this.previousTime;
this.previousTime = currentTime;
return delta / 1000;
return Math.min(delta / 1000, this.maxDeltaTimeInSeconds);
}
private handleVisibilityChange() {