Commit 836a3be0 by Matjaz Gregoric

Resize video elements when step is displayed.

The videos have to be resized after each step is displayed,
because they are sized to fit into their container at load time,
but since the container isn't visible at load time, the videos
end up with wrong dimensions.

Trigger video resize after displaying each step.
parent 0de45814
......@@ -270,8 +270,8 @@ function MentoringWithStepsBlock(runtime, element) {
function showActiveStep() {
var step = steps[activeStep];
step.updatePlots();
$(step.element).show();
step.updateChildren();
}
function onChange() {
......
function MentoringStepBlock(runtime, element) {
var children = runtime.children(element);
var plots = [];
for (var i in children) {
var child = children[i];
var blockType = $(child.element).data('block-type');
if (blockType === 'sb-plot') {
plots.push(child);
}
}
var submitXHR, resultsXHR,
message = $(element).find('.sb-step-message');
......@@ -21,6 +13,14 @@ function MentoringStepBlock(runtime, element) {
}
}
function updateVideo(video) {
video.resizer.align();
}
function updatePlot(plot) {
plot.update();
}
return {
initChildren: function(options) {
......@@ -103,13 +103,18 @@ function MentoringStepBlock(runtime, element) {
return $('.sb-step', element).data('has-question')
},
updatePlots: function() {
if (plots) {
for (var i in plots) {
var plot = plots[i];
plot.update();
updateChildren: function() {
children.forEach(function(child) {
var type = $(child.element).data('block-type');
switch (type) {
case 'video':
updateVideo(child);
break;
case 'sb-plot':
updatePlot(child);
break;
}
}
});
}
};
......
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