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) {
if (step.hasQuestion()) {
reviewButtonDOM.attr('disabled', 'disabled');
} else {
reviewButtonDOM.removeAttr('disabled')
reviewButtonDOM.removeAttr('disabled');
}
reviewButtonDOM.show();
}
}
// Scroll to top of this block
scrollIntoView();
}
function showReviewStep() {
......@@ -189,7 +192,7 @@ function MentoringWithStepsBlock(runtime, element) {
}
function hideReviewStep() {
reviewStepDOM.hide()
reviewStepDOM.hide();
}
function getStepToReview(event) {
......@@ -225,6 +228,9 @@ function MentoringWithStepsBlock(runtime, element) {
reviewLinkDOM.show();
getResults();
// Scroll to top of this block
scrollIntoView();
}
function showAttempts() {
......@@ -323,6 +329,9 @@ function MentoringWithStepsBlock(runtime, element) {
nextDOM.off();
nextDOM.on('click', reviewNextStep);
reviewLinkDOM.hide();
// Scroll to top of this block
scrollIntoView();
}
function reviewNextStep() {
......@@ -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() {
$(document).on("click", function(event, ui) {
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