Invert overtime (#1715)

* refactor: invert offset calculation

* chore: update tests

* chore: flip offset in UI

* fix seconds display on group target duration

* update comment

* fix rebase
This commit is contained in:
Alex Christoffer Rasmussen
2025-08-10 18:22:02 +02:00
committed by Carlos Valente
parent 4665f9c2f7
commit e0149c1cbf
11 changed files with 127 additions and 172 deletions
+3 -5
View File
@@ -314,7 +314,7 @@ export function updateLoaded(event?: PlayableEvent): string | undefined {
// handle edge cases with roll
if (runtimeState.timer.playback === Playback.Roll) {
const offsetClock = runtimeState.clock + runtimeState.runtime.offsetAbs;
const offsetClock = runtimeState.clock - runtimeState.runtime.offsetAbs;
// if waiting to roll, we update the targets and potentially start the timer
if (runtimeState._timer.secondaryTarget !== null) {
if (runtimeState.eventNow.timeStart < offsetClock && offsetClock < runtimeState.eventNow.timeEnd) {
@@ -391,7 +391,6 @@ export function start(state: RuntimeState = runtimeState): boolean {
state.timer.expectedFinish = getExpectedFinish(state);
state.timer.elapsed = 0;
// update runtime delays: over - under
if (state.runtime.actualStart === null) {
state.runtime.actualStart = state.clock;
}
@@ -521,7 +520,6 @@ export function update(): UpdateResult {
const { offsetAbs, offsetRel } = getRuntimeOffset(runtimeState);
runtimeState.runtime.offsetAbs = offsetAbs;
runtimeState.runtime.offsetRel = offsetRel;
// runtimeState.runtime.expectedEnd = getExpectedEnd(runtimeState);
const finishedNow =
Boolean(runtimeState._timer.forceFinish) ||
@@ -596,7 +594,7 @@ export function roll(
runtimeState.timer.expectedFinish = normalisedEndTime;
//account for offset
const offsetClock = runtimeState.clock + runtimeState.runtime.offsetAbs;
const offsetClock = runtimeState.clock - runtimeState.runtime.offsetAbs;
// state catch up
runtimeState.timer.duration = calculateDuration(runtimeState.eventNow.timeStart, normalisedEndTime);
@@ -635,7 +633,7 @@ export function roll(
//account for offset but we only keep it if passed to us
runtimeState.runtime.offsetAbs = offset;
const offsetClock = runtimeState.clock + runtimeState.runtime.offsetAbs;
const offsetClock = runtimeState.clock - runtimeState.runtime.offsetAbs;
const { index, isPending } = loadRoll(rundown, metadata, offsetClock);