Fix intro image scaling if used in compound content types

When using QS in compount content types (in Column in particular),
the intro div may not have been rendered when determining its
width. In consequence, instead of scaling the intro image to full
width, it would be displayed in its natural dimensions in Column.

This pull request fixes this behavior and the intro image will scale
properly in Column as well.
pull/55/head
Oliver Tacke 2020-03-01 13:53:46 +01:00
parent 7ada8795b6
commit 6413e664b1
1 changed files with 8 additions and 5 deletions

View File

@ -946,11 +946,14 @@ H5P.QuestionSet = function (options, contentId, contentData) {
if ($intro.length) { if ($intro.length) {
var bgImg = params.introPage.backgroundImage; var bgImg = params.introPage.backgroundImage;
var bgImgRatio = (bgImg.height / bgImg.width); var bgImgRatio = (bgImg.height / bgImg.width);
$intro.css({
background: '#fff url("' + H5P.getPath(bgImg.path, contentId) + '") no-repeat 50% 50%', setTimeout(function () {
backgroundSize: 'auto 100%', $intro.css({
minHeight: bgImgRatio * +window.getComputedStyle($intro[0]).width.replace('px','') background: '#fff url("' + H5P.getPath(bgImg.path, contentId) + '") no-repeat 50% 50%',
}); backgroundSize: 'auto 100%',
minHeight: bgImgRatio * +window.getComputedStyle($intro[0]).width.replace('px','')
});
}, 0);
} }
} }