Skip to content

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.

Boot: the logo finishes its move before it goes, and the phone's launch screen stays until the page has drawn (no black seconds)

Duarte Santos8eb2e830e206
diff --git a/frontend/capacitor.config.json b/frontend/capacitor.config.json
index f49280772..00c0467db 100644
--- a/frontend/capacitor.config.json
+++ b/frontend/capacitor.config.json
@@ -9,6 +9,13 @@
"plugins": {
"SystemBars": {
"insetsHandling": "disable"
+ },
+ "SplashScreen": {
+ "launchShowDuration": 8000,
+ "launchAutoHide": true,
+ "launchFadeOutDuration": 180,
+ "backgroundColor": "#0c0e12",
+ "showSpinner": false
}
}
}
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 6d803ec53..91f15f161 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -16,6 +16,7 @@
"@capacitor/filesystem": "^8.1.4",
"@capacitor/local-notifications": "^8.0.0",
"@capacitor/share": "^8.0.0",
+ "@capacitor/splash-screen": "^8.0.2",
"jsqr": "^1.4.0",
"lean-qr": "^2.7.3",
"react": "^19.2.7",
@@ -623,6 +624,15 @@
"@capacitor/core": ">=8.0.0"
}
},
+ "node_modules/@capacitor/splash-screen": {
+ "version": "8.0.2",
+ "resolved": "https://registry.npmjs.org/@capacitor/splash-screen/-/splash-screen-8.0.2.tgz",
+ "integrity": "sha512-0C6rYScr13WfAE9nPl4ScOQynmjFv9NT3Th+RZkD4ezYHmER6mcl1/lDYsv7jg3Rj3FOvLrlTlmNkUrr83kZzQ==",
+ "license": "MIT",
+ "peerDependencies": {
+ "@capacitor/core": ">=8.0.0"
+ }
+ },
"node_modules/@capacitor/synapse": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@capacitor/synapse/-/synapse-1.0.4.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index b9f80662f..bbe7efb1c 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -21,6 +21,7 @@
"@capacitor/filesystem": "^8.1.4",
"@capacitor/local-notifications": "^8.0.0",
"@capacitor/share": "^8.0.0",
+ "@capacitor/splash-screen": "^8.0.2",
"jsqr": "^1.4.0",
"lean-qr": "^2.7.3",
"react": "^19.2.7",
diff --git a/frontend/src/lib/boot.js b/frontend/src/lib/boot.js
index bc89cd934..11e67493f 100644
--- a/frontend/src/lib/boot.js
+++ b/frontend/src/lib/boot.js
@@ -1,8 +1,40 @@
+import { registerPlugin } from '@capacitor/core'
+
// The boot screen in index.html: markup and CSS only, so the web image's CSP needs no new hash.
-// It goes the moment the app can draw, or on a script error before that, so it never lifts forever.
-export function hideBoot() {
+// It goes once the app can draw, or on a script error before that, so it never lifts forever.
+// Never mid-move: the logo first finishes building (about 0.7 s), and once the bar is going up
+// and down it leaves when the bar is back on the floor, not halfway through a rep.
+const BUILT_MS = 700, REP_DELAY_MS = 750, REP_MS = 1250
+
+export function bootWait(t, reduced) {
+ if (reduced || !Number.isFinite(t)) return 0
+ if (t < REP_DELAY_MS) return Math.max(0, BUILT_MS - t)
+ return (REP_MS - ((t - REP_DELAY_MS) % REP_MS)) % REP_MS
+}
+
+export function hideBoot(e) {
const b = document.getElementById('boot')
- if (!b || b.className) return
- b.className = 'out'
- setTimeout(() => b.remove(), 260)
+ if (!b || b.dataset.leaving) return
+ b.dataset.leaving = '1'
+ let wait = 0
+ if (!(e instanceof Event)) {
+ try {
+ const reduced = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches
+ wait = bootWait(Number(b.querySelector('.db')?.getAnimations?.()[0]?.currentTime), reduced)
+ } catch { wait = 0 }
+ }
+ setTimeout(() => {
+ b.className = 'out'
+ setTimeout(() => b.remove(), 260)
+ }, wait)
+}
+
+// The phone's own launch screen stays up until the page has painted the boot screen, so the
+// WebView starting up never shows as seconds of plain black (capacitor.config.json SplashScreen
+// also drops it by itself after 8 s, should this never run).
+export function handOverFromLaunchScreen() {
+ try {
+ if (!window.Capacitor?.isNativePlatform?.()) return
+ registerPlugin('SplashScreen').hide({ fadeOutDuration: 180 }).catch(() => {})
+ } catch { /* no plugin in this build: the launch screen goes on its own */ }
}
diff --git a/frontend/src/lib/boot.test.js b/frontend/src/lib/boot.test.js
new file mode 100644
index 000000000..248a666d4
--- /dev/null
+++ b/frontend/src/lib/boot.test.js
@@ -0,0 +1,18 @@
+import { expect, it } from 'vitest'
+import { bootWait } from './boot.js'
+
+it('lets the logo finish building before it goes', () => {
+ expect(bootWait(100, false)).toBe(600)
+ expect(bootWait(720, false)).toBe(0)
+})
+
+it('waits for the bar to be back on the floor once it is moving', () => {
+ expect(bootWait(750, false)).toBe(0)
+ expect(bootWait(750 + 300, false)).toBe(950)
+ expect(bootWait(750 + 1250 * 3 + 1200, false)).toBe(50)
+})
+
+it('goes at once with reduced motion or no timing to read', () => {
+ expect(bootWait(300, true)).toBe(0)
+ expect(bootWait(NaN, false)).toBe(0)
+})
diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx
index ae12b0052..8f4f80439 100644
--- a/frontend/src/main.jsx
+++ b/frontend/src/main.jsx
@@ -6,11 +6,12 @@ import { useStore } from './store/useStore.js'
import { startMediaSync } from './lib/media-sync.js'
import { startNativeKeyboard } from './lib/native-keyboard.js'
import './index.css'
-import { hideBoot } from './lib/boot.js'
+import { hideBoot, handOverFromLaunchScreen } from './lib/boot.js'
// App.jsx restores per-route scroll itself; the browser's own attempt races it.
// A script that dies before the app draws would otherwise leave the boot logo lifting forever.
window.addEventListener('error', hideBoot, { once: true })
+handOverFromLaunchScreen()
if ('scrollRestoration' in history) history.scrollRestoration = 'manual'