Commit cffa4537 by Tim Krones

Scroll to top when navigating to next step or loading page.

parent 06e41fcd
...@@ -168,11 +168,14 @@ function MentoringWithStepsBlock(runtime, element) { ...@@ -168,11 +168,14 @@ function MentoringWithStepsBlock(runtime, element) {
if (step.hasQuestion()) { if (step.hasQuestion()) {
reviewButtonDOM.attr('disabled', 'disabled'); reviewButtonDOM.attr('disabled', 'disabled');
} else { } else {
reviewButtonDOM.removeAttr('disabled') reviewButtonDOM.removeAttr('disabled');
} }
reviewButtonDOM.show(); reviewButtonDOM.show();
} }
} }
// Scroll to top of this block
scrollIntoView();
} }
function showReviewStep() { function showReviewStep() {
...@@ -189,7 +192,7 @@ function MentoringWithStepsBlock(runtime, element) { ...@@ -189,7 +192,7 @@ function MentoringWithStepsBlock(runtime, element) {
} }
function hideReviewStep() { function hideReviewStep() {
reviewStepDOM.hide() reviewStepDOM.hide();
} }
function getStepToReview(event) { function getStepToReview(event) {
...@@ -225,6 +228,9 @@ function MentoringWithStepsBlock(runtime, element) { ...@@ -225,6 +228,9 @@ function MentoringWithStepsBlock(runtime, element) {
reviewLinkDOM.show(); reviewLinkDOM.show();
getResults(); getResults();
// Scroll to top of this block
scrollIntoView();
} }
function showAttempts() { function showAttempts() {
...@@ -323,6 +329,9 @@ function MentoringWithStepsBlock(runtime, element) { ...@@ -323,6 +329,9 @@ function MentoringWithStepsBlock(runtime, element) {
nextDOM.off(); nextDOM.off();
nextDOM.on('click', reviewNextStep); nextDOM.on('click', reviewNextStep);
reviewLinkDOM.hide(); reviewLinkDOM.hide();
// Scroll to top of this block
scrollIntoView();
} }
function reviewNextStep() { function reviewNextStep() {
...@@ -363,6 +372,12 @@ function MentoringWithStepsBlock(runtime, element) { ...@@ -363,6 +372,12 @@ function MentoringWithStepsBlock(runtime, element) {
} }
} }
function scrollIntoView() {
var rootBlock = $(element),
rootBlockOffset = rootBlock.offset().top;
$('html, body').animate({ scrollTop: rootBlockOffset }, 500);
}
function initClickHandlers() { function initClickHandlers() {
$(document).on("click", function(event, ui) { $(document).on("click", function(event, ui) {
var target = $(event.target); var target = $(event.target);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment