fix: mathjax resize on sindow resize (#32606)

* fix: mathjax resize on sindow resize

* fix: add resize for mathjax in wiki and cms
This commit is contained in:
Ben Warzeski
2023-07-05 10:49:03 -04:00
committed by GitHub
parent 810bf97431
commit a68fd49103
2 changed files with 45 additions and 0 deletions

View File

@@ -81,6 +81,12 @@
<!-- Configure and load MathJax -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
styles: {
'.MathJax_SVG>svg': { 'max-width': '100%' },
},
CommonHTML: { linebreaks: { automatic: true } },
SVG: { linebreaks: { automatic: true } },
"HTML-CSS": { linebreaks: { automatic: true } },
tex2jax: {
inlineMath: [
["\\(","\\)"],
@@ -92,6 +98,18 @@
]
}
});
window.addEventListener('resize', MJrenderer);
let 1 = -1;
let delay = 1000;
function MJrenderer() {
if (t >= 0) {
window.clearTimeout(t);
}
t = window.setTimeout(function() {
MathJax.Hub.Queue(["Rerenderer", MathJax.Hub]);
t = -1;
}, delay);
};
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.signal.Interest(function(message) {

View File

@@ -29,6 +29,12 @@
%if mathjax_mode is not Undefined and mathjax_mode == 'wiki':
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
styles: {
'.MathJax_SVG>svg': { 'max-width': '100%', },
},
CommonHTML: { linebreaks: { automatic: true } },
SVG: { linebreaks: { automatic: true } },
"HTML-CSS": { linebreaks: { automatic: true } },
tex2jax: {inlineMath: [ ['$','$'], ["\\(","\\)"]],
displayMath: [ ['$$','$$'], ["\\[","\\]"]]}
});
@@ -36,7 +42,13 @@
%else:
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
styles: {
'.MathJax_SVG>svg': { 'max-width': '100%', },
},
messageStyle: "none",
CommonHTML: { linebreaks: { automatic: true } },
SVG: { linebreaks: { automatic: true } },
"HTML-CSS": { linebreaks: { automatic: true } },
tex2jax: {
inlineMath: [
["\\(","\\)"],
@@ -85,6 +97,21 @@
explorer: true
}
};
window.addEventListener('resize', MJrerender);
let t = -1;
let delay = 1000;
function MJrerender() {
if (t >= 0) {
// If we are still waiting, then the user is still resizing =>
// postpone the action further!
window.clearTimeout(t);
}
t = window.setTimeout(function() {
MathJax.Hub.Queue(["Rerender",MathJax.Hub]);
t = -1; // Reset the handle
}, delay);
};
</script>
<!-- This must appear after all mathjax-config blocks, so it is after the imports from the other templates.