Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
perf: rest bar shrinks by transform instead of width
Duarte Santosb2036327b376
diff --git a/frontend/src/components/RestTimer.jsx b/frontend/src/components/RestTimer.jsxindex ecc27e53a..88c72a8ea 100644--- a/frontend/src/components/RestTimer.jsx+++ b/frontend/src/components/RestTimer.jsx@@ -90,10 +90,12 @@ export default function RestTimer() {}, [!!on])if (!on) return nullconst pct = Math.max(0, Math.min(100, (on.left / on.total) * 100))+ // The bar shrinks by transform, not width: a width transition lays the page out again on every+ // frame of every rest (~45 layouts a second), a scaled bar is the compositor's alone.if (work) return (<div id="timer" className="working">- <div className="bar" aria-hidden="true"><i style={{ width: pct + '%' }} /></div>+ <div className="bar" aria-hidden="true"><i style={{ transform: `scaleX(${pct / 100})` }} /></div><div className="tclock"><span className="t">{work.left <= 0 && work.overtime ? '+' + clock(-work.left) : clock(work.left)}</span>{work.label && <span className="lbl">{work.label}</span>}@@ -114,7 +116,7 @@ export default function RestTimer() {const label = timer.kind === 'switch' ? t('Switch sides') : timer.paused ? t('Paused') : t('Rest')return (<div id="timer" className={'rest' + (timer.paused ? ' paused' : '') + (timer.kind === 'switch' ? ' switch' : '') + (timer.ready ? ' ready' : '')}>- <div className="bar" aria-hidden="true"><i style={{ width: pct + '%' }} /></div>+ <div className="bar" aria-hidden="true"><i style={{ transform: `scaleX(${pct / 100})` }} /></div><button type="button" className="tclock" onClick={adjustRestSheet}aria-label={(timer.ready ? t('Ready') : clock(timer.left)) + '. ' + t('Change the time left')}><span className="t" role={timer.ready ? 'status' : undefined} data-alt={timer.ready ? '0:00' : t('Ready')}>{timer.ready ? t('Ready') : clock(timer.left)}</span>diff --git a/frontend/src/components/RestTimer.ready.test.jsx b/frontend/src/components/RestTimer.ready.test.jsxindex c25b5b61b..57451997c 100644--- a/frontend/src/components/RestTimer.ready.test.jsx+++ b/frontend/src/components/RestTimer.ready.test.jsx@@ -58,7 +58,7 @@ describe('RestTimer Ready and overtime display', () => {act(() => vi.advanceTimersByTime(5000))expect(host.querySelector('#timer .t').textContent).toBe('+0:03')- expect(host.querySelector('#timer .bar i').style.width).toBe('0%')+ expect(host.querySelector('#timer .bar i').style.transform).toBe('scaleX(0)')})})diff --git a/frontend/src/index.css b/frontend/src/index.cssindex 7810ea0ea..8d695b213 100644--- a/frontend/src/index.css+++ b/frontend/src/index.css@@ -1430,7 +1430,8 @@ body.chips-dragging *{cursor:inherit}}@keyframes slideup{from{transform:translateY(16px);opacity:0}to{transform:none;opacity:1}}#timer .bar{position:absolute;top:0;inset-inline-start:0;inset-inline-end:0;height:3px;background:var(--surface-3)}-#timer .bar i{display:block;height:100%;background:var(--acc);transition:width 1s linear}+#timer .bar i{display:block;height:100%;background:var(--acc);transform-origin:left center;transition:transform 1s linear;will-change:transform}+[dir="rtl"] #timer .bar i{transform-origin:right center}/* The clock is what the bar is for, so it never gives up width: the buttons do (Skip is the one thatgives: in a long language on a narrow phone it becomes an icon, RestTimer.jsx useSkipFits). The label under theclock fills the clock's width but does not widen it. */