From e6ef2291b19fd95b4af4e1eabe4b34ec842e4519 Mon Sep 17 00:00:00 2001 From: mortezaei Date: Sat, 22 Aug 2026 15:03:55 +0330 Subject: [PATCH] feat(assessments): add native-like smooth horizontal slide transition to test questions --- .../Componentes/test-questions-flow.tsx | 158 ++++++++++-------- 1 file changed, 88 insertions(+), 70 deletions(-) diff --git a/src/components/Componentes/test-questions-flow.tsx b/src/components/Componentes/test-questions-flow.tsx index 9cbd01d..1c74335 100644 --- a/src/components/Componentes/test-questions-flow.tsx +++ b/src/components/Componentes/test-questions-flow.tsx @@ -198,11 +198,11 @@ export default function TestQuestionsFlow({ [currentQuestion.id]: value, })); - // Auto advance to next question if not on last question + // Auto advance to next question if not on last question with slide animation if (!isLastQuestion) { setTimeout(() => { setCurrentIndex((prev) => Math.min(prev + 1, totalQuestions - 1)); - }, 250); + }, 200); } }; @@ -296,84 +296,102 @@ export default function TestQuestionsFlow({ - {/* Question Section */} -
- {/* Question Title */} -

- {currentQuestion.text} -

+ {/* Question Slider Viewport */} +
+ {questions.map((q, index) => { + const offset = index - currentIndex; + const isNearby = Math.abs(offset) <= 1; + + if (!isNearby) return null; - {/* Answer Options Stack */} - {(() => { - const options = currentQuestion.options || []; + const qSelectedValue = answers[q.id]; + const options = q.options || []; return ( -
- {options.map((option) => { - const isSelected = selectedValue === option.value; - - return ( - - ); - })} + + ); + })} +
); - })()} + })}
{/* Bottom Actions Bar */}