From 1efd67c733932baaa0810a8c4972ab5fac8b790b Mon Sep 17 00:00:00 2001 From: Dennis Schoepf Date: Sun, 8 Aug 2021 00:57:56 +0200 Subject: [PATCH] Fix scrolling for questions --- src/logger.ts | 10 ++++++---- src/store.ts | 2 +- src/ui/intro.ts | 9 +++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/logger.ts b/src/logger.ts index 67f2a30..f3e49c9 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -79,10 +79,12 @@ export class Logger { public logQuestions(answers: string[], isKQ: boolean = false) { const uid = store.getState().uid; - this.database - .ref(uid) - .child(`${isKQ ? 'knowledge' : 'general'}Questions`) - .set(answers); + try { + this.database + .ref(uid) + .child(`${isKQ ? 'knowledge' : 'general'}Questions`) + .set(answers); + } catch (e) {} } } diff --git a/src/store.ts b/src/store.ts index 1fe8185..cea427a 100644 --- a/src/store.ts +++ b/src/store.ts @@ -31,7 +31,7 @@ const store = create((set) => ({ uid: null, showScore: false, showOvScore: true, - currentIntroStep: 1, + currentIntroStep: 5, revealablesFinished: 0, currentScene: Scenes.OVERVIEW, currentSubproject: null, diff --git a/src/ui/intro.ts b/src/ui/intro.ts index 481e33c..a6d84df 100644 --- a/src/ui/intro.ts +++ b/src/ui/intro.ts @@ -91,7 +91,7 @@ export class Intro { this.showStep(); } - store.subscribe((state) => { + store.subscribe((state, prevState) => { this.currentStep = state.currentIntroStep; this.anonymous = state.participantAnonymous; @@ -101,6 +101,12 @@ export class Intro { this.nextButton.innerHTML = 'Confirm'; } else if (state.currentIntroStep === 4) { this.nextButton.innerHTML = 'Start already!'; + } else if (state.currentIntroStep === 6 && prevState.currentIntroStep === 5) { + console.log('hm'); + + setTimeout(() => { + document.querySelector('#intro-step6').scrollIntoView(); + }, 50); } else if (state.currentIntroStep === 7) { this.nextButton.style.display = 'none'; } else if (state.currentIntroStep === 0) { @@ -174,7 +180,6 @@ export class Intro { if (currentStep === 6) { this.sendGeneralQuestionAnswers(); - window.scrollTo(0); } if (currentStep === 5) {