improve iterators

This commit is contained in:
2023-08-05 22:18:43 +02:00
parent 9e4ee3659f
commit 9dc6e8750d
2 changed files with 17 additions and 3 deletions

View File

@ -287,6 +287,19 @@ export class UserAPI {
limit
};
} else {
// Check if limit has changed
if (this.iterators[name].limit !== limit) {
// Reset value to 0 and update limit
this.iterators[name].value = 0;
this.iterators[name].limit = limit;
}
// Check if step has changed
if (this.iterators[name].step !== step) {
// Update step
this.iterators[name].step = step ?? this.iterators[name].step;
}
// Increment existing iterator by step value
this.iterators[name].value += this.iterators[name].step;

View File

@ -705,6 +705,7 @@ function startClock() {
function startOnEnter(e: KeyboardEvent) {
if (e.code === "Enter" || e.code === "Space") startClock();
}
function startOnClick(e: MouseEvent) {
if (e.button === 0) startClock();
}