From e9ee6c0b6921f562f8ae2af13a0816f2c244ad79 Mon Sep 17 00:00:00 2001 From: Alex Stan Date: Sun, 2 Jun 2024 10:10:16 +0300 Subject: [PATCH] Smoothed out the animations (#10) Co-authored-by: Alex Stan Co-committed-by: Alex Stan --- app/components/question_component.tsx | 17 ++++++++++++++--- app/learn/[category]/page.tsx | 20 +++++++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/app/components/question_component.tsx b/app/components/question_component.tsx index 82454fb..bdc457a 100644 --- a/app/components/question_component.tsx +++ b/app/components/question_component.tsx @@ -33,9 +33,20 @@ const QuestionView = ({ question, setState, state }: { question: Question, setSt return (
-

- {question && question.text} -

+ {/* {question && question.text} */} + +

+ {question.text} +

+
{ + let i = array.length - 1; + + while ( i >= 0 ) { + const random_i = Math.floor( Math.random() * i ); + + [array[ i ], array[ random_i ]] = [array[ random_i ], array[ i ]]; + i--; + } +} const Page = ({ params }: { params: { category: string }}) => { const [mobileMenuOpen, setMobileMenuOpen] = useState(false) @@ -35,6 +45,7 @@ const Page = ({ params }: { params: { category: string }}) => { result = result.filter( q => q.category === params.category) .map(it=>({...it, answered: AnswerType.Unset})); //result = result.filter + shuffle( result ); setQuestions( result ); console.log( `q12 uestions: ${ JSON.stringify( questions ) }`, result ); } @@ -44,6 +55,7 @@ const Page = ({ params }: { params: { category: string }}) => { questions?.forEach(q => { ans[ q.id ] = AnswerType.Unset; }); + /* setState( (prevState: SessionState) => ({ @@ -83,7 +95,13 @@ const Page = ({ params }: { params: { category: string }}) => {
- {questions[ index ] ? () : } + {(()=>{ + if ( !questions[ 0 ] ) + return <>; + return (index < 10 && questions[ index ]) ? : ; + })()} + + {/* {questions[ 0 ] ? ((index < 10 && questions[ index ]) ? : ) : null} */}