mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-72033 User tours: step placement issues if screen too narrow
This commit is contained in:
parent
5774e9e081
commit
7076db3492
3 changed files with 30 additions and 2 deletions
2
admin/tool/usertours/amd/build/tour.min.js
vendored
2
admin/tool/usertours/amd/build/tour.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1199,6 +1199,7 @@ export default class Tour {
|
|||
return this;
|
||||
}
|
||||
|
||||
stepConfig.placement = this.recalculatePlacement(stepConfig);
|
||||
let flipBehavior;
|
||||
switch (stepConfig.placement) {
|
||||
case 'left':
|
||||
|
@ -1293,6 +1294,33 @@ export default class Tour {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* For left/right placement, checks that there is room for the step at current window size.
|
||||
*
|
||||
* If there is not enough room, changes placement to 'top'.
|
||||
*
|
||||
* @method recalculatePlacement
|
||||
* @param {Object} stepConfig The step configuration of the step
|
||||
* @return {String} The placement after recalculate
|
||||
*/
|
||||
recalculatePlacement(stepConfig) {
|
||||
const buffer = 10;
|
||||
const arrowWidth = 16;
|
||||
let target = this.getStepTarget(stepConfig);
|
||||
let widthContent = this.currentStepNode.width() + arrowWidth;
|
||||
let targetOffsetLeft = target.offset().left - buffer;
|
||||
let targetOffsetRight = target.offset().left + target.width() + buffer;
|
||||
let placement = stepConfig.placement;
|
||||
|
||||
if (['left', 'right'].indexOf(placement) !== -1) {
|
||||
if ((targetOffsetLeft < (widthContent + buffer)) &&
|
||||
((targetOffsetRight + widthContent + buffer) > document.documentElement.clientWidth)) {
|
||||
placement = 'top';
|
||||
}
|
||||
}
|
||||
return placement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the backdrop.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue