From ef76c9057114ad544208dc059c080e224d061216 Mon Sep 17 00:00:00 2001 From: Chaphasilor Date: Sat, 31 Dec 2022 16:57:27 +0100 Subject: [PATCH] working progress bar --- src/onboarding.js | 38 +++++++++++++++++++++++++++++--------- src/rewind.js | 15 ++++++++++++++- src/setup.js | 4 ++-- 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/onboarding.js b/src/onboarding.js index b55fd6e..9fb6cb1 100644 --- a/src/onboarding.js +++ b/src/onboarding.js @@ -19,6 +19,7 @@ export const state = reactive({ rewindGenerating: false, rewindReport: null, staleReport: false, + progress: 0, auth: null, featuresInitialized: false, darkMode: null, @@ -328,22 +329,40 @@ const viewLogin = html` ` -const progressBar = (progress) => html` +const progressBar = html`
- -
+ +
` +function smoothSeek(current, target, duration) { + const diff = Math.abs(target - current) + const stepCount = 20 + const step = Math.abs(diff / stepCount) + + const increase = () => { + if (state.progress < target) { + state.progress += step + setTimeout(increase, duration / stepCount) + } + } + increase() +} + async function generateReport() { try { state.rewindGenerating = true - state.rewindReport = await generateRewindReport() + state.progress = 0 + state.rewindReport = await generateRewindReport((progress) => { + smoothSeek(state.progress, progress, 750) + // state.progress = progress + }) state.rewindGenerating = false } catch (err) { console.error(err) @@ -361,6 +380,7 @@ watch(() => state.currentView, async (view) => { function launchRewind() { initializeFeatureStory(state.rewindReport, state.featuresInitialized) state.featuresInitialized = true + state.currentView = `revisit` } const viewLoad = html` @@ -374,12 +394,12 @@ const viewLoad = html`

Please be patient, and if nothing happens for more than 30s, reach out to me via Reddit so that I can look into it :)

- ${() => progressBar(0.5)} + ${() => progressBar} ${() => state.rewindReport ? html`