From a74b2433b8debf17aaeb7720a0caa513585f4f26 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Fri, 13 Dec 2024 10:18:19 -0600 Subject: [PATCH] Update the board after MathJax finishes typesetting to fix label positions. When MathJax accessibility is enabled the tick label positions are off. Updating the board after the labels are typeset fixes this. --- htdocs/js/GraphTool/graphtool.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/js/GraphTool/graphtool.js b/htdocs/js/GraphTool/graphtool.js index 0474dcea8..9bcf13c32 100644 --- a/htdocs/js/GraphTool/graphtool.js +++ b/htdocs/js/GraphTool/graphtool.js @@ -482,7 +482,7 @@ window.graphTool = (containerId, options) => { }); } - const resize = () => { + const resize = (gt.resize = () => { // If the container does not have width or height (for example if the graph is inside a closed scaffold when // the window is resized), then delay resizing the graph until the container does have width and height. if (!gt.board.containerObj.offsetWidth || !gt.board.containerObj.offsetHeight) { @@ -501,7 +501,7 @@ window.graphTool = (containerId, options) => { gt.graphedObjs.forEach((object) => object.onResize()); gt.staticObjs.forEach((object) => object.onResize()); } - }; + }); window.addEventListener('resize', resize); @@ -2696,4 +2696,8 @@ window.graphTool = (containerId, options) => { gt.updateText(); gt.updateUI(); } + + // When MathJax accessibility is enabled the tick label positions are off. + // Updating the board after the labels are typeset fixes this. + if (window.MathJax) MathJax.startup.promise = MathJax.startup.promise.then(() => gt.board.update()); };