MDL-76941 tool_usertours: Fix accessibility issue when resizing

This commit is contained in:
Huong Nguyen
2023-03-28 12:18:24 +07:00
parent 8af994f1f0
commit c7cc232e16
3 changed files with 25 additions and 3 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+23 -1
View File
@@ -14,6 +14,8 @@ import {eventTypes} from './events';
let currentTour = null;
let tourId = null;
let restartTourAndKeepProgress = false;
let currentStepNo = null;
/**
* Find the first matching tour.
@@ -75,6 +77,20 @@ export const init = async(tourDetails, filters) => {
resetTourState(tourId);
}
});
// Watch for the resize event.
window.addEventListener("resize", () => {
// Only listen for the running tour.
if (currentTour && currentTour.tourRunning) {
clearTimeout(window.resizedFinished);
window.resizedFinished = setTimeout(() => {
// Wait until the resize event has finished.
currentStepNo = currentTour.getCurrentStepNumber();
restartTourAndKeepProgress = true;
resetTourState(tourId);
}, 250);
}
});
};
/**
@@ -187,7 +203,13 @@ const startBootstrapTour = (tourId, template, tourConfig) => {
});
currentTour = new BootstrapTour(tourConfig);
return currentTour.startTour();
let startAt = 0;
if (restartTourAndKeepProgress && currentStepNo) {
startAt = currentStepNo;
restartTourAndKeepProgress = false;
currentStepNo = null;
}
return currentTour.startTour(startAt);
};
/**