Skip to content

Commit dc6288e

Browse files
committed
Delay showing problem content until after MathJax content has rendered.
This was suggested by @dpvc in openwebwork/pg#1431. The point is to prevent the visual motion that occurs while the MathJax content is rendered. This doesn't use the `#problem_body` id selector since that is not on all problems (it isn't in Gateway tests), but uses the `.problem-content` class selector instead, since that is on all problems. Also, a `for of` loop and `document.querySelectorAll` is needed for tests, since there can be more than one problem. I am not entirely sold on the empty area shown in the mean time, but it does prevent the jitter for the text within the problem. Perhaps if someone wants to toy with css, a loading block could be shown with a transition that fades in the problem when the MathJax rendering is completed. Note that webwork2 renders MathJax in places outside of the problem content, and those will not be affected by this.
1 parent d238e7b commit dc6288e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

htdocs/js/MathJaxConfig/mathjax-config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ if (!window.MathJax) {
103103

104104
MathJax.startup.defaultReady();
105105
MathJax.startup.document.constructor.ProcessBits.allocate('findScripts');
106+
},
107+
pageReady() {
108+
return MathJax.startup.defaultPageReady().then(() => {
109+
for (const problemBody of document.querySelectorAll('.problem-content')) {
110+
problemBody.style.visibility = '';
111+
}
112+
});
106113
}
107114
},
108115
options: {
@@ -134,4 +141,8 @@ if (!window.MathJax) {
134141
ignoreHtmlClass: 'tex2jax_ignore'
135142
}
136143
};
144+
145+
for (const problemBody of document.querySelectorAll('.problem-content')) {
146+
problemBody.style.visibility = 'hidden';
147+
}
137148
}

0 commit comments

Comments
 (0)