Skip to content

Commit

Permalink
Update the board after MathJax finishes typesetting to fix label posi…
Browse files Browse the repository at this point in the history
…tions.

When MathJax accessibility is enabled the tick label positions are off.
Updating the board after the labels are typeset fixes this.
  • Loading branch information
drgrice1 committed Dec 13, 2024
1 parent d9d2de8 commit a74b243
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions htdocs/js/GraphTool/graphtool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -501,7 +501,7 @@ window.graphTool = (containerId, options) => {
gt.graphedObjs.forEach((object) => object.onResize());
gt.staticObjs.forEach((object) => object.onResize());
}
};
});

window.addEventListener('resize', resize);

Expand Down Expand Up @@ -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());
};

0 comments on commit a74b243

Please sign in to comment.