Commit d2d0e84d by Tim Krones

Studio: Make exercise preview render correctly on page load.

parent d2fe0450
...@@ -606,11 +606,24 @@ function VectorDrawXBlock(runtime, element, init_args) { ...@@ -606,11 +606,24 @@ function VectorDrawXBlock(runtime, element, init_args) {
.success(updateStatus); .success(updateStatus);
} }
// Logic for dealing with rendering issues
function reRender() {
JXG.JSXGraph.freeBoard(vectordraw.board);
vectordraw.render();
}
// Initialization logic // Initialization logic
// Initialize exercise // Initialize exercise
var vectordraw = new VectorDraw('vectordraw', init_args.settings); var vectordraw = new VectorDraw('vectordraw', init_args.settings);
// Check if board was initialized successfully;
// if not, re-render the exercise:
if (vectordraw.board.canvasWidth === 0 && vectordraw.board.canvasHeight === 0) {
window.setTimeout(reRender, 1);
}
// Load user state // Load user state
if (!_.isEmpty(init_args.user_state)) { if (!_.isEmpty(init_args.user_state)) {
vectordraw.setState(init_args.user_state); vectordraw.setState(init_args.user_state);
......
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