diff --git a/.changelogs/change_quiz-question-scroll-to-top.yml b/.changelogs/change_quiz-question-scroll-to-top.yml new file mode 100644 index 0000000000..7730b1d74f --- /dev/null +++ b/.changelogs/change_quiz-question-scroll-to-top.yml @@ -0,0 +1,3 @@ +significance: minor +type: changed +entry: Scroll to the top of the quiz UI area when a quiz question is loaded. diff --git a/assets/js/llms-quiz.js b/assets/js/llms-quiz.js index 75b7575050..a5fc0760c9 100644 --- a/assets/js/llms-quiz.js +++ b/assets/js/llms-quiz.js @@ -760,6 +760,13 @@ $( document ).trigger( 'llms-post-append-question', $html ); + var $quizUi = $( '#llms-quiz-ui' ); + if ( $quizUi.length ) { + $( 'html, body' ).animate( { + scrollTop: $quizUi.offset().top - 50 + }, 300 ); + } + }, /**