leesbare tijdseenheid in stats plus timer door laten lopen na einde
This commit is contained in:
@@ -67,27 +67,27 @@ export class FocusPage implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private update() {
|
||||
const elapsed = Math.round((Date.now() - (this.timerStarted!)) / 1000); // in seconden
|
||||
const elapsed = this.timerStarted ? Math.round((Date.now() - (this.timerStarted)) / 1000) : 0; // in seconden
|
||||
let progress = elapsed / (this.duration * 60); // from 0 to 1
|
||||
|
||||
if( progress === 0) {
|
||||
progress = 0.0000001; // otherwise no graph
|
||||
}
|
||||
|
||||
if (progress >= 1) {
|
||||
if (progress >= 1 || isNaN(progress)) {
|
||||
progress = 1;
|
||||
if (this.duration === 0) {
|
||||
this.forcedEndOfTimerChime.play().catch(error => {
|
||||
console.error('Error playing audio:', error);
|
||||
});
|
||||
clearInterval(this.interval);
|
||||
this.timerStarted = null;
|
||||
}
|
||||
else {
|
||||
this.endOfTimerChime.play().catch(error => {
|
||||
console.error('Error playing audio:', error);
|
||||
});
|
||||
}
|
||||
clearInterval(this.interval);
|
||||
this.timerStarted = null;
|
||||
}
|
||||
|
||||
this.renderer.setStyle(
|
||||
@@ -106,8 +106,9 @@ export class FocusPage implements OnInit, OnDestroy {
|
||||
this.pathD = 'M100 10 A90 90 0 ' + (percentage > 0.5 ? '1' : '0') + ' 1 ' + circleEndX + ' ' + circleEndY;
|
||||
|
||||
const twoNumbers = (n: number) => n < 10 && n >= 0 ? '0' + n.toString() : n.toString();
|
||||
this.minutesText = twoNumbers(Math.max(Math.floor(timeLeft / 60), 0));
|
||||
this.secondsText = twoNumbers(Math.max(Math.floor(timeLeft % 60), 0));
|
||||
const floorPositiveCeilNegative = (n: number): number => n > 0 ? Math.floor(n) : Math.ceil(n);
|
||||
this.minutesText = twoNumbers(Math.abs(floorPositiveCeilNegative(timeLeft / 60)));
|
||||
this.secondsText = twoNumbers(Math.abs(floorPositiveCeilNegative(timeLeft % 60)));
|
||||
|
||||
this.dashOffset = elapsed;
|
||||
}
|
||||
@@ -147,7 +148,7 @@ export class FocusPage implements OnInit, OnDestroy {
|
||||
this.state = FocusState.FOCUS;
|
||||
this.stopStatsCounter();
|
||||
this.focusService.startFocus();
|
||||
this.startTimer(25); // 25
|
||||
this.startTimer(1); // 25
|
||||
}
|
||||
|
||||
reload() {
|
||||
@@ -160,7 +161,7 @@ export class FocusPage implements OnInit, OnDestroy {
|
||||
this.state = FocusState.SHORT_BREAK;
|
||||
this.stopStatsCounter();
|
||||
this.focusService.startShortBreak();
|
||||
this.startTimer(5); // 5
|
||||
this.startTimer(0.1); // 5
|
||||
}
|
||||
|
||||
recharge() {
|
||||
@@ -173,6 +174,6 @@ export class FocusPage implements OnInit, OnDestroy {
|
||||
this.state = FocusState.LONG_BREAK;
|
||||
this.stopStatsCounter();
|
||||
this.focusService.startLongBreak();
|
||||
this.startTimer(15); // 15
|
||||
this.startTimer(0.3); // 15
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user